From: kjvdheide Date: Fri, 5 Jan 2018 04:00:58 +0000 (+0000) Subject: JAL-281 ForesterParser now extends from AlignFile X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=a01b86ddf621af845f71d04441870c4b52220c52;p=jalview.git JAL-281 ForesterParser now extends from AlignFile --- diff --git a/src/jalview/ext/forester/io/ForesterParser.java b/src/jalview/ext/forester/io/ForesterParser.java index 851b12b..6e86d7b 100644 --- a/src/jalview/ext/forester/io/ForesterParser.java +++ b/src/jalview/ext/forester/io/ForesterParser.java @@ -6,7 +6,7 @@ import jalview.datamodel.SequenceI; import jalview.ext.archaeopteryx.Tree; import jalview.ext.treeviewer.TreeI; import jalview.ext.treeviewer.TreeParserI; -import jalview.io.AlignmentFileReaderI; +import jalview.io.AlignFile; import jalview.io.DataSourceType; import jalview.io.FileParse; @@ -17,26 +17,40 @@ import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.phyloxml.PhyloXmlParser; import org.forester.phylogeny.Phylogeny; -public class ForesterParser implements TreeParserI, AlignmentFileReaderI +public class ForesterParser extends AlignFile + implements TreeParserI { private final PhylogenyParser parser; + private TreeI[] parsedTrees; + protected ForesterParser(PhylogenyParser foresterParser, FileParse source) { parser = foresterParser; } + public static ForesterParser createNexusParser(FileParse source) + { + return new ForesterParser(new NexusPhylogeniesParser(), source); + } + + public static ForesterParser createPhyloXmlParser(FileParse source) + { + // support non-xsd validating? + return new ForesterParser( + PhyloXmlParser.createPhyloXmlParserXsdValidating(), source); + } + @Override - public TreeI[] parse() throws IOException + public void parse() throws IOException { Phylogeny[] foresterTrees = parser.parse(); - TreeI[] jalviewTrees = new TreeI[foresterTrees.length]; + parsedTrees = new TreeI[foresterTrees.length]; for (int i = 0; i < foresterTrees.length; i++) { - jalviewTrees[i] = new Tree(foresterTrees[i]); + parsedTrees[i] = new Tree(foresterTrees[i]); } - return jalviewTrees; } @@ -116,15 +130,18 @@ public class ForesterParser implements TreeParserI, AlignmentFileReaderI return null; } - public static ForesterParser createNexusParser(FileParse source) + + + @Override + public String print(SequenceI[] seqs, boolean jvsuffix) { - return new ForesterParser(new NexusPhylogeniesParser(), source); + // TODO Auto-generated method stub + return null; } - public static ForesterParser createPhyloXmlParser(FileParse source) + @Override + public TreeI[] getParsedTrees() { - // support non-xsd validating? - return new ForesterParser( - PhyloXmlParser.createPhyloXmlParserXsdValidating(), source); + return parsedTrees; } } \ No newline at end of file diff --git a/src/jalview/ext/treeviewer/TreeParserI.java b/src/jalview/ext/treeviewer/TreeParserI.java index 00c8334..52b4f2c 100644 --- a/src/jalview/ext/treeviewer/TreeParserI.java +++ b/src/jalview/ext/treeviewer/TreeParserI.java @@ -4,10 +4,12 @@ import java.io.IOException; public interface TreeParserI { - public TreeI[] parse() throws IOException; + public void parse() throws IOException; public void setSource(Object source) throws IOException; public String getName(); + public TreeI[] getParsedTrees(); + }