* DOCUMENT ME!
*/
public NJTree(SequenceI[] sequence, AlignmentView seqData, String type,
- String pwtype, int start, int end)
+ String pwtype, ScoreModelI sm, int start, int end)
{
this.sequence = sequence;
this.node = new Vector();
type = "AV";
}
- if (!(pwtype.equals("PID")))
+ if (sm == null && !(pwtype.equals("PID")))
{
if (ResidueProperties.getScoreMatrix(pwtype) == null)
{
noseqs = i++;
- distance = findDistances();
+ distance = findDistances(sm);
// System.err.println("Made distances");// dbg
makeLeaves();
// System.err.println("Made leaves");// dbg
for (int j = 0; j < seqs.length; j++)
{
- seqs[j] = (SequenceI) list.get(j);
+ seqs[j] = list.get(j);
}
seqmatcher = new SequenceIdMatcher(seqs);
*
* @return similarity matrix used to compute tree
*/
- public float[][] findDistances()
+ public float[][] findDistances(ScoreModelI _pwmatrix)
{
float[][] distance = new float[noseqs][noseqs];
-
- // Pairwise substitution score (with no gap penalties)
- ScoreModelI _pwmatrix = ResidueProperties.getScoreModel(pwtype);
if (_pwmatrix == null)
{
- _pwmatrix = ResidueProperties.getScoreMatrix("BLOSUM62");
+ // Resolve substitution model
+ _pwmatrix = ResidueProperties.getScoreModel(pwtype);
+ if (_pwmatrix == null)
+ {
+ _pwmatrix = ResidueProperties.getScoreMatrix("BLOSUM62");
+ }
}
distance = _pwmatrix.findDistances(seqData);
return distance;
package jalview.appletgui;
import jalview.analysis.NJTree;
+import jalview.api.analysis.ScoreModelI;
+import jalview.api.analysis.ViewBasedAnalysisI;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.SequenceI;
import jalview.io.NewickFile;
+import jalview.schemes.ResidueProperties;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
seqs = av.getSelectionGroup().getSequencesInOrder(
av.getAlignment());
}
-
- tree = new NJTree(seqs, seqStrings, type, pwtype, start, end);
+ ScoreModelI sm = ResidueProperties.getScoreModel(pwtype);
+ if (sm instanceof ViewBasedAnalysisI)
+ {
+ try
+ {
+ sm = sm.getClass().newInstance();
+ ((ViewBasedAnalysisI) sm)
+ .configureFromAlignmentView(treeCanvas.ap);
+ } catch (Exception q)
+ {
+ System.err.println("Couldn't create a scoremodel instance for "
+ + sm.getName());
+ q.printStackTrace();
+ }
+ tree = new NJTree(seqs, seqStrings, type, pwtype, sm, start, end);
+ }
+ else
+ {
+ tree = new NJTree(seqs, seqStrings, type, pwtype, null, start,
+ end);
+ }
}
tree.reCount(tree.getTopNode());
seqs = av.getSelectionGroup().getSequencesInOrder(
av.getAlignment());
}
-
- tree = new NJTree(seqs, seqStrings, type, pwtype, start, end);
+ ScoreModelI sm = ResidueProperties.getScoreModel(pwtype);
+ if (sm instanceof ViewBasedAnalysisI)
+ {
+ try
+ {
+ sm = sm.getClass().newInstance();
+ ((ViewBasedAnalysisI) sm)
+ .configureFromAlignmentView(treeCanvas.ap);
+ } catch (Exception q)
+ {
+ Cache.log.error("Couldn't create a scoremodel instance for "
+ + sm.getName());
+ }
+ tree = new NJTree(seqs, seqStrings, type, pwtype, sm, start, end);
+ }
+ else
+ {
+ tree = new NJTree(seqs, seqStrings, type, pwtype, null, start,
+ end);
+ }
showDistances(true);
}