X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fjalview%2Fws%2Fdbsources%2FPdb.java;h=a658089a47fa6deed99befd0aa37edbdcbadf493;hb=81ca65d00bdb8a49fa063272ce53fdc8758c2264;hp=0aae38f7b69aedd5d7fd7aa7f099537f14ddc204;hpb=7d67fb613ec026dc9a265e351e7fab542e3f1d61;p=jalview.git diff --git a/src/jalview/ws/dbsources/Pdb.java b/src/jalview/ws/dbsources/Pdb.java index 0aae38f..a658089 100644 --- a/src/jalview/ws/dbsources/Pdb.java +++ b/src/jalview/ws/dbsources/Pdb.java @@ -38,9 +38,9 @@ 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; -import java.util.Vector; import com.stevesoft.pat.Regex; @@ -142,12 +142,19 @@ public class Pdb extends EbiFileRetrievedProxy stopQuery(); return null; } + + /* + * 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 ext = pdbFileFormat.getExtension(); + String fetchFormat = pdbFileFormat.getFormat(); + EBIFetchClient ebi = new EBIFetchClient(); - file = ebi.fetchDataAsFile("pdb:" + id, pdbFileFormat.getFormat(), ext) - .getAbsolutePath(); + File tmpFile = ebi.fetchDataAsFile("pdb:" + id, fetchFormat, ext); + file = tmpFile.getAbsolutePath(); stopQuery(); if (file == null) { @@ -155,11 +162,11 @@ public class Pdb extends EbiFileRetrievedProxy } try { - // convert Type.PDB/MMCIF to FileFormat.PDB/MMCIF - // todo get rid of Type? - FileFormatI fileFormat = FileFormat.valueOf(pdbFileFormat.toString()); - pdbAlignment = new FormatAdapter().readFile(file, - DataSourceType.FILE, fileFormat); + // 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(); @@ -175,15 +182,14 @@ 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 - pdbcs.setName(jalview.datamodel.DBRefSource.PDB + SEPARATOR - + id + SEPARATOR + pdbcs.getName()); + pdbcs.setName(jalview.datamodel.DBRefSource.PDB + SEPARATOR + id + + SEPARATOR + pdbcs.getName()); // Might need to add more metadata to the PDBEntry object // like below /* @@ -229,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