From: tcofoegbu Date: Tue, 19 Jul 2016 11:49:35 +0000 (+0100) Subject: JAL-1919 set default structure file format to mmCIF, refactored some StructureImportS... X-Git-Tag: Release_2_10_0~139 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=0555b298d22be533a0a67a3cd0ce2db883bae8bd;p=jalview.git JAL-1919 set default structure file format to mmCIF, refactored some StructureImportSetting variables, removed mmCIF from DBRefSource, updated tests --- diff --git a/src/jalview/bin/Cache.java b/src/jalview/bin/Cache.java index cf251dc..23277a4 100755 --- a/src/jalview/bin/Cache.java +++ b/src/jalview/bin/Cache.java @@ -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 diff --git a/src/jalview/datamodel/DBRefSource.java b/src/jalview/datamodel/DBRefSource.java index cf15ff8..fba9211 100755 --- a/src/jalview/datamodel/DBRefSource.java +++ b/src/jalview/datamodel/DBRefSource.java @@ -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"; diff --git a/src/jalview/ext/jmol/JmolParser.java b/src/jalview/ext/jmol/JmolParser.java index a791558..ea347ae 100644 --- a/src/jalview/ext/jmol/JmolParser.java +++ b/src/jalview/ext/jmol/JmolParser.java @@ -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()); Viewer jmolModel = getJmolData(); jmolModel.openReader(getDataName(), getDataName(), getReader()); diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index fb414f4..fca7263 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -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")) { diff --git a/src/jalview/structure/StructureImportSettings.java b/src/jalview/structure/StructureImportSettings.java index b23fd53..4c06e0f 100644 --- a/src/jalview/structure/StructureImportSettings.java +++ b/src/jalview/structure/StructureImportSettings.java @@ -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; + } + } diff --git a/src/jalview/ws/dbsources/Pdb.java b/src/jalview/ws/dbsources/Pdb.java index d945699..1a58466 100644 --- a/src/jalview/ws/dbsources/Pdb.java +++ b/src/jalview/ws/dbsources/Pdb.java @@ -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 toremove = new ArrayList(); diff --git a/test/jalview/ext/jmol/JmolParserTest.java b/test/jalview/ext/jmol/JmolParserTest.java index 0627a4a..0010321 100644 --- a/test/jalview/ext/jmol/JmolParserTest.java +++ b/test/jalview/ext/jmol/JmolParserTest.java @@ -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" }) diff --git a/test/jalview/io/AnnotatedPDBFileInputTest.java b/test/jalview/io/AnnotatedPDBFileInputTest.java index 3524a88..5368d41 100644 --- a/test/jalview/io/AnnotatedPDBFileInputTest.java +++ b/test/jalview/io/AnnotatedPDBFileInputTest.java @@ -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" }) diff --git a/test/jalview/ws/PDBSequenceFetcherTest.java b/test/jalview/ws/PDBSequenceFetcherTest.java index 0c810a3..d082785 100644 --- a/test/jalview/ws/PDBSequenceFetcherTest.java +++ b/test/jalview/ws/PDBSequenceFetcherTest.java @@ -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(); }