JAL-1919 set default structure file format to mmCIF, refactored some StructureImportS...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 19 Jul 2016 11:49:35 +0000 (12:49 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 19 Jul 2016 11:49:35 +0000 (12:49 +0100)
src/jalview/bin/Cache.java
src/jalview/datamodel/DBRefSource.java
src/jalview/ext/jmol/JmolParser.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/structure/StructureImportSettings.java
src/jalview/ws/dbsources/Pdb.java
test/jalview/ext/jmol/JmolParserTest.java
test/jalview/io/AnnotatedPDBFileInputTest.java
test/jalview/ws/PDBSequenceFetcherTest.java

index cf251dc..23277a4 100755 (executable)
@@ -20,7 +20,6 @@
  */
 package jalview.bin;
 
-import jalview.datamodel.DBRefSource;
 import jalview.structure.StructureImportSettings;
 import jalview.ws.dbsources.das.api.DasSourceRegistryI;
 import jalview.ws.dbsources.das.datamodel.DasSourceRegistry;
@@ -228,7 +227,9 @@ public class Cache
 
   private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30";
 
-  private final static String DEFAULT_STRUCTURE_FORMAT = DBRefSource.PDB;
+  private final static String DEFAULT_STRUCTURE_FORMAT = StructureImportSettings.MMCIF;
+  
+  private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.JMOL_PARSER;
 
   /**
    * Initialises the Jalview Application Log
@@ -426,10 +427,12 @@ public class Cache
     System.out
             .println("Jalview Version: " + codeVersion + codeInstallation);
 
-    StructureImportSettings.setCurrentDefaultFormat(jalview.bin.Cache
+    StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache
             .getDefault(
             "DEFAULT_STRUCTURE_FORMAT", DEFAULT_STRUCTURE_FORMAT));
-
+    StructureImportSettings
+            .setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
+                    "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
     StructureImportSettings.setProcessHETATMs(jalview.bin.Cache.getDefault(
             "PROCESS_HETATM", false));
     // jnlpVersion will be null if we're using InstallAnywhere
index cf15ff8..fba9211 100755 (executable)
@@ -57,11 +57,6 @@ public class DBRefSource
   public static String PDB = "PDB";
 
   /**
-   * mmCIF Entry Code
-   */
-  public static String MMCIF = "mmCIF";
-
-  /**
    * EMBL ID
    */
   public static String EMBL = "EMBL";
index a791558..ea347ae 100644 (file)
@@ -22,7 +22,6 @@ package jalview.ext.jmol;
 
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.Annotation;
-import jalview.datamodel.DBRefSource;
 import jalview.datamodel.SequenceI;
 import jalview.io.FileParse;
 import jalview.io.StructureFile;
@@ -87,15 +86,6 @@ public class JmolParser extends StructureFile implements JmolStatusListener
   @Override
   public void parse() throws IOException
   {
-    String dataName = getDataName();
-    if (dataName.endsWith(".cif"))
-    {
-      setDbRefType(DBRefSource.MMCIF);
-    }
-    else
-    {
-      setDbRefType(DBRefSource.PDB);
-    }
     setChains(new Vector<PDBChain>());
     Viewer jmolModel = getJmolData();
     jmolModel.openReader(getDataName(), getDataName(), getReader());
index fb414f4..fca7263 100755 (executable)
@@ -280,8 +280,9 @@ public class AppletFormatAdapter
       {
         // TODO obtain config value from preference settings.
         // Set value to 'true' to test PDB processing with Jmol: JAL-1213
-        boolean isParseWithJMOL = !StructureImportSettings
-                .getCurrentDefaultFormat().equalsIgnoreCase("PDB");
+        boolean isParseWithJMOL = StructureImportSettings
+                .getDefaultPDBFileParser().equalsIgnoreCase(
+                        StructureImportSettings.JMOL_PARSER);
         if (isParseWithJMOL)
         {
           StructureImportSettings.addSettings(annotFromStructure,
@@ -299,6 +300,7 @@ public class AppletFormatAdapter
                   localSecondaryStruct, serviceSecondaryStruct, inFile,
                   type);
         }
+        ((StructureFile) alignFile).setDbRefType(format);
       }
       else if (format.equals("mmCIF"))
       {
@@ -306,6 +308,7 @@ public class AppletFormatAdapter
                 localSecondaryStruct, serviceSecondaryStruct);
         alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
                 localSecondaryStruct, serviceSecondaryStruct, inFile, type);
+        ((StructureFile) alignFile).setDbRefType(format);
       }
       else if (format.equals("STH"))
       {
@@ -447,6 +450,8 @@ public class AppletFormatAdapter
           alignFile = new MCview.PDBfile(annotFromStructure,
                   localSecondaryStruct, serviceSecondaryStruct, source);
         }
+        ((StructureFile) alignFile)
+                .setDbRefType(StructureImportSettings.PDB);
       }
       else if (format.equals("mmCIF"))
       {
@@ -454,6 +459,8 @@ public class AppletFormatAdapter
                 localSecondaryStruct, serviceSecondaryStruct);
         alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
                 localSecondaryStruct, serviceSecondaryStruct, source);
+        ((StructureFile) alignFile)
+                .setDbRefType(StructureImportSettings.MMCIF);
       }
       else if (format.equals("STH"))
       {
index b23fd53..4c06e0f 100644 (file)
@@ -26,8 +26,25 @@ public class StructureImportSettings
 
   private static boolean processHETATMs = false;
 
-  private static String currentDefaultFormat = DBRefSource.PDB;
+  public static final String JMOL_PARSER = "JMolParser";
 
+  public static final String JALVIEW_PARSER = "JalViewParser";
+
+  public static final String MMCIF = "mmCIF";
+
+  public static final String PDB = "PDB";
+
+  /**
+   * Determines the default file format for structure files to be downloaded
+   * from the PDB sequence fetcher. Possible options include: PDB|mmCIF
+   */
+  private static String defaultStructureFileFormat = DBRefSource.PDB;
+
+  /**
+   * Determines the parser used for parsing PDB format file. Possible options
+   * are : JMolParser|JalveiwParser
+   */
+  private static String defaultPDBFileParser = JMOL_PARSER;
   public static void addSettings(boolean addAlignmentAnnotations,
           boolean predictSecStr, boolean externalSecStr)
   {
@@ -80,14 +97,15 @@ public class StructureImportSettings
     StructureImportSettings.showSeqFeatures = showSeqFeatures;
   }
 
-  public static String getCurrentDefaultFormat()
+  public static String getDefaultStructureFileFormat()
   {
-    return currentDefaultFormat;
+    return defaultStructureFileFormat;
   }
 
-  public static void setCurrentDefaultFormat(String currentDefaultFormat)
+  public static void setDefaultStructureFileFormat(
+          String defaultStructureFileFormat)
   {
-    StructureImportSettings.currentDefaultFormat = currentDefaultFormat;
+    StructureImportSettings.defaultStructureFileFormat = defaultStructureFileFormat;
   }
 
   public static boolean isProcessHETATMs()
@@ -100,4 +118,14 @@ public class StructureImportSettings
     StructureImportSettings.processHETATMs = processHETATMs;
   }
 
+  public static String getDefaultPDBFileParser()
+  {
+    return defaultPDBFileParser;
+  }
+
+  public static void setDefaultPDBFileParser(String defaultPDBFileParser)
+  {
+    StructureImportSettings.defaultPDBFileParser = defaultPDBFileParser;
+  }
+
 }
index d945699..1a58466 100644 (file)
@@ -132,12 +132,12 @@ public class Pdb extends EbiFileRetrievedProxy
       stopQuery();
       return null;
     }
-    String ext = StructureImportSettings.getCurrentDefaultFormat()
+    String ext = StructureImportSettings.getDefaultStructureFileFormat()
             .equalsIgnoreCase("mmcif") ? ".cif"
             : ".xml";
     EBIFetchClient ebi = new EBIFetchClient();
     file = ebi.fetchDataAsFile("pdb:" + id,
-            StructureImportSettings.getCurrentDefaultFormat().toLowerCase(),
+            StructureImportSettings.getDefaultStructureFileFormat().toLowerCase(),
             ext)
             .getAbsolutePath();
     stopQuery();
@@ -150,7 +150,7 @@ public class Pdb extends EbiFileRetrievedProxy
 
       pdbAlignment = new FormatAdapter().readFile(file,
               jalview.io.AppletFormatAdapter.FILE,
-              StructureImportSettings.getCurrentDefaultFormat());
+              StructureImportSettings.getDefaultStructureFileFormat());
       if (pdbAlignment != null)
       {
         List<SequenceI> toremove = new ArrayList<SequenceI>();
index 0627a4a..0010321 100644 (file)
@@ -89,6 +89,9 @@ public class JmolParserTest
             Boolean.TRUE.toString());
     Cache.applicationProperties.setProperty("ADD_SS_ANN",
             Boolean.TRUE.toString());
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureImportSettings.JALVIEW_PARSER);
   }
 
   @Test(groups = { "Functional" })
index 3524a88..5368d41 100644 (file)
@@ -66,7 +66,9 @@ public class AnnotatedPDBFileInputTest
     al = af.getViewport().getAlignment();
     pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
             .get(0).getId();
-    StructureImportSettings.setCurrentDefaultFormat("PDB");
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureImportSettings.JALVIEW_PARSER);
   }
 
   @Test(groups = { "Functional" })
index 0c810a3..d082785 100644 (file)
@@ -86,7 +86,9 @@ public class PDBSequenceFetcherTest
   {
     Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
             Boolean.TRUE.toString());
-    StructureImportSettings.setCurrentDefaultFormat("PDB");
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureImportSettings.JALVIEW_PARSER);
 
     testRetrieveProteinSeqFromPDB();
   }
@@ -96,7 +98,7 @@ public class PDBSequenceFetcherTest
   {
     Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
             Boolean.TRUE.toString());
-    StructureImportSettings.setCurrentDefaultFormat("mmCIF");
+    StructureImportSettings.setDefaultStructureFileFormat("mmCIF");
     testRetrieveProteinSeqFromPDB();
   }