From: kjvdheide Date: Tue, 9 Jan 2018 10:54:54 +0000 (+0000) Subject: JAL-2805 broke off the phylogenetic file formats into separate classes X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=7b80cf6c6749b157f48d18a0b4a8352a35a942d4;p=jalview.git JAL-2805 broke off the phylogenetic file formats into separate classes --- diff --git a/src/jalview/ext/forester/io/NexusFile.java b/src/jalview/ext/forester/io/NexusFile.java new file mode 100644 index 0000000..2db46cc --- /dev/null +++ b/src/jalview/ext/forester/io/NexusFile.java @@ -0,0 +1,41 @@ +package jalview.ext.forester.io; + +import jalview.datamodel.SequenceI; +import jalview.ext.treeviewer.TreeI; +import jalview.ext.treeviewer.TreeParserI; +import jalview.io.AlignFile; +import jalview.io.FileParse; + +import java.io.File; +import java.io.IOException; + +public class NexusFile extends AlignFile +{ + + public NexusFile(FileParse source) throws IOException + { + super(source); + } + + @Override + public String print(SequenceI[] seqs, boolean jvsuffix) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public void parse() throws IOException + { + TreeParserI parser = ForesterParser + .createNexusParser(new File(getDataName())); + TreeI[] trees = parser.parse(); + for (TreeI tree : trees) { + for (SequenceI seq : tree.getNodeSequences()) { + seqs.add(seq); + } + } + + } + +} diff --git a/src/jalview/ext/forester/io/PhyloXmlFile.java b/src/jalview/ext/forester/io/PhyloXmlFile.java new file mode 100644 index 0000000..e64845c --- /dev/null +++ b/src/jalview/ext/forester/io/PhyloXmlFile.java @@ -0,0 +1,40 @@ +package jalview.ext.forester.io; + +import jalview.datamodel.SequenceI; +import jalview.ext.treeviewer.TreeI; +import jalview.ext.treeviewer.TreeParserI; +import jalview.io.AlignFile; +import jalview.io.FileParse; + +import java.io.File; +import java.io.IOException; + +public class PhyloXmlFile extends AlignFile +{ + + public PhyloXmlFile(FileParse source) throws IOException + { + super(source); + } + + @Override + public String print(SequenceI[] seqs, boolean jvsuffix) + { + // TODO Auto-generated method stub + return null; + } + + @Override + public void parse() throws IOException + { + TreeParserI parser = ForesterParser + .createPhyloXmlParser(new File(getDataName())); + TreeI[] trees = parser.parse(); + for (SequenceI seq : trees[0].getNodeSequences()) + { + seqs.add(seq); + } + + } + +} diff --git a/src/jalview/io/FileFormat.java b/src/jalview/io/FileFormat.java index e737c35..2b0122b 100644 --- a/src/jalview/io/FileFormat.java +++ b/src/jalview/io/FileFormat.java @@ -22,7 +22,8 @@ package jalview.io; import jalview.datamodel.AlignmentI; import jalview.datamodel.PDBEntry; -import jalview.ext.forester.io.ForesterParser; +import jalview.ext.forester.io.NexusFile; +import jalview.ext.forester.io.PhyloXmlFile; import jalview.ext.jmol.JmolParser; import jalview.structure.StructureImportSettings; @@ -382,7 +383,7 @@ public enum FileFormat implements FileFormatI public AlignmentFileReaderI getReader(FileParse source) throws IOException { - return ForesterParser.createNexusParser(source); + return new NexusFile(source); } @Override @@ -406,7 +407,7 @@ public enum FileFormat implements FileFormatI public AlignmentFileReaderI getReader(FileParse source) throws IOException { - return ForesterParser.createPhyloXmlParser(source); + return new PhyloXmlFile(source); } @Override