X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FPdb.java;h=bb5c1659441b805e9db85eef87060b1b80091083;hb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;hp=a50ed143888938e947a845a1007f549e719acbee;hpb=5d7968c49365f35b490ca101b838c998df0df675;p=jalview.git diff --git a/src/jalview/ws/dbsources/Pdb.java b/src/jalview/ws/dbsources/Pdb.java index a50ed14..bb5c165 100644 --- a/src/jalview/ws/dbsources/Pdb.java +++ b/src/jalview/ws/dbsources/Pdb.java @@ -29,12 +29,16 @@ import jalview.datamodel.DBRefSource; import jalview.datamodel.PDBEntry; import jalview.datamodel.PDBEntry.Type; import jalview.datamodel.SequenceI; +import jalview.io.DataSourceType; +import jalview.io.FileFormat; +import jalview.io.FileFormatI; import jalview.io.FormatAdapter; import jalview.io.PDBFeatureSettings; import jalview.structure.StructureImportSettings; import jalview.util.MessageManager; import jalview.ws.ebi.EBIFetchClient; +import java.io.File; import java.util.ArrayList; import java.util.List; @@ -47,9 +51,10 @@ import com.stevesoft.pat.Regex; public class Pdb extends EbiFileRetrievedProxy { private static final String SEPARATOR = "|"; + private static final String COLON = ":"; - private static final int PDB_ID_LENGTH = 4; + private static final int PDB_ID_LENGTH = 4; public Pdb() { @@ -137,13 +142,19 @@ public class Pdb extends EbiFileRetrievedProxy stopQuery(); return null; } - String ext = StructureImportSettings.getDefaultStructureFileFormat() - .equalsIgnoreCase(Type.MMCIF.toString()) ? ".cif" : ".xml"; + + /* + * ensure that an mmCIF format structure file is saved with extension.cif, + * because the Chimera "open" command recognises this extension + */ + Type pdbFileFormat = StructureImportSettings + .getDefaultStructureFileFormat(); + String ext = pdbFileFormat.getExtension(); + String fetchFormat = pdbFileFormat.getFormat(); + EBIFetchClient ebi = new EBIFetchClient(); - file = ebi.fetchDataAsFile("pdb:" + id, - StructureImportSettings.getDefaultStructureFileFormat().toLowerCase(), - ext) - .getAbsolutePath(); + File tmpFile = ebi.fetchDataAsFile("pdb:" + id, fetchFormat, ext); + file = tmpFile.getAbsolutePath(); stopQuery(); if (file == null) { @@ -151,10 +162,11 @@ public class Pdb extends EbiFileRetrievedProxy } try { - - pdbAlignment = new FormatAdapter().readFile(file, - jalview.io.AppletFormatAdapter.FILE, - StructureImportSettings.getDefaultStructureFileFormat()); + // todo get rid of Type and use FileFormatI instead? + FileFormatI fileFormat = (pdbFileFormat == Type.PDB) ? FileFormat.PDB + : FileFormat.MMCif; + pdbAlignment = new FormatAdapter().readFile(tmpFile, + DataSourceType.FILE, fileFormat); if (pdbAlignment != null) { List toremove = new ArrayList(); @@ -170,10 +182,9 @@ public class Pdb extends EbiFileRetrievedProxy } } - if (chain == null - || (chid != null && (chid.equals(chain) - || chid.trim().equals(chain.trim()) || (chain - .trim().length() == 0 && chid.equals("_"))))) + if (chain == null || (chid != null && (chid.equals(chain) + || chid.trim().equals(chain.trim()) + || (chain.trim().length() == 0 && chid.equals("_"))))) { // FIXME seems to result in 'PDB|1QIP|1qip|A' - 1QIP is redundant. // TODO: suggest simplify naming to 1qip|A as default name defined @@ -224,8 +235,8 @@ public class Pdb extends EbiFileRetrievedProxy if (pdbAlignment == null || pdbAlignment.getHeight() < 1) { throw new Exception(MessageManager.formatMessage( - "exception.no_pdb_records_for_chain", new String[] { id, - ((chain == null) ? "' '" : chain) })); + "exception.no_pdb_records_for_chain", new String[] + { id, ((chain == null) ? "' '" : chain) })); } } catch (Exception ex) // Problem parsing PDB file @@ -269,7 +280,6 @@ public class Pdb extends EbiFileRetrievedProxy return 0; } - /** * Returns a descriptor for suitable feature display settings with *