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.AlignmentFileReaderI; import jalview.io.DataSourceType; import jalview.io.FileParse; 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.phylogeny.Phylogeny; public class ForesterParser implements TreeParserI, AlignmentFileReaderI { private final PhylogenyParser parser; protected ForesterParser(PhylogenyParser foresterParser, FileParse source) { parser = foresterParser; } @Override public TreeI[] parse() throws IOException { Phylogeny[] foresterTrees = parser.parse(); TreeI[] jalviewTrees = new TreeI[foresterTrees.length]; for (int i = 0; i < foresterTrees.length; i++) { jalviewTrees[i] = new Tree(foresterTrees[i]); } return jalviewTrees; } @Override public void setSource(Object source) throws IOException { parser.setSource(source); } @Override public String getName() { 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; } 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); } }