JAL-2805 broke off the phylogenetic file formats into separate classes
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Tue, 9 Jan 2018 10:54:54 +0000 (10:54 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Tue, 9 Jan 2018 10:54:54 +0000 (10:54 +0000)
src/jalview/ext/forester/io/NexusFile.java [new file with mode: 0644]
src/jalview/ext/forester/io/PhyloXmlFile.java [new file with mode: 0644]
src/jalview/io/FileFormat.java

diff --git a/src/jalview/ext/forester/io/NexusFile.java b/src/jalview/ext/forester/io/NexusFile.java
new file mode 100644 (file)
index 0000000..2db46cc
--- /dev/null
@@ -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 (file)
index 0000000..e64845c
--- /dev/null
@@ -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);
+      }
+
+  }
+
+}
index e737c35..2b0122b 100644 (file)
@@ -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