*/
package jalview.analysis;
+import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.BinaryNode;
import jalview.datamodel.NodeTransformI;
* NewickFile
*/
public TreeModel(SequenceI[] seqs, AlignmentView odata,
- NewickFile treefile)
+ NewickFile treefile, AlignmentAnnotation[] leafAnnotations)
{
this(seqs, treefile.getTree(), treefile.HasDistances(),
treefile.HasBootstrap(), treefile.HasRootDistance());
seqData = odata;
-
- associateLeavesToSequences(seqs);
+ if (leafAnnotations != null)
+ {
+ // leaf names are seuqence ID + annotation for display
+ // leaf links are annotationId <> annotation object for import from project
+ // --> need to resolve before passing for display
+ // ==> do leafs need to be renamed after import ?
+ // ==> implies the 'nodeLabel' business needs to be callable independently of score function
+ } else {
+ associateLeavesToSequences(seqs);
+ }
}
/**
return seqs;
}
+ //// ***************************************************
+ //// TODO REFACTOR TREE I/O TO CONTROLLER/SEPARATE CLASS
+ //// ***************************************************
+
/**
* DOCUMENT ME!
*
return tp;
}
+ public TreePanel showNewickTreeForAnnotation(NewickFile nf, String treeTitle,
+ AlignmentView input, int w, int h, int x, int y)
+ {
+ TreePanel tp = null;
+
+ try
+ {
+ nf.parse();
+
+ if (nf.getTree() != null)
+ {
+ tp = TreePanel.newTreeForAnnotations(alignPanel, nf, treeTitle, input);
+ // TODO - refactor layout code to one place for tree view methods
+ tp.setSize(w, h);
+
+ if (x > 0 && y > 0)
+ {
+ tp.setLocation(x, y);
+ }
+
+ Desktop.addInternalFrame(tp, treeTitle, w, h);
+ }
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return tp;
+ }
+
public void showContactMapTree(AlignmentAnnotation aa, ContactMatrixI cm)
{
}
return null;
}
+ //// ***************************************************
+ //// TODO REFACTOR TREE I/O TO CONTROLLER/SEPARATE CLASS - END OF METHODS
+ //// ***************************************************
private boolean buildingMenu = false;
super();
this.setFrameIcon(null);
this.similarityParams = options;
- initTreePanel(ap, type, modelName, null, null);
+ initTreePanel(ap, type, modelName, null, null, null);
// We know this tree has distances. JBPNote TODO: prolly should add this as
// a userdefined default
public TreePanel(AlignmentPanel alignPanel, NewickFile newtree,
String theTitle, AlignmentView inputData)
{
+ this(alignPanel, newtree, theTitle, inputData, null,null);
+ }
+
+ /**
+ * when true, leaf labels are annotations
+ */
+ boolean forAnnotation = false;
+
+ public TreePanel(AlignmentPanel alignPanel, NewickFile newtree,
+ String theTitle, AlignmentView inputData, AlignmentAnnotation[] leafAnnotations, String subTitle)
+ {
super();
+ this.forAnnotation=leafAnnotations!=null && leafAnnotations.length>0;
this.setFrameIcon(null);
this.treeTitle = theTitle;
- initTreePanel(alignPanel, null, null, newtree, inputData);
+ initTreePanel(alignPanel, null, null, newtree, inputData, null);
}
/**
assocAnnotation = aa;
this.setFrameIcon(null);
this.treeTitle = title;
- initTreePanel(alignPanel, null, null, fin, null);
+ initTreePanel(alignPanel, null, null, fin, null, null);
}
boolean columnWise = false;
return getTreeCanvas().getViewport();
}
+ private void addSubtitlePanel(String subTitle)
+ {
+ subtitleLabel = new JLabel(subTitle, SwingConstants.LEFT);
+
+ JPanel panel = new JPanel(new BorderLayout());
+ panel.add(subtitleLabel, BorderLayout.NORTH);
+ panel.add(scrollPane, BorderLayout.CENTER);
+
+ this.add(panel);
+ }
+
void initTreePanel(AlignmentPanel ap, String type, String modelName,
- NewickFile newTree, AlignmentView inputData)
+ NewickFile newTree, AlignmentView inputData, AlignmentAnnotation[] leafAnnotations)
{
av = ap.av;
treeCanvas = new TreeCanvas(this, ap, scrollPane);
scrollPane.setViewportView(treeCanvas);
- if(this.similarityParams!=null)
- if(this.similarityParams.getSecondaryStructureSource()!=null ) {
-
- subtitleLabel = new JLabel(" Secondary Structure Provider : "
- + this.similarityParams.getSecondaryStructureSource(), SwingConstants.LEFT);
-
- JPanel panel = new JPanel(new BorderLayout());
- panel.add(subtitleLabel, BorderLayout.NORTH);
- panel.add(scrollPane, BorderLayout.CENTER);
-
- this.add(panel);
- }
+ if (similarityParams != null
+ && similarityParams.getSecondaryStructureSource() != null)
+ {
+ addSubtitlePanel(" Secondary Structure Provider : "
+ + similarityParams.getSecondaryStructureSource());
+ }
+ if (leafAnnotations!=null)
+ {
+ forAnnotation=true;
+ }
if (columnWise)
{
bootstrapMenu.setVisible(false);
}
});
- TreeLoader tl = new TreeLoader(newTree, inputData);
+ TreeLoader tl = new TreeLoader(newTree, inputData, leafAnnotations);
tl.start();
}
private AlignmentView odata = null;
- public TreeLoader(NewickFile newickFile, AlignmentView inputData)
+ private AlignmentAnnotation[] leafAnnotations;
+ public TreeLoader(NewickFile newickFile, AlignmentView inputData, AlignmentAnnotation[] leafAnnotations)
{
this.newtree = newickFile;
this.odata = inputData;
-
+ this.leafAnnotations = leafAnnotations;
+
if (newickFile != null)
{
// Must be outside run(), as Jalview2XML tries to
if (newtree != null)
{
tree = new TreeModel(av.getAlignment().getSequencesArray(), odata,
- newtree);
+ newtree, leafAnnotations);
if (tree.getOriginalData() == null)
{
originalSeqData.setVisible(false);
{
return treeCanvas;
}
+
+ public static TreePanel newTreeForAnnotations(AlignmentPanel alignPanel,
+ NewickFile nf, String treeTitle2, AlignmentView input)
+ {
+ // TODO - recover subpanel name
+ TreePanel tp = new TreePanel(alignPanel, nf, treeTitle2, input, null, "Annotation Tree");
+ return tp;
+ }
}