public static MainFrame createUnboundInstance(final Phylogeny aptxTree)
{
Phylogeny[] aptxTrees = { aptxTree };
- return createAptxFrameInJalview(aptxTrees);
+ return createAptxFrame(aptxTrees);
}
// public static MainFrame createInstance(final Phylogeny[] aptxTrees,
Phylogeny[] aptxTrees = { aptxTree }; // future possibility to load in
// several trees simultaneously
- MainFrame aptxApp = createAptxFrameInJalview(aptxTrees);
+ MainFrame aptxApp = createAptxFrame(aptxTrees);
bindNodesToJalviewSequences(aptxApp, calculatedTree.getAvport(),
aptxTreeBuilder.getAlignmentBoundNodes(),
- public static MainFrame createAptxFrameInJalview(
+ public static MainFrame createAptxFrame(
final Phylogeny[] aptxTrees)
{
MainFrame aptxApp = Archaeopteryx.createApplication(aptxTrees,
"_aptx_jalview_configuration_file", null);
- bindFrameToJalview(aptxApp);
return aptxApp;
}
- public static void bindNodesToJalviewSequences(final MainFrame aptxApp,
+ public static JalviewTreeViewerBindingI bindNodesToJalviewSequences(
+ final MainFrame aptxApp,
final AlignmentViewport jalviewAlignViewport,
final Map<SequenceI, PhylogenyNode> alignMappedToNodes,
final Map<PhylogenyNode, SequenceI> nodesMappedToAlign)
{
- new JalviewAptxBinding(aptxApp, jalviewAlignViewport,
+ return new JalviewAptxBinding(aptxApp, jalviewAlignViewport,
alignMappedToNodes, nodesMappedToAlign);
}
* @param sequence
* of the node selected in the tree viewer.
*/
+ @Override
public void treeSelectionChanged(final SequenceI sequence)
{
SequenceGroup selected = parentAvport.getSelectionGroup();
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.analysis.SequenceIdMatcher;
+import jalview.datamodel.SequenceI;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.forester.phylogeny.Phylogeny;
+import org.forester.phylogeny.PhylogenyNode;
+
+public class JalviewToAptxAssociation
+ implements JalviewToSequenceAssociationI<Phylogeny>
+{
+ SequenceI[] alignSequences;
+
+ Phylogeny tree;
+
+ public JalviewToAptxAssociation(SequenceI[] alignmentSequences,
+ Phylogeny aptxTree)
+ {
+ alignSequences = alignmentSequences;
+ tree = aptxTree;
+
+ }
+
+
+
+ /**
+ * Tries to match sequences from Jalview with tree nodes in Archaeopteryx and
+ * fills in the tree node with sequence data if a match is found.
+ *
+ * Partially refactored from the old Jalview TreeModel
+ * associateLeavesToSequences method.
+ *
+ * @param seqs
+ * @param aptxTree
+ */
+ @Override
+ public void associateLeavesToSequences(SequenceI[] seqs,
+ Phylogeny aptxTree)
+ {
+ SequenceIdMatcher algnIds = new SequenceIdMatcher(seqs);
+
+ List<PhylogenyNode> leaves = aptxTree.getExternalNodes();
+
+ int namesleft = seqs.length;
+ SequenceI nodeSequence;
+ String nodeSequenceName;
+ List<SequenceI> one2many = new ArrayList<>();
+ // int countOne2Many = 0;
+
+ for (PhylogenyNode treeNode : leaves)
+ {
+ nodeSequenceName = treeNode.getName();
+ nodeSequence = null;
+
+ if (namesleft > -1)
+ {
+ nodeSequence = algnIds.findIdMatch(nodeSequenceName);
+ }
+
+ if (nodeSequence != null)
+ {
+
+ //treeNode.setElement(nodeSequence);
+ if (one2many.contains(nodeSequence))
+ {
+ // countOne2Many++;
+ if (jalview.bin.Cache.log.isDebugEnabled())
+ {
+ jalview.bin.Cache.log.debug("One 2 many relationship for"
+ +nodeSequence.getName());
+ }
+ }
+ else
+ {
+ one2many.add(nodeSequence);
+ namesleft--;
+ }
+ }
+ else
+ {
+ // treeNode.setElement( new Sequence(nodeSequenceName, "THISISAPLACEHOLDER"));
+ // treeNode.setPlaceholder(true);
+ }
+ }
+ // if (jalview.bin.Cache.log.isDebugEnabled() && countOne2Many>0) {
+ // jalview.bin.Cache.log.debug("There were "+countOne2Many+" alignment
+ // sequence ids (out of "+one2many.size()+" unique ids) linked to two or
+ // more leaves.");
+ // }
+ // one2many.clear();
+
+ }
+}
+
+
+
+
+
+
--- /dev/null
+package jalview.ext.archaeopteryx;
+
+import jalview.datamodel.SequenceI;
+
+interface JalviewToSequenceAssociationI<T>
+{
+ public void associateLeavesToSequences(SequenceI[] seqs, T tree);
+}
*/
package jalview.ext.archaeopteryx;
+import jalview.datamodel.SequenceI;
import jalview.structure.SelectionListener;
import jalview.structure.SelectionSource;
/**
* Interface for binding a tree viewer to Jalview alignments. Assumes a tree
- * viewer will both want to receive and send selection events
+ * viewer will both want to receive and send selection events.
*
* @author kjvanderheide
*
{
public void showNodeSelectionOnAlign(MouseEvent e);
+ public void treeSelectionChanged(final SequenceI sequence);
+
}
private final FileFilter treeFilter;
- SupportedTreeFileFilter(FileFilter treeFilter)
+ SupportedTreeFileFilter(final FileFilter treeFilter)
{
this.treeFilter = treeFilter;
private final File file;
- public TreeParser(String treeFilePath)
+ public TreeParser(final String treeFilePath)
{
final String possibleError = ForesterUtil.isReadableFile(treeFilePath);
if (possibleError != null)
}
- public TreeParser(File treeFile) throws IOException
+ public TreeParser(final File treeFile) throws IOException
{
final String possibleError = ForesterUtil.isReadableFile(treeFile);
if (possibleError != null)
filePath = file.getCanonicalPath();
}
-
- public void loadTree()
+ public MainFrame loadTree()
{
String[] AptxArgs = new String[] { "-c",
"_aptx_jalview_configuration_file", filePath };
MainFrame aptx = Archaeopteryx.main(AptxArgs);
ArchaeopteryxInit.bindFrameToJalview(aptx);
+ return aptx;
}
}
@Override
- public void setCurrentTree(TreeModel tree)
+ public void setCurrentTree(TreeModel tree) // adapt to Aptx
{
currentTree = tree;
}