X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fdatamodel%2FPDBEntry.java;h=80e2de87aef0e4d145afa9065578479146550c55;hb=82bb8b489341891b28f178aff577b7958860b876;hp=6a6ccd0f7d1904425a7e9dc0476d4f4d088da187;hpb=37de9310bec3501cbc6381e0c3dcb282fcaad812;p=jalview.git diff --git a/src/jalview/datamodel/PDBEntry.java b/src/jalview/datamodel/PDBEntry.java index 6a6ccd0..80e2de8 100755 --- a/src/jalview/datamodel/PDBEntry.java +++ b/src/jalview/datamodel/PDBEntry.java @@ -46,7 +46,39 @@ public class PDBEntry public enum Type { - PDB, MMCIF, FILE; + // TODO is FILE needed; if not is this enum needed, or can we + // use FileFormatI for PDB, MMCIF? + PDB("pdb", "pdb"), MMCIF("mmcif", "cif"), FILE("?", "?"); + + /* + * file extension for cached structure file; must be one that + * is recognised by Chimera 'open' command + * @see https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/filetypes.html + */ + String ext; + + /* + * format specifier used in dbfetch request + * @see http://www.ebi.ac.uk/Tools/dbfetch/dbfetch/dbfetch.databases#pdb + */ + String format; + + private Type(String fmt, String ex) + { + format = fmt; + ext = ex; + } + + public String getFormat() + { + return format; + } + + public String getExtension() + { + return ext; + } + /** * case insensitive matching for Type enum * @@ -77,7 +109,6 @@ public class PDBEntry } } - /** * Answers true if obj is a PDBEntry with the same id and chain code (both * ignoring case), file, type and properties @@ -100,18 +131,11 @@ public class PDBEntry * CaseInsensitiveString, so we are in effect doing a * case-insensitive comparison of chain codes */ - boolean idMatches = id == o.id - || (id != null && id.equalsIgnoreCase(o.id)); - boolean fileMatches = file == o.file - || (file != null && file.equals(o.file)); - boolean typeMatches = type == o.type - || (type != null && type.equals(o.type)); - if (idMatches && fileMatches && typeMatches) - { - return properties == o.properties - || (properties != null && properties.equals(o.properties)); - } - return false; + return (id == o.id || (id != null && id.equalsIgnoreCase(o.id))) + && (file == o.file || (file != null && file.equals(o.file))) + && (type == o.type || (type != null && type.equals(o.type))) + && (properties == o.properties || (properties != null + && properties.equals(o.properties))); } /** @@ -121,17 +145,6 @@ public class PDBEntry { } - /** - * Constructor given file path and PDB id. - * - * @param filePath - */ - // public PDBEntry(String filePath, String pdbId) - // { - // this.file = filePath; - // this.id = pdbId; - // } - public PDBEntry(String pdbId, String chain, PDBEntry.Type type, String filePath) { @@ -144,11 +157,12 @@ public class PDBEntry * @param entryType * @param filePath */ - void init(String pdbId, String chain, PDBEntry.Type entryType, String filePath) + void init(String pdbId, String chain, PDBEntry.Type entryType, + String filePath) { this.id = pdbId; this.type = entryType == null ? null : entryType.toString(); - this.file = filePath; + this.file = (filePath == null ? null : filePath.replace('\\', '/')); setChainCode(chain); } @@ -179,8 +193,8 @@ public class PDBEntry { if (!DBRefSource.PDB.equals(dbr.getSource())) { - throw new IllegalArgumentException("Invalid source: " - + dbr.getSource()); + throw new IllegalArgumentException( + "Invalid source: " + dbr.getSource()); } String pdbId = dbr.getAccessionId(); @@ -199,7 +213,7 @@ public class PDBEntry public void setFile(String f) { - this.file = f; + this.file = f.replace('\\', '/'); } public String getFile() @@ -236,7 +250,7 @@ public class PDBEntry { if (this.properties == null) { - this.properties = new Hashtable(); + this.properties = new Hashtable<>(); } properties.put(key, value); }