--- /dev/null
+package jalview.ext.forester;
+
+import jalview.datamodel.SequenceI;
+import jalview.math.MatrixI;
+
+import org.forester.evoinference.matrix.distance.DistanceMatrix;
+import org.forester.io.parsers.phyloxml.PhyloXmlDataFormatException;
+
+public final class ForesterConversions
+{
+ public static org.forester.phylogeny.data.Sequence createForesterSequence(
+ SequenceI jalviewSequence)
+ {
+ org.forester.phylogeny.data.Sequence foresterSeq = new org.forester.phylogeny.data.Sequence();
+ if (jalviewSequence.getDescription() != null)
+ {
+ foresterSeq.setName(jalviewSequence.getDescription());
+ }
+ foresterSeq.setMolecularSequenceAligned(true); // all tree sequences should
+ // be aligned already
+ foresterSeq.setMolecularSequence(jalviewSequence.getSequenceAsString());
+ if (jalviewSequence.isProtein()) // add checks for DNA or RNA (infer from
+ // forester itself?)
+ {
+ try
+ {
+ foresterSeq.setType("protein");
+ } catch (final PhyloXmlDataFormatException ignore)
+ {
+ // do nothing
+ }
+
+ }
+
+ return foresterSeq;
+
+ }
+
+
+ // public static org.forester.phylogeny.data.Accession
+ // createForesterAccession(
+ // SequenceI jalviewSequence)
+ // {
+ //
+ //
+ // org.forester.phylogeny.data.Accession foresterAcs = new
+ // org.forester.phylogeny.data.Accession();
+ //
+ // return foresterAcs;
+ // }
+
+ public static DistanceMatrix createForesterDistanceMatrix(
+ final MatrixI jalviewInputMatrix,
+ final String[] matrixIdentifiers)
+ {
+ if (jalviewInputMatrix.width() != jalviewInputMatrix.height())
+ {
+ // some kind of warning?
+ }
+
+ DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix,
+ matrixIdentifiers);
+ return foresterMatrix;
+
+ }
+
+ public static DistanceMatrix createForesterDistanceMatrix(
+ final MatrixI jalviewInputMatrix,
+ final SequenceI[] matrixSequences)
+ {
+ if (jalviewInputMatrix.width() != jalviewInputMatrix.height())
+ {
+ // some kind of warning?
+ }
+ DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix,
+ matrixSequences);
+ return foresterMatrix;
+
+ }
+}
this.identifiers = new String[matrixSequences.length];
int i = 0;
-
for (SequenceI sequence : matrixSequences)
{
identifiers[i] = sequence.getName();
final MatrixI jalviewInputMatrix,
final SequenceI[] matrixSequences)
{
- if (jalviewInputMatrix.width() != jalviewInputMatrix.height())
- {
- // some kind of warning?
- }
- DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix,
- matrixSequences);
- return foresterMatrix;
+ return ForesterConversions.createForesterDistanceMatrix(
+ jalviewInputMatrix, matrixSequences);
}
final MatrixI jalviewInputMatrix,
final String[] matrixIdentifiers)
{
- if (jalviewInputMatrix.width() != jalviewInputMatrix.height())
- {
- // some kind of warning?
- }
-
- DistanceMatrix foresterMatrix = new ForesterMatrix(jalviewInputMatrix,
- matrixIdentifiers);
- return foresterMatrix;
+ return ForesterConversions.createForesterDistanceMatrix(
+ jalviewInputMatrix, matrixIdentifiers);
}