JAL-281 split up TreeParser into separate format parsers
authorkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 20 Dec 2017 13:24:41 +0000 (13:24 +0000)
committerkjvdheide <kjvanderheide@dundee.ac.uk>
Wed, 20 Dec 2017 13:24:41 +0000 (13:24 +0000)
src/jalview/ext/archaeopteryx/JalviewBinding.java
src/jalview/ext/forester/io/ForesterParser.java [moved from src/jalview/ext/archaeopteryx/TreeParser.java with 76% similarity]
src/jalview/ext/forester/io/ForesterReader.java [new file with mode: 0644]
src/jalview/ext/forester/io/NexusParser.java
src/jalview/ext/forester/io/PhyloXMLParser.java
src/jalview/io/FileFormat.java

index 54b9225..2ba5a88 100644 (file)
@@ -9,13 +9,13 @@ import jalview.datamodel.ColumnSelection;
 import jalview.datamodel.HiddenColumns;
 import jalview.datamodel.SequenceGroup;
 import jalview.datamodel.SequenceI;
+import jalview.ext.treeviewer.LoadedTreeSequenceAssociation;
 import jalview.ext.treeviewer.TreeFrameI;
 import jalview.ext.treeviewer.TreeI;
 import jalview.ext.treeviewer.TreeNodeI;
 import jalview.ext.treeviewer.TreePanelI;
 import jalview.ext.treeviewer.TreeViewerBindingI;
 import jalview.ext.treeviewer.TreeViewerUtils;
-import jalview.ext.treeviewer.LoadedTreeSequenceAssociation;
 import jalview.gui.AlignViewport;
 import jalview.gui.AlignmentPanel;
 import jalview.gui.Desktop;
@@ -347,6 +347,10 @@ public final class JalviewBinding
                 tree.getRoot());
 
       }
+      else
+      {
+        // clear previous colours?
+      }
     }
 
 
@@ -1,5 +1,7 @@
-package jalview.ext.archaeopteryx;
+package jalview.ext.forester.io;
 
+import jalview.datamodel.SequenceI;
+import jalview.ext.archaeopteryx.Tree;
 import jalview.ext.treeviewer.TreeI;
 import jalview.ext.treeviewer.TreeParserI;
 
@@ -8,11 +10,13 @@ import java.io.IOException;
 import org.forester.io.parsers.PhylogenyParser;
 import org.forester.phylogeny.Phylogeny;
 
-public class TreeParser implements TreeParserI
+public class ForesterParser implements TreeParserI
 {
   private final PhylogenyParser parser;
 
-  public TreeParser(PhylogenyParser foresterParser)
+  private SequenceI[] seqs;
+
+  public ForesterParser(PhylogenyParser foresterParser)
   {
     parser = foresterParser;
   }
@@ -43,5 +47,4 @@ public class TreeParser implements TreeParserI
   {
     return parser.getName();
   }
-
-}
+}
\ No newline at end of file
diff --git a/src/jalview/ext/forester/io/ForesterReader.java b/src/jalview/ext/forester/io/ForesterReader.java
new file mode 100644 (file)
index 0000000..625a151
--- /dev/null
@@ -0,0 +1,91 @@
+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;
+  }
+
+}
index d48b033..f15c6f2 100644 (file)
-package jalview.ext.forester.io;
-
-import jalview.api.FeatureSettingsModelI;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceI;
-import jalview.ext.treeviewer.TreeI;
-import jalview.ext.treeviewer.TreeParserI;
-import jalview.io.AlignmentFileReaderI;
-import jalview.io.DataSourceType;
-
-import java.io.IOException;
-
-public class NexusParser implements TreeParserI, AlignmentFileReaderI
-{
-
-
-  public NexusParser()
-  {
-
-  }
-
-  @Override
-  public TreeI[] parse() throws IOException
-  {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @Override
-  public void setSource(Object source) throws IOException
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public String getName()
-  {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @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;
-  }
-}
+// 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
index 8194d21..e877d41 100644 (file)
-package jalview.ext.forester.io;
-
-import jalview.api.FeatureSettingsModelI;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceI;
-import jalview.ext.treeviewer.TreeI;
-import jalview.ext.treeviewer.TreeParserI;
-import jalview.io.AlignmentFileReaderI;
-import jalview.io.DataSourceType;
-
-import java.io.IOException;
-
-public class PhyloXMLParser implements TreeParserI, AlignmentFileReaderI
-{
-
-  @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 TreeI[] parse() throws IOException
-  {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-  @Override
-  public void setSource(Object source) throws IOException
-  {
-    // TODO Auto-generated method stub
-
-  }
-
-  @Override
-  public String getName()
-  {
-    // TODO Auto-generated method stub
-    return null;
-  }
-
-}
+// 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 718370a..ef4a2be 100644 (file)
@@ -22,6 +22,7 @@ package jalview.io;
 
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.PDBEntry;
+import jalview.ext.forester.io.ForesterReader;
 import jalview.ext.jmol.JmolParser;
 import jalview.structure.StructureImportSettings;
 
@@ -381,8 +382,7 @@ public enum FileFormat implements FileFormatI
     public AlignmentFileReaderI getReader(FileParse source)
             throws IOException
     {
-      // TODO Auto-generated method stub
-      return null;
+      return new ForesterReader(source);
     }
 
     @Override
@@ -406,8 +406,7 @@ public enum FileFormat implements FileFormatI
     public AlignmentFileReaderI getReader(FileParse source)
             throws IOException
     {
-      // TODO Auto-generated method stub
-      return null;
+      return new ForesterReader(source);
     }
 
     @Override