1 package jalview.ext.archaeopteryx;
3 import jalview.analysis.SequenceIdMatcher;
4 import jalview.datamodel.SequenceI;
6 import java.util.ArrayList;
9 import org.forester.phylogeny.Phylogeny;
10 import org.forester.phylogeny.PhylogenyNode;
12 public class JalviewToAptxAssociation
13 implements JalviewToLoadedTreeAssociationI<Phylogeny>
15 SequenceI[] alignSequences;
19 public JalviewToAptxAssociation(SequenceI[] alignmentSequences,
22 alignSequences = alignmentSequences;
30 * Tries to match sequences from Jalview with tree nodes in Archaeopteryx and
31 * fills in the tree node with sequence data if a match is found.
33 * Partially refactored from the old Jalview TreeModel
34 * associateLeavesToSequences method.
40 public void associateLeavesToSequences(SequenceI[] seqs,
43 SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);
45 List<PhylogenyNode> leaves = aptxTree.getExternalNodes();
47 int namesleft = seqs.length;
48 SequenceI nodeSequence;
49 String nodeSequenceName;
50 List<SequenceI> one2many = new ArrayList<>();
51 // int countOne2Many = 0;
53 for (PhylogenyNode treeNode : leaves)
55 nodeSequenceName = treeNode.getName();
60 nodeSequence = algnIds.findIdMatch(nodeSequenceName);
63 if (nodeSequence != null)
66 //treeNode.setElement(nodeSequence);
67 if (one2many.contains(nodeSequence))
70 if (jalview.bin.Cache.log.isDebugEnabled())
72 jalview.bin.Cache.log.debug("One 2 many relationship for"
73 +nodeSequence.getName());
78 one2many.add(nodeSequence);
84 // treeNode.setElement( new Sequence(nodeSequenceName, "THISISAPLACEHOLDER"));
85 // treeNode.setPlaceholder(true);
88 // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many>0) {
89 // jalview.bin.Cache.log.debug("There were "+countOne2Many+" alignment
90 // sequence ids (out of "+one2many.size()+" unique ids) linked to two or