1 package jalview.ext.archaeopteryx;
3 import jalview.analysis.SequenceIdMatcher;
4 import jalview.datamodel.SequenceI;
5 import jalview.ext.forester.ForesterDataConversions;
7 import java.util.ArrayList;
10 import org.forester.phylogeny.Phylogeny;
11 import org.forester.phylogeny.PhylogenyNode;
13 public class AptxNodeAssociation
14 implements ExternalLoadedTreeAssociationI<Phylogeny>
16 SequenceI[] alignSequences;
20 public AptxNodeAssociation(SequenceI[] alignmentSequences,
23 alignSequences = alignmentSequences;
31 * Tries to match sequences from Jalview with tree nodes in Archaeopteryx and
32 * fills in the tree node with sequence data if a match is found.
34 * Partially refactored from the old Jalview TreeModel
35 * associateLeavesToSequences method.
41 public void associateLeavesToSequences(SequenceI[] seqs,
44 SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);
46 List<PhylogenyNode> leaves = aptxTree.getExternalNodes();
48 int namesleft = seqs.length;
49 SequenceI nodeSequence;
50 String nodeSequenceName;
51 List<SequenceI> one2many = new ArrayList<>();
52 int countOne2Many = 0;
54 for (PhylogenyNode treeNode : leaves)
56 nodeSequenceName = treeNode.getName();
61 nodeSequence = algnIds.findIdMatch(nodeSequenceName);
64 if (nodeSequence != null)
66 org.forester.phylogeny.data.Sequence foresterNodeSeq = ForesterDataConversions.createForesterSequence(nodeSequence, true);
68 treeNode.getNodeData().setSequence(foresterNodeSeq);
69 if (one2many.contains(nodeSequence))
72 if (jalview.bin.Cache.log.isDebugEnabled())
74 jalview.bin.Cache.log.debug("One 2 many relationship for"
75 +nodeSequence.getName());
80 one2many.add(nodeSequence);
86 // treeNode.setElement( new Sequence(nodeSequenceName, "THISISAPLACEHOLDER"));
87 // treeNode.setPlaceholder(true);
90 // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many>0) {
91 // jalview.bin.Cache.log.debug("There were "+countOne2Many+" alignment
92 // sequence ids (out of "+one2many.size()+" unique ids) linked to two or