From a01b86ddf621af845f71d04441870c4b52220c52 Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Fri, 5 Jan 2018 04:00:58 +0000 Subject: [PATCH] JAL-281 ForesterParser now extends from AlignFile --- src/jalview/ext/forester/io/ForesterParser.java | 41 ++++++++++++++++------- src/jalview/ext/treeviewer/TreeParserI.java | 4 ++- 2 files changed, 32 insertions(+), 13 deletions(-) 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(); + } -- 1.7.10.2