git://source.jalview.org
/
jalview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
JAL-2344 corrected conversion of Type enum to FileFormat
[jalview.git]
/
src
/
jalview
/
ws
/
dbsources
/
Pdb.java
diff --git
a/src/jalview/ws/dbsources/Pdb.java
b/src/jalview/ws/dbsources/Pdb.java
index
f41d86a
..
68dda88
100644
(file)
--- a/
src/jalview/ws/dbsources/Pdb.java
+++ b/
src/jalview/ws/dbsources/Pdb.java
@@
-1,3
+1,4
@@
+
/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
/*
* Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
* Copyright (C) $$Year-Rel$$ The Jalview Authors
@@
-26,15
+27,19
@@
import jalview.datamodel.AlignmentI;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.DBRefEntry;
import jalview.datamodel.DBRefSource;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.PDBEntry.Type;
import jalview.datamodel.SequenceI;
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.io.FormatAdapter;
import jalview.io.PDBFeatureSettings;
+import jalview.structure.StructureImportSettings;
import jalview.util.MessageManager;
import jalview.ws.ebi.EBIFetchClient;
import java.util.ArrayList;
import java.util.List;
import jalview.util.MessageManager;
import jalview.ws.ebi.EBIFetchClient;
import java.util.ArrayList;
import java.util.List;
-import java.util.Vector;
import com.stevesoft.pat.Regex;
import com.stevesoft.pat.Regex;
@@
-44,17
+49,17
@@
import com.stevesoft.pat.Regex;
*/
public class Pdb extends EbiFileRetrievedProxy
{
*/
public class Pdb extends EbiFileRetrievedProxy
{
+ private static final String SEPARATOR = "|";
+
+ private static final String COLON = ":";
+
+ private static final int PDB_ID_LENGTH = 4;
+
public Pdb()
{
super();
}
public Pdb()
{
super();
}
- public static final String FEATURE_INSERTION = "INSERTION";
-
- public static final String FEATURE_RES_NUM = "RESNUM";
-
- private static String currentDefaultFomart = DBRefSource.PDB;
-
/*
* (non-Javadoc)
*
/*
* (non-Javadoc)
*
@@
-63,7
+68,6
@@
public class Pdb extends EbiFileRetrievedProxy
@Override
public String getAccessionSeparator()
{
@Override
public String getAccessionSeparator()
{
- // TODO Auto-generated method stub
return null;
}
return null;
}
@@
-109,34
+113,39
@@
public class Pdb extends EbiFileRetrievedProxy
public AlignmentI getSequenceRecords(String queries) throws Exception
{
AlignmentI pdbAlignment = null;
public AlignmentI getSequenceRecords(String queries) throws Exception
{
AlignmentI pdbAlignment = null;
- Vector result = new Vector();
String chain = null;
String id = null;
String chain = null;
String id = null;
- if (queries.indexOf(":") > -1)
+ if (queries.indexOf(COLON) > -1)
{
{
- chain = queries.substring(queries.indexOf(":") + 1);
- id = queries.substring(0, queries.indexOf(":"));
+ chain = queries.substring(queries.indexOf(COLON) + 1);
+ id = queries.substring(0, queries.indexOf(COLON));
}
else
{
id = queries;
}
}
else
{
id = queries;
}
- if (queries.length() > 4 && chain == null)
+
+ /*
+ * extract chain code if it is appended to the id and we
+ * don't already have one
+ */
+ if (queries.length() > PDB_ID_LENGTH && chain == null)
{
{
- chain = queries.substring(4, 5);
- id = queries.substring(0, 4);
+ chain = queries.substring(PDB_ID_LENGTH, PDB_ID_LENGTH + 1);
+ id = queries.substring(0, PDB_ID_LENGTH);
}
}
+
if (!isValidReference(id))
{
System.err.println("Ignoring invalid pdb query: '" + id + "'");
stopQuery();
return null;
}
if (!isValidReference(id))
{
System.err.println("Ignoring invalid pdb query: '" + id + "'");
stopQuery();
return null;
}
- String ext = getCurrentDefaultFormat().equalsIgnoreCase("mmcif") ? ".cif"
- : ".xml";
+ Type pdbFileFormat = StructureImportSettings
+ .getDefaultStructureFileFormat();
+ String ext = "." + pdbFileFormat.getExtension();
EBIFetchClient ebi = new EBIFetchClient();
EBIFetchClient ebi = new EBIFetchClient();
- file = ebi.fetchDataAsFile("pdb:" + id,
- getCurrentDefaultFormat().toLowerCase(), "raw", ext)
+ file = ebi.fetchDataAsFile("pdb:" + id, pdbFileFormat.getFormat(), ext)
.getAbsolutePath();
stopQuery();
if (file == null)
.getAbsolutePath();
stopQuery();
if (file == null)
@@
-145,10
+154,12
@@
public class Pdb extends EbiFileRetrievedProxy
}
try
{
}
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
+ : FileFormat.MMCif;
pdbAlignment = new FormatAdapter().readFile(file,
pdbAlignment = new FormatAdapter().readFile(file,
- jalview.io.AppletFormatAdapter.FILE,
- getCurrentDefaultFormat());
+ DataSourceType.FILE, fileFormat);
if (pdbAlignment != null)
{
List<SequenceI> toremove = new ArrayList<SequenceI>();
if (pdbAlignment != null)
{
List<SequenceI> toremove = new ArrayList<SequenceI>();
@@
-163,16
+174,16
@@
public class Pdb extends EbiFileRetrievedProxy
chid = pid.getChainCode();
}
chid = pid.getChainCode();
}
- ;
-
}
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("_")))))
{
- pdbcs.setName(jalview.datamodel.DBRefSource.PDB + "|" + id
- + "|" + pdbcs.getName());
+ // 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());
// Might need to add more metadata to the PDBEntry object
// like below
/*
// Might need to add more metadata to the PDBEntry object
// like below
/*
@@
-243,12
+254,12
@@
public class Pdb extends EbiFileRetrievedProxy
}
/**
}
/**
- * obtain human glyoxalase chain A sequence
+ * human glyoxalase
*/
@Override
public String getTestQuery()
{
*/
@Override
public String getTestQuery()
{
- return "1QIPA";
+ return "1QIP";
}
@Override
}
@Override
@@
-263,16
+274,6
@@
public class Pdb extends EbiFileRetrievedProxy
return 0;
}
return 0;
}
- public static String getCurrentDefaultFormat()
- {
- return currentDefaultFomart;
- }
-
- public static void setCurrentDefaultFormat(String currentDefaultFomart)
- {
- Pdb.currentDefaultFomart = currentDefaultFomart;
- }
-
/**
* Returns a descriptor for suitable feature display settings with
* <ul>
/**
* Returns a descriptor for suitable feature display settings with
* <ul>