JAL-1919 JAL-2148 regularise use of jalview.datamodel.PDBEntry.Type for PDB/mmCIF file type
JAL-1919 JAL-2148 use new enum jalview.structure.StructureImportSettings.StructureParser
*/
package jalview.bin;
++import jalview.datamodel.PDBEntry;
import jalview.structure.StructureImportSettings;
import jalview.ws.dbsources.das.api.DasSourceRegistryI;
import jalview.ws.dbsources.das.datamodel.DasSourceRegistry;
private final static String DEFAULT_CACHE_THRESHOLD_IN_DAYS = "2";
private final static String DEFAULT_FAIL_SAFE_PID_THRESHOLD = "30";
--
- private final static String DEFAULT_STRUCTURE_FORMAT = StructureImportSettings.MMCIF;
+
- private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.JMOL_PARSER;
+ /**
+ * Allowed values are PDB or mmCIF
+ */
- private final static String DEFAULT_STRUCTURE_FORMAT = "PDB";
++ private final static String DEFAULT_STRUCTURE_FORMAT = PDBEntry.Type.MMCIF
++ .toString();
++
++ private final static String DEFAULT_PDB_FILE_PARSER = StructureImportSettings.StructureParser.JMOL_PARSER
++ .toString();
/**
* Initialises the Jalview Application Log
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
++import jalview.datamodel.PDBEntry.Type;
import jalview.structure.StructureImportSettings;
import jalview.util.MessageManager;
{
// 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);
++ .getDefaultPDBFileParser()
++ .equals(StructureImportSettings.StructureParser.JMOL_PARSER);
if (isParseWithJMOL)
{
StructureImportSettings.addSettings(annotFromStructure,
alignFile = new MCview.PDBfile(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct, source);
}
- ((StructureFile) alignFile)
- .setDbRefType(StructureImportSettings.PDB);
++ ((StructureFile) alignFile).setDbRefType(Type.PDB);
}
else if (format.equals("mmCIF"))
{
localSecondaryStruct, serviceSecondaryStruct);
alignFile = new jalview.ext.jmol.JmolParser(annotFromStructure,
localSecondaryStruct, serviceSecondaryStruct, source);
- ((StructureFile) alignFile)
- .setDbRefType(StructureImportSettings.MMCIF);
++ ((StructureFile) alignFile).setDbRefType(Type.MMCIF);
}
else if (format.equals("STH"))
{
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
++import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.SequenceI;
import jalview.structure.StructureImportSettings;
private String id;
-- private String dbRefType;
++ private PDBEntry.Type dbRefType;
/**
* set to true to add derived sequence annotations (temp factor read from
this.chains = chains;
}
-- public String getDbRefType()
++ public Type getDbRefType()
{
return dbRefType;
}
public void setDbRefType(String dbRefType)
{
++ this.dbRefType = Type.valueOf(dbRefType);
++ }
++
++ public void setDbRefType(Type dbRefType)
++ {
this.dbRefType = dbRefType;
}
package jalview.structure;
- import jalview.datamodel.DBRefSource;
--
++import jalview.datamodel.PDBEntry;
++import jalview.datamodel.PDBEntry.Type;
++
++/**
++ * bean holding settings for structure IO. TODO: tests for validation of values
++ *
++ * @author tcofoegbu
++ *
++ */
public class StructureImportSettings
{
/**
private static boolean processHETATMs = false;
- public static final String JMOL_PARSER = "JMolParser";
-
- public static final String JALVIEW_PARSER = "JalViewParser";
-
- public static final String MMCIF = "mmCIF";
- public enum StructureFormat
++ public enum StructureParser
+ {
- PDB, MMCIF
- };
++ JMOL_PARSER, JALVIEW_PARSER
++ }
- public static final String PDB = "PDB";
- private static StructureFormat currentDefaultFormat = StructureFormat.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;
++ private static PDBEntry.Type defaultStructureFileFormat = Type.PDB;
+
+ /**
+ * Determines the parser used for parsing PDB format file. Possible options
+ * are : JMolParser|JalveiwParser
+ */
- private static String defaultPDBFileParser = JMOL_PARSER;
++ private static StructureParser defaultPDBFileParser = StructureParser.JMOL_PARSER;
public static void addSettings(boolean addAlignmentAnnotations,
- boolean predictSecStr, boolean externalSecStr)
+ boolean processSecStr, boolean externalSecStr)
{
StructureImportSettings.visibleChainAnnotation = addAlignmentAnnotations;
- StructureImportSettings.predictSecStr = predictSecStr;
+ StructureImportSettings.processSecStr = processSecStr;
StructureImportSettings.externalSecondaryStructure = externalSecStr;
StructureImportSettings.showSeqFeatures = true;
}
StructureImportSettings.showSeqFeatures = showSeqFeatures;
}
- public static String getCurrentDefaultFormat()
+ public static String getDefaultStructureFileFormat()
{
- return defaultStructureFileFormat;
- return currentDefaultFormat.toString();
++ return defaultStructureFileFormat.toString();
}
- public static void setCurrentDefaultFormat(String currentDefaultFormat)
+ public static void setDefaultStructureFileFormat(
+ String defaultStructureFileFormat)
{
- StructureImportSettings.defaultStructureFileFormat = defaultStructureFileFormat;
- StructureImportSettings.currentDefaultFormat = StructureFormat
- .valueOf(currentDefaultFormat);
++ StructureImportSettings.defaultStructureFileFormat = PDBEntry.Type
++ .valueOf(defaultStructureFileFormat);
}
public static boolean isProcessHETATMs()
StructureImportSettings.processHETATMs = processHETATMs;
}
+ public static String getDefaultPDBFileParser()
+ {
- return defaultPDBFileParser;
++ return defaultPDBFileParser.toString();
+ }
+
- public static void setDefaultPDBFileParser(String defaultPDBFileParser)
++ public static void setDefaultPDBFileParser(
++ StructureParser defaultPDBFileParser)
+ {
+ StructureImportSettings.defaultPDBFileParser = defaultPDBFileParser;
+ }
+
++ public static void setDefaultPDBFileParser(String defaultPDBFileParser)
++ {
++ StructureImportSettings.defaultPDBFileParser = StructureParser
++ .valueOf(defaultPDBFileParser);
++ }
++
}
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
++import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.SequenceI;
import jalview.io.FormatAdapter;
import jalview.io.PDBFeatureSettings;
stopQuery();
return null;
}
- String ext = StructureImportSettings.getCurrentDefaultFormat().equals(
- StructureFormat.MMCIF) ? ".cif" : ".xml";
+ String ext = StructureImportSettings.getDefaultStructureFileFormat()
- .equalsIgnoreCase("mmcif") ? ".cif"
- : ".xml";
++ .equals(Type.MMCIF) ? ".cif" : ".xml";
EBIFetchClient ebi = new EBIFetchClient();
file = ebi.fetchDataAsFile("pdb:" + id,
- StructureImportSettings.getCurrentDefaultFormat().toLowerCase(),
+ StructureImportSettings.getDefaultStructureFileFormat().toLowerCase(),
ext)
.getAbsolutePath();
stopQuery();
import jalview.io.AppletFormatAdapter;
import jalview.io.FileLoader;
import jalview.structure.StructureImportSettings;
++import jalview.structure.StructureImportSettings.StructureParser;
import java.util.Vector;
Boolean.TRUE.toString());
Cache.applicationProperties.setProperty("ADD_SS_ANN",
Boolean.TRUE.toString());
+ StructureImportSettings.setDefaultStructureFileFormat("PDB");
+ StructureImportSettings
- .setDefaultPDBFileParser(StructureImportSettings.JALVIEW_PARSER);
++ .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
}
@Test(groups = { "Functional" })
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.structure.StructureImportSettings;
++import jalview.structure.StructureImportSettings.StructureParser;
import java.io.File;
al = af.getViewport().getAlignment();
pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
.get(0).getId();
- StructureImportSettings.setCurrentDefaultFormat("PDB");
+ StructureImportSettings.setDefaultStructureFileFormat("PDB");
+ StructureImportSettings
- .setDefaultPDBFileParser(StructureImportSettings.JALVIEW_PARSER);
++ .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
}
@Test(groups = { "Functional" })
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;
{
Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
Boolean.TRUE.toString());
- StructureImportSettings.setCurrentDefaultFormat("PDB");
+ StructureImportSettings.setDefaultStructureFileFormat("PDB");
+ StructureImportSettings
- .setDefaultPDBFileParser(StructureImportSettings.JALVIEW_PARSER);
++ .setDefaultPDBFileParser(StructureParser.JALVIEW_PARSER);
testRetrieveProteinSeqFromPDB();
}