X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FPdb.java;h=d945699d6b54aaed8250a3e873aaa5a4ff59f6e8;hb=0bec4854366c4bc4608ed0d7dc1506fc6afe2285;hp=836e211b232d04f6adaf7c806a84a6f7e50e2abe;hpb=06e3a52df5af8243cdb67c023c8ddd834711ad36;p=jalview.git diff --git a/src/jalview/ws/dbsources/Pdb.java b/src/jalview/ws/dbsources/Pdb.java index 836e211..d945699 100644 --- 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 @@ -20,6 +21,7 @@ */ package jalview.ws.dbsources; +import jalview.api.FeatureSettingsModelI; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.DBRefEntry; @@ -27,9 +29,10 @@ import jalview.datamodel.DBRefSource; import jalview.datamodel.PDBEntry; import jalview.datamodel.SequenceI; import jalview.io.FormatAdapter; +import jalview.io.PDBFeatureSettings; +import jalview.structure.StructureImportSettings; import jalview.util.MessageManager; import jalview.ws.ebi.EBIFetchClient; -import jalview.ws.seqfetcher.DbSourceProxy; import java.util.ArrayList; import java.util.List; @@ -41,19 +44,23 @@ import com.stevesoft.pat.Regex; * @author JimP * */ -public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy +public class Pdb extends EbiFileRetrievedProxy { public Pdb() { super(); - addDbSourceProperty(DBRefSource.PROTSEQDB); } + public static final String FEATURE_INSERTION = "INSERTION"; + + public static final String FEATURE_RES_NUM = "RESNUM"; + /* * (non-Javadoc) * * @see jalview.ws.DbSourceProxy#getAccessionSeparator() */ + @Override public String getAccessionSeparator() { // TODO Auto-generated method stub @@ -65,6 +72,7 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy * * @see jalview.ws.DbSourceProxy#getAccessionValidator() */ + @Override public Regex getAccessionValidator() { return new Regex("([1-9][0-9A-Za-z]{3}):?([ _A-Za-z0-9]?)"); @@ -75,6 +83,7 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy * * @see jalview.ws.DbSourceProxy#getDbSource() */ + @Override public String getDbSource() { return DBRefSource.PDB; @@ -85,6 +94,7 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy * * @see jalview.ws.DbSourceProxy#getDbVersion() */ + @Override public String getDbVersion() { return "0"; @@ -95,9 +105,10 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy * * @see jalview.ws.DbSourceProxy#getSequenceRecords(java.lang.String[]) */ + @Override public AlignmentI getSequenceRecords(String queries) throws Exception { - AlignmentI pdbfile = null; + AlignmentI pdbAlignment = null; Vector result = new Vector(); String chain = null; String id = null; @@ -121,8 +132,14 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy stopQuery(); return null; } + String ext = StructureImportSettings.getCurrentDefaultFormat() + .equalsIgnoreCase("mmcif") ? ".cif" + : ".xml"; EBIFetchClient ebi = new EBIFetchClient(); - file = ebi.fetchDataAsFile("pdb:" + id, "pdb", "raw").getAbsolutePath(); + file = ebi.fetchDataAsFile("pdb:" + id, + StructureImportSettings.getCurrentDefaultFormat().toLowerCase(), + ext) + .getAbsolutePath(); stopQuery(); if (file == null) { @@ -131,12 +148,13 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy try { - pdbfile = new FormatAdapter().readFile(file, - jalview.io.AppletFormatAdapter.FILE, "PDB"); - if (pdbfile != null) + pdbAlignment = new FormatAdapter().readFile(file, + jalview.io.AppletFormatAdapter.FILE, + StructureImportSettings.getCurrentDefaultFormat()); + if (pdbAlignment != null) { List toremove = new ArrayList(); - for (SequenceI pdbcs : pdbfile.getSequences()) + for (SequenceI pdbcs : pdbAlignment.getSequences()) { String chid = null; // Mapping map=null; @@ -188,20 +206,22 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy // now remove marked sequences for (SequenceI pdbcs : toremove) { - pdbfile.deleteSequence(pdbcs); - if (pdbcs.getAnnotation()!=null) + pdbAlignment.deleteSequence(pdbcs); + if (pdbcs.getAnnotation() != null) { - for (AlignmentAnnotation aa: pdbcs.getAnnotation()) + for (AlignmentAnnotation aa : pdbcs.getAnnotation()) { - pdbfile.deleteAnnotation(aa); + pdbAlignment.deleteAnnotation(aa); } } } } - if (pdbfile == null || pdbfile.getHeight() < 1) + if (pdbAlignment == null || pdbAlignment.getHeight() < 1) { - throw new Exception(MessageManager.formatMessage("exception.no_pdb_records_for_chain", new String[]{id, ((chain == null) ? "' '" : chain)})); + throw new Exception(MessageManager.formatMessage( + "exception.no_pdb_records_for_chain", new String[] { id, + ((chain == null) ? "' '" : chain) })); } } catch (Exception ex) // Problem parsing PDB file @@ -209,7 +229,7 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy stopQuery(); throw (ex); } - return pdbfile; + return pdbAlignment; } /* @@ -217,6 +237,7 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy * * @see jalview.ws.DbSourceProxy#isValidReference(java.lang.String) */ + @Override public boolean isValidReference(String accession) { Regex r = getAccessionValidator(); @@ -224,13 +245,15 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy } /** - * obtain human glyoxalase chain A sequence + * human glyoxalase */ + @Override public String getTestQuery() { - return "1QIPA"; + return "1QIP"; } + @Override public String getDbName() { return "PDB"; // getDbSource(); @@ -241,4 +264,20 @@ public class Pdb extends EbiFileRetrievedProxy implements DbSourceProxy { return 0; } + + + /** + * Returns a descriptor for suitable feature display settings with + * + */ + @Override + public FeatureSettingsModelI getFeatureColourScheme() + { + return new PDBFeatureSettings(); + } }