From dde2abe99b75477853a09b4668a6b46cc14bc3ef Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 13 Sep 2016 17:07:44 +0100 Subject: [PATCH] Revert "JAL-2164 JAL-1919 disabled and removed PDB file parser configuration option, JmolParser is now the sole parser for parsing PDB and mmCIF format files." This reverts commit 13bc8a3fb89b083922d9fa9dad5050e6aaa1f661. --- src/jalview/bin/Cache.java | 6 +++++- src/jalview/io/AppletFormatAdapter.java | 19 ++++++++++++++++++- src/jalview/structure/StructureImportSettings.java | 17 +++++++++++++++++ .../structure/StructureSelectionManager.java | 13 +++++++++++++ test/jalview/ext/jmol/JmolParserTest.java | 3 +++ test/jalview/io/AnnotatedPDBFileInputTest.java | 11 ++++++----- test/jalview/ws/PDBSequenceFetcherTest.java | 3 +++ 7 files changed, 65 insertions(+), 7 deletions(-) diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index 0972ced..508e8a7 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -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 diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index da7eb1d..55bb03d 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -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")) diff --git a/src/jalview/structure/StructureImportSettings.java b/src/jalview/structure/StructureImportSettings.java index f168413..82b5f69 100644 --- a/src/jalview/structure/StructureImportSettings.java +++ b/src/jalview/structure/StructureImportSettings.java @@ -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()); + } } diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 7db85ff..c27289c 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -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)) diff --git a/test/jalview/ext/jmol/JmolParserTest.java b/test/jalview/ext/jmol/JmolParserTest.java index 6ed49cd..7ab058e 100644 --- a/test/jalview/ext/jmol/JmolParserTest.java +++ b/test/jalview/ext/jmol/JmolParserTest.java @@ -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" }) diff --git a/test/jalview/io/AnnotatedPDBFileInputTest.java b/test/jalview/io/AnnotatedPDBFileInputTest.java index f79b7c6..e03f7a1 100644 --- a/test/jalview/io/AnnotatedPDBFileInputTest.java +++ b/test/jalview/io/AnnotatedPDBFileInputTest.java @@ -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)); + } } } } diff --git a/test/jalview/ws/PDBSequenceFetcherTest.java b/test/jalview/ws/PDBSequenceFetcherTest.java index b911107..c1d1144 100644 --- a/test/jalview/ws/PDBSequenceFetcherTest.java +++ b/test/jalview/ws/PDBSequenceFetcherTest.java @@ -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(); } -- 1.7.10.2