JAL-281 ForesterParser factory methods added
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 4 Jan 2018 20:17:49 +0000 (20:17 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Thu, 4 Jan 2018 20:17:49 +0000 (20:17 +0000)
src/jalview/ext/forester/io/ForesterParser.java
src/jalview/ext/forester/io/ForesterReader.java [deleted file]
src/jalview/ext/forester/io/NexusParser.java [deleted file]
src/jalview/ext/forester/io/PhyloXMLParser.java [deleted file]
src/jalview/io/FileFormat.java

index 1167e13..851b12b 100644 (file)
@@ -1,22 +1,27 @@
 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
+public class ForesterParser implements TreeParserI, AlignmentFileReaderI
 {
   private final PhylogenyParser parser;
 
-  private SequenceI[] seqs;
-
-  public ForesterParser(PhylogenyParser foresterParser)
+  protected ForesterParser(PhylogenyParser foresterParser, FileParse source)
   {
     parser = foresterParser;
   }
@@ -47,4 +52,79 @@ public class ForesterParser implements TreeParserI
   {
     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);
+  }
 }
\ No newline at end of file
diff --git a/src/jalview/ext/forester/io/ForesterReader.java b/src/jalview/ext/forester/io/ForesterReader.java
deleted file mode 100644 (file)
index 625a151..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-package jalview.ext.forester.io;
-
-import jalview.api.FeatureSettingsModelI;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceI;
-import jalview.io.AlignmentFileReaderI;
-import jalview.io.DataSourceType;
-import jalview.io.FileParse;
-
-public class ForesterReader implements AlignmentFileReaderI
-{
-
-  public ForesterReader(FileParse source)
-  {
-    // if (source.getDataSourceType() == DataSourceType.URL)
-    // {
-    // ParserUtils.createParserDependingOnUrlContents(url,
-    // AptxInit.APTX_CONFIG.isValidatePhyloXmlAgainstSchema());
-    //
-    // }
-    // else
-    // {
-    // ParserUtils.createParserDependingOnFileType(file,
-    // AptxInit.APTX_CONFIG.isValidatePhyloXmlAgainstSchema());
-    // }
-  }
-
-  @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;
-  }
-
-}
diff --git a/src/jalview/ext/forester/io/NexusParser.java b/src/jalview/ext/forester/io/NexusParser.java
deleted file mode 100644 (file)
index f15c6f2..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-// package jalview.ext.forester.io;
-//
-// import jalview.api.FeatureSettingsModelI;
-// import jalview.datamodel.AlignmentI;
-// import jalview.datamodel.SequenceI;
-// import jalview.io.AlignmentFileReaderI;
-// import jalview.io.DataSourceType;
-//
-// import org.forester.io.parsers.nexus.NexusPhylogeniesParser;
-//
-// public class NexusParser extends ForesterParser
-// implements AlignmentFileReaderI
-// {
-// NexusPhylogeniesParser nxParser;
-//
-// public NexusParser()
-// {
-// nxParser = new NexusPhylogeniesParser();
-//
-// }
-//
-// @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;
-// }
-//
-//
-//
-// }
\ No newline at end of file
diff --git a/src/jalview/ext/forester/io/PhyloXMLParser.java b/src/jalview/ext/forester/io/PhyloXMLParser.java
deleted file mode 100644 (file)
index e877d41..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-// package jalview.ext.forester.io;
-//
-// import jalview.api.FeatureSettingsModelI;
-// import jalview.datamodel.AlignmentI;
-// import jalview.datamodel.SequenceI;
-// import jalview.io.AlignmentFileReaderI;
-// import jalview.io.DataSourceType;
-//
-// import org.forester.io.parsers.PhylogenyParser;
-// import org.forester.io.parsers.phyloxml.PhyloXmlParser;
-//
-// public class PhyloXMLParser extends ForesterParser
-// implements AlignmentFileReaderI
-// {
-// PhyloXmlParser phxmlParser = PhyloXmlParser
-// .createPhyloXmlParserXsdValidating();
-//
-// public PhyloXMLParser(PhylogenyParser foresterParser)
-// {
-// super(foresterParser);
-// }
-//
-// @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;
-// }
-//
-// }
\ No newline at end of file
index ef4a2be..e737c35 100644 (file)
@@ -22,7 +22,7 @@ package jalview.io;
 
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.PDBEntry;
-import jalview.ext.forester.io.ForesterReader;
+import jalview.ext.forester.io.ForesterParser;
 import jalview.ext.jmol.JmolParser;
 import jalview.structure.StructureImportSettings;
 
@@ -382,13 +382,13 @@ public enum FileFormat implements FileFormatI
     public AlignmentFileReaderI getReader(FileParse source)
             throws IOException
     {
-      return new ForesterReader(source);
+      return ForesterParser.createNexusParser(source);
     }
 
     @Override
     public AlignmentFileWriterI getWriter(AlignmentI al)
     {
-      // TODO Auto-generated method stub
+      // handle within Aptx?
       return null;
     }
 
@@ -406,13 +406,13 @@ public enum FileFormat implements FileFormatI
     public AlignmentFileReaderI getReader(FileParse source)
             throws IOException
     {
-      return new ForesterReader(source);
+      return ForesterParser.createPhyloXmlParser(source);
     }
 
     @Override
     public AlignmentFileWriterI getWriter(AlignmentI al)
     {
-      // TODO Auto-generated method stub
+      // handle within Aptx?
       return null;
     }