{
EBIFetchClient ebi = new EBIFetchClient();
String query = "pdb:" + pdbentry.getId();
- pdbentry.setFile(ebi.fetchDataAsFile(query, "default", ".xml")
+ pdbentry.setFile(ebi.fetchDataAsFile(query, "default", "xml")
.getAbsolutePath());
if (pdbentry.getFile() != null)
public enum Type
{
- // TODO is FILE needed; if not is this needed or can we
+ // TODO is FILE needed; if not is this enum needed, or can we
// use FileFormatI for PDB, MMCIF?
- PDB("pdb", "xml"), MMCIF("mmcif", "mmcif"), FILE("?", "?");
+ 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)
{
reply = dbFetch.fetchDataAsFile(
emprefx.toLowerCase() + ":" + query.trim(), "display=xml",
- ".xml");
+ "xml");
} catch (Exception e)
{
stopQuery();
import jalview.util.MessageManager;
import jalview.ws.ebi.EBIFetchClient;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
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)
{
try
{
// todo get rid of Type and use FileFormatI instead?
- // todo get rid of "ext" and just use "tmp"?
- FileFormatI fileFormat = pdbFileFormat == Type.PDB ? FileFormat.PDB
+ FileFormatI fileFormat = (pdbFileFormat == Type.PDB) ? FileFormat.PDB
: FileFormat.MMCif;
pdbAlignment = new FormatAdapter().readFile(file,
DataSourceType.FILE, fileFormat);
// uniprotxml parameter required since december 2007
// uniprotkb dbname changed introduced december 2008
File file = ebi.fetchDataAsFile("uniprotkb:" + queries, "uniprotxml",
- ".xml");
+ "xml");
Vector<UniprotEntry> entries = getUniprotEntries(new FileReader(file));
if (entries != null)
* @param format
* the format wanted
* @param extension
- * for the temporary file to hold response
+ * for the temporary file to hold response (without separator)
* @return the file holding the response
* @throws OutOfMemoryError
*/
File outFile = null;
try
{
- outFile = File.createTempFile("jalview", ext);
+ outFile = File.createTempFile("jalview", "." + ext);
outFile.deleteOnExit();
fetchData(ids, format, outFile);
if (outFile.length() == 0)