Revert "JAL-2164 JAL-1919 disabled and removed PDB file parser configuration option...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 13 Sep 2016 16:07:44 +0000 (17:07 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 13 Sep 2016 16:07:44 +0000 (17:07 +0100)
This reverts commit 13bc8a3fb89b083922d9fa9dad5050e6aaa1f661.

src/jalview/bin/Cache.java
src/jalview/io/AppletFormatAdapter.java
src/jalview/structure/StructureImportSettings.java
src/jalview/structure/StructureSelectionManager.java
test/jalview/ext/jmol/JmolParserTest.java
test/jalview/io/AnnotatedPDBFileInputTest.java
test/jalview/ws/PDBSequenceFetcherTest.java

index 0972ced..508e8a7 100755 (executable)
@@ -235,6 +235,8 @@ public class Cache
   private final static String PDB_DOWNLOAD_FORMAT = PDBEntry.Type.MMCIF
           .toString();
 
+  private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER
+          .toString();
 
   /*
    * a date formatter using a fixed (rather than the user's) locale; 
@@ -444,7 +446,9 @@ public class Cache
     StructureImportSettings.setDefaultStructureFileFormat(jalview.bin.Cache
             .getDefault(
 "PDB_DOWNLOAD_FORMAT", PDB_DOWNLOAD_FORMAT));
-
+    StructureImportSettings
+            .setDefaultPDBFileParser(jalview.bin.Cache.getDefault(
+                    "DEFAULT_PDB_FILE_PARSER", DEFAULT_PDB_FILE_PARSER));
     // jnlpVersion will be null if we're using InstallAnywhere
     // Dont do this check if running in headless mode
     if (jnlpVersion == null
index da7eb1d..55bb03d 100755 (executable)
@@ -279,12 +279,29 @@ public class AppletFormatAdapter
       }
       else if (format.equals("PDB"))
       {
-
+        // TODO obtain config value from preference settings.
+        // Set value to 'true' to test PDB processing with Jmol: JAL-1213
+        boolean isParseWithJMOL = StructureImportSettings
+                .getDefaultPDBFileParser().equalsIgnoreCase(
+                        StructureImportSettings.StructureParser.JMOL_PARSER
+                                .toString());
+        if (isParseWithJMOL)
+        {
           StructureImportSettings.addSettings(annotFromStructure,
                   localSecondaryStruct, serviceSecondaryStruct);
           alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
                   localSecondaryStruct, serviceSecondaryStruct, inFile,
                   type);
+        }
+        else
+        {
+          StructureImportSettings.addSettings(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct);
+          StructureImportSettings.setShowSeqFeatures(true);
+          alignFile = new MCview.PDBfile(annotFromStructure,
+                  localSecondaryStruct, serviceSecondaryStruct, inFile,
+                  type);
+        }
         ((StructureFile) alignFile).setDbRefType(format);
       }
       else if (format.equalsIgnoreCase("mmCIF"))
index f168413..82b5f69 100644 (file)
@@ -48,6 +48,7 @@ public class StructureImportSettings
    * Determines the parser used for parsing PDB format file. Possible options
    * are : JMolParser|JalveiwParser
    */
+  private static StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
   public static void addSettings(boolean addAlignmentAnnotations,
           boolean processSecStr, boolean externalSecStr)
   {
@@ -112,5 +113,21 @@ public class StructureImportSettings
             .valueOf(defaultStructureFileFormat.toUpperCase());
   }
 
+  public static String getDefaultPDBFileParser()
+  {
+    return defaultPDBFileParser.toString();
+  }
+
+  public static void setDefaultPDBFileParser(
+          StructureParser defaultPDBFileParser)
+  {
+    StructureImportSettings.defaultPDBFileParser = defaultPDBFileParser;
+  }
+
+  public static void setDefaultPDBFileParser(String defaultPDBFileParser)
+  {
+    StructureImportSettings.defaultPDBFileParser = StructureParser
+            .valueOf(defaultPDBFileParser.toUpperCase());
+  }
 
 }
index 7db85ff..c27289c 100644 (file)
@@ -384,8 +384,21 @@ public class StructureSelectionManager
     boolean isMapUsingSIFTs = SiftsSettings.isMapWithSifts();
     try
     {
+
+      boolean isParseWithJMOL = StructureImportSettings
+              .getDefaultPDBFileParser().equalsIgnoreCase(
+                      StructureImportSettings.StructureParser.JMOL_PARSER
+                              .toString());
+      if (isParseWithJMOL || (pdbFile != null && isCIFFile(pdbFile)))
+      {
         pdb = new jalview.ext.jmol.JmolParser(addTempFacAnnot, parseSecStr,
                 secStructServices, pdbFile, protocol);
+      }
+      else
+      {
+        pdb = new PDBfile(addTempFacAnnot, parseSecStr, secStructServices,
+                pdbFile, protocol);
+      }
 
       if (pdb.getId() != null && pdb.getId().trim().length() > 0
               && AppletFormatAdapter.FILE.equals(protocol))
index 6ed49cd..7ab058e 100644 (file)
@@ -31,6 +31,7 @@ import jalview.gui.AlignFrame;
 import jalview.io.AppletFormatAdapter;
 import jalview.io.FileLoader;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
 
 import java.util.Vector;
 
@@ -90,6 +91,8 @@ public class JmolParserTest
     Cache.applicationProperties.setProperty("ADD_SS_ANN",
             Boolean.TRUE.toString());
     StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
   }
 
   @Test(groups = { "Functional" })
index f79b7c6..e03f7a1 100644 (file)
@@ -32,6 +32,7 @@ import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
 
 import java.io.File;
 
@@ -100,11 +101,11 @@ public class AnnotatedPDBFileInputTest
       {
 
         System.out.println("CalcId: " + aa.getCalcId());
-        // if (StructureImportSettings.getDefaultPDBFileParser().equals(
-        // StructureParser.JALVIEW_PARSER))
-        // {
-        // assertTrue(MCview.PDBfile.isCalcIdForFile(aa, pdbId));
-        // }
+        if (StructureImportSettings.getDefaultPDBFileParser().equals(
+                StructureParser.JALVIEW_PARSER))
+        {
+        assertTrue(MCview.PDBfile.isCalcIdForFile(aa, pdbId));
+        }
       }
     }
   }
index b911107..c1d1144 100644 (file)
@@ -26,6 +26,7 @@ import jalview.bin.Cache;
 import jalview.datamodel.AlignmentI;
 import jalview.datamodel.SequenceI;
 import jalview.structure.StructureImportSettings;
+import jalview.structure.StructureImportSettings.StructureParser;
 import jalview.ws.seqfetcher.DbSourceProxy;
 
 import java.util.List;
@@ -87,6 +88,8 @@ public class PDBSequenceFetcherTest
     Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
             Boolean.TRUE.toString());
     StructureImportSettings.setDefaultStructureFileFormat("PDB");
+    StructureImportSettings
+            .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
 
     testRetrieveProteinSeqFromPDB();
   }