From a6dca333c60641ceb0b54ccb2bd0f5ab457c7f88 Mon Sep 17 00:00:00 2001 From: kjvdheide Date: Tue, 9 Jan 2018 10:53:43 +0000 Subject: [PATCH] JAL-2805 parser is now File based (instead of FileParse) and source is now properly set --- src/jalview/ext/forester/io/ForesterParser.java | 99 ++++------------------- 1 file changed, 15 insertions(+), 84 deletions(-) diff --git a/src/jalview/ext/forester/io/ForesterParser.java b/src/jalview/ext/forester/io/ForesterParser.java index 6e86d7b..a6d7831 100644 --- a/src/jalview/ext/forester/io/ForesterParser.java +++ b/src/jalview/ext/forester/io/ForesterParser.java @@ -1,48 +1,49 @@ package jalview.ext.forester.io; -import jalview.api.FeatureSettingsModelI; -import jalview.datamodel.AlignmentI; -import jalview.datamodel.SequenceI; import jalview.ext.archaeopteryx.Tree; import jalview.ext.treeviewer.TreeI; import jalview.ext.treeviewer.TreeParserI; -import jalview.io.AlignFile; -import jalview.io.DataSourceType; -import jalview.io.FileParse; +import java.io.File; import java.io.IOException; import org.forester.io.parsers.PhylogenyParser; import org.forester.io.parsers.nexus.NexusPhylogeniesParser; import org.forester.io.parsers.phyloxml.PhyloXmlParser; +import org.forester.io.parsers.util.PhylogenyParserException; import org.forester.phylogeny.Phylogeny; -public class ForesterParser extends AlignFile +public class ForesterParser implements TreeParserI { private final PhylogenyParser parser; private TreeI[] parsedTrees; - protected ForesterParser(PhylogenyParser foresterParser, FileParse source) + protected ForesterParser(PhylogenyParser foresterParser, File file) + throws PhylogenyParserException, IOException { parser = foresterParser; + parser.setSource(file); } - public static ForesterParser createNexusParser(FileParse source) + public static ForesterParser createNexusParser(File file) + throws PhylogenyParserException, IOException { - return new ForesterParser(new NexusPhylogeniesParser(), source); + return new ForesterParser(new NexusPhylogeniesParser(), file); } - public static ForesterParser createPhyloXmlParser(FileParse source) + public static ForesterParser createPhyloXmlParser(File file) + throws PhylogenyParserException, IOException { // support non-xsd validating? return new ForesterParser( - PhyloXmlParser.createPhyloXmlParserXsdValidating(), source); + PhyloXmlParser.createPhyloXmlParserXsdValidating(), file); } + // ParserBasedPhylogenyFactory.getInstance().create(foresterParser, source) @Override - public void parse() throws IOException + public TreeI[] parse() throws IOException { Phylogeny[] foresterTrees = parser.parse(); parsedTrees = new TreeI[foresterTrees.length]; @@ -51,6 +52,7 @@ public class ForesterParser extends AlignFile { parsedTrees[i] = new Tree(foresterTrees[i]); } + return parsedTrees; } @@ -67,77 +69,6 @@ public class ForesterParser extends AlignFile return parser.getName(); } - @Override - public SequenceI[] getSeqsAsArray() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public void addAnnotations(AlignmentI al) - { - // TODO Auto-generated method stub - - } - - @Override - public void addGroups(AlignmentI al) - { - // TODO Auto-generated method stub - - } - - @Override - public void setSeqs(SequenceI[] sequencesArray) - { - // TODO Auto-generated method stub - - } - - @Override - public boolean hasWarningMessage() - { - // TODO Auto-generated method stub - return false; - } - - @Override - public String getWarningMessage() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getInFile() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public DataSourceType getDataSourceType() - { - // TODO Auto-generated method stub - return null; - } - - @Override - public FeatureSettingsModelI getFeatureColourScheme() - { - // TODO Auto-generated method stub - return null; - } - - - - @Override - public String print(SequenceI[] seqs, boolean jvsuffix) - { - // TODO Auto-generated method stub - return null; - } @Override public TreeI[] getParsedTrees() -- 1.7.10.2