* SequenceData is a string representation of what the user
* sees. The display may contain hidden columns.
*/
- public AlignmentView seqData;
+ private AlignmentView seqData;
int noseqs;
/**
* Create a new TreeModel object with leaves associated with sequences in
- * seqs, and original alignment data represented by Cigar strings
+ * seqs, and (optionally) original alignment data represented by Cigar strings
*
* @param seqs
* SequenceI[]
*/
public TreeModel(SequenceI[] seqs, AlignmentView odata, NewickFile treefile)
{
- this(seqs, treefile);
- seqData = odata;
- }
-
- /**
- * Creates a new TreeModel object from a tree from an external source
- *
- * @param seqs
- * SequenceI which should be associated with leafs of treefile
- * @param treefile
- * A parsed tree
- */
- public TreeModel(SequenceI[] seqs, NewickFile treefile)
- {
this(seqs, treefile.getTree(), treefile.HasDistances(), treefile
.HasBootstrap(), treefile.HasRootDistance());
+ seqData = odata;
associateLeavesToSequences(seqs);
}
}
/**
- *
- * @return true if original sequence data can be recovered
- */
- public boolean hasOriginalSequenceData()
- {
- return seqData != null;
- }
-
- /**
* Returns original alignment data used for calculation - or null where not
* available.
*
;
}
}
+
+ public AlignmentView getOriginalData()
+ {
+ return seqData;
+ }
}
*/
boolean isProtein();
+ // TODO getName, isDNA, isProtein can be static methods in Java 8
}
// yields unaligned seqs)
// or create a selection box around columns in alignment view
// test Alignment(SeqCigar[])
- if (tree.seqData != null)
+ if (tree.getOriginalData() != null)
{
char gc = '-';
try
} catch (Exception ex)
{
}
- ;
- Object[] alAndColsel = tree.seqData
+
+ Object[] alAndColsel = tree.getOriginalData()
.getAlignmentAndColumnSelection(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
if (newtree != null)
{
- if (odata == null)
- {
- tree = new TreeModel(av.getAlignment().getSequencesArray(),
- newtree);
- }
- else
- {
- tree = new TreeModel(av.getAlignment().getSequencesArray(),
- odata, newtree);
- }
-
+ tree = new TreeModel(av.getAlignment().getSequencesArray(), odata,
+ newtree);
}
else
{
}
});
- TreeLoader tl = new TreeLoader(newTree);
- if (inputData != null)
- {
- tl.odata = inputData;
- }
+ TreeLoader tl = new TreeLoader(newTree, inputData);
tl.start();
}
class TreeLoader extends Thread
{
- NewickFile newtree;
+ private NewickFile newtree;
- AlignmentView odata = null;
+ private AlignmentView odata = null;
- public TreeLoader(NewickFile newickFile)
+ public TreeLoader(NewickFile newickFile, AlignmentView inputData)
{
this.newtree = newickFile;
+ this.odata = inputData;
+
if (newickFile != null)
{
// Must be outside run(), as Jalview2XML tries to
if (newtree != null)
{
- if (odata == null)
+ tree = new TreeModel(av.getAlignment().getSequencesArray(), odata,
+ newtree);
+ if (tree.getOriginalData() == null)
{
- tree = new TreeModel(av.getAlignment().getSequencesArray(),
- newtree);
- }
- else
- {
- tree = new TreeModel(av.getAlignment().getSequencesArray(),
- odata, newtree);
- }
- if (!tree.hasOriginalSequenceData())
- {
- allowOriginalSeqData(false);
+ originalSeqData.setVisible(false);
}
}
else
treeCanvas.setMarkPlaceholders(b);
}
- private void allowOriginalSeqData(boolean b)
- {
- originalSeqData.setVisible(b);
- }
-
/**
* DOCUMENT ME!
*
@Override
public void originalSeqData_actionPerformed(ActionEvent e)
{
- if (!tree.hasOriginalSequenceData())
+ AlignmentView originalData = tree.getOriginalData();
+ if (originalData == null)
{
jalview.bin.Cache.log
.info("Unexpected call to originalSeqData_actionPerformed - should have hidden this menu action.");
} catch (Exception ex)
{
}
- ;
- Object[] alAndColsel = tree.seqData.getAlignmentAndColumnSelection(gc);
+
+ Object[] alAndColsel = originalData
+ .getAlignmentAndColumnSelection(gc);
if (alAndColsel != null && alAndColsel[0] != null)
{
*/
package jalview.io.packed;
+import jalview.analysis.TreeModel;
import jalview.api.FeatureColourI;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.SequenceI;
{
// the following works because all trees are already had node/SequenceI
// associations created.
- jalview.analysis.TreeModel njt = new jalview.analysis.TreeModel(
- al.getSequencesArray(), nf);
+ TreeModel njt = new TreeModel(al.getSequencesArray(), null, nf);
// this just updates the displayed leaf name on the tree according to
// the SequenceIs.
njt.renameAssociatedNodes();
prov.getEntry(0).setUser(provEntry.getUser());
prov.getEntry(0).setApp(provEntry.getApp());
prov.getEntry(0).setDate(provEntry.getDate());
- if (tp.getTree().hasOriginalSequenceData())
+
+ AlignmentView originalData = tp.getTree().getOriginalData();
+ if (originalData != null)
{
Input vInput = new Input();
// LATER: check to see if tree input data is contained in this alignment -
// or just correctly resolve the tree's seqData to the correct alignment
// in
// the document.
- Vector alsqrefs = getjv2vObjs(findAlignmentSequences(jal,
- tp.getTree().seqData.getSequences()));
+ Vector alsqrefs = getjv2vObjs(findAlignmentSequences(jal, tp
+ .getTree().getOriginalData().getSequences()));
Object[] alsqs = new Object[alsqrefs.size()];
alsqrefs.copyInto(alsqs);
vInput.setObjRef(alsqs);
prov.getEntry(0).getParam(0)
.setContent(TreeBuilder.NEIGHBOUR_JOINING);
// TODO: type of tree is a general parameter
- int ranges[] = tp.getTree().seqData.getVisibleContigs();
+ int ranges[] = originalData.getVisibleContigs();
// VisibleContigs are with respect to alignment coordinates. Still need
// offsets
- int start = tp.getTree().seqData.getAlignmentOrigin();
+ int start = tp.getTree().getOriginalData().getAlignmentOrigin();
for (int r = 0; r < ranges.length; r += 2)
{
Seg visSeg = new Seg();
stage = "Compare original and generated tree" + treename;
Vector<SequenceNode> oseqs, nseqs;
- oseqs = new TreeModel(new SequenceI[0], nf).findLeaves(nf.getTree());
+ oseqs = new TreeModel(new SequenceI[0], null, nf).findLeaves(nf
+ .getTree());
AssertJUnit.assertTrue(stage + "No nodes in original tree.",
oseqs.size() > 0);
SequenceI[] olsqs = new SequenceI[oseqs.size()];
{
olsqs[i] = (SequenceI) oseqs.get(i).element();
}
- nseqs = new TreeModel(new SequenceI[0], nf_regen).findLeaves(nf_regen
+ nseqs = new TreeModel(new SequenceI[0], null, nf_regen)
+ .findLeaves(nf_regen
.getTree());
AssertJUnit.assertTrue(stage + "No nodes in regerated tree.",
nseqs.size() > 0);