X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FUniprot.java;h=e26ccda1bcd6baab43655172d810288295bc9c5a;hb=56bc65e4a83ab45cb98a37b60f0d547bd6ae9a71;hp=843828b16f9da51bee051434dcce48ccfb4c66ef;hpb=bb9e5fdd698bc2ccfbe37293f4d25178c407c811;p=jalview.git diff --git a/src/jalview/ws/dbsources/Uniprot.java b/src/jalview/ws/dbsources/Uniprot.java index 843828b..e26ccda 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -31,15 +31,16 @@ import jalview.datamodel.SequenceI; import jalview.datamodel.UniprotEntry; import jalview.datamodel.UniprotFile; import jalview.ws.ebi.EBIFetchClient; -import jalview.ws.seqfetcher.DbSourceProxy; import jalview.ws.seqfetcher.DbSourceProxyImpl; import java.io.File; import java.io.FileReader; import java.io.Reader; +import java.net.URL; import java.util.ArrayList; import java.util.Vector; +import org.exolab.castor.mapping.Mapping; import org.exolab.castor.xml.Unmarshaller; import com.stevesoft.pat.Regex; @@ -48,12 +49,14 @@ import com.stevesoft.pat.Regex; * @author JimP * */ -public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy +public class Uniprot extends DbSourceProxyImpl { - private static final String BAR_DELIMITER = "|"; - private static org.exolab.castor.mapping.Mapping map; + /* + * Castor mapping loaded from uniprot_mapping.xml + */ + private static Mapping map; /** * Constructor @@ -61,8 +64,6 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy public Uniprot() { super(); - addDbSourceProperty(DBRefSource.SEQDB, DBRefSource.SEQDB); - addDbSourceProperty(DBRefSource.PROTSEQDB); } /* @@ -125,9 +126,8 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy if (map == null) { // 1. Load the mapping information from the file - map = new org.exolab.castor.mapping.Mapping(uni.getClass() - .getClassLoader()); - java.net.URL url = getClass().getResource("/uniprot_mapping.xml"); + map = new Mapping(uni.getClass().getClassLoader()); + URL url = getClass().getResource("/uniprot_mapping.xml"); map.loadMapping(url); } @@ -165,7 +165,7 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy // uniprotxml parameter required since december 2007 // uniprotkb dbname changed introduced december 2008 File file = ebi.fetchDataAsFile("uniprotkb:" + queries, "uniprotxml", - null); + ".xml"); Vector entries = getUniprotEntries(new FileReader(file)); if (entries != null) @@ -205,10 +205,10 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy { DBRefEntry dbRef = new DBRefEntry(DBRefSource.UNIPROT, dbVersion, accessionId); + + // mark dbRef as a primary reference for this sequence dbRefs.add(dbRef); } - sequence.setSourceDBRef((dbRefs != null && dbRefs.size() > 0) ? dbRefs - .get(0) : null); Vector onlyPdbEntries = new Vector(); for (PDBEntry pdb : entry.getDbReference()) @@ -222,6 +222,42 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy { onlyPdbEntries.addElement(pdb); } + if ("EMBL".equals(pdb.getType())) + { + // look for a CDS reference and add it, too. + String cdsId = (String) pdb.getProperty() + .get("protein sequence ID"); + if (cdsId != null && cdsId.trim().length() > 0) + { + // remove version + String[] vrs = cdsId.split("\\."); + dbr = new DBRefEntry(DBRefSource.EMBLCDS, vrs.length > 1 ? vrs[1] + : DBRefSource.UNIPROT + ":" + dbVersion, vrs[0]); + dbRefs.add(dbr); + } + } + if (false) // "Ensembl".equals(pdb.getType())) + { + /*UniprotXML + * + * + * + * + * + */ + String cdsId = (String) pdb.getProperty() + .get("protein sequence ID"); + if (cdsId != null && cdsId.trim().length() > 0) + { + // Only add the product ID + dbRefs.remove(dbr); + dbr = new DBRefEntry(DBRefSource.ENSEMBL, DBRefSource.UNIPROT + + ":" + dbVersion, cdsId.trim()); + dbRefs.add(dbr); + + } + } + } sequence.setPDBId(onlyPdbEntries); @@ -233,7 +269,12 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy sequence.addSequenceFeature(sf); } } + // we use setDBRefs to assign refs quickly. sequence.setDBRefs(dbRefs.toArray(new DBRefEntry[0])); + // need to use ensurePrimaries to reify any refs that should become primary + // refs + DBRefUtils.ensurePrimaries(sequence); // promote any direct refs to primary + // source dbs return sequence; } @@ -248,9 +289,15 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy StringBuilder desc = new StringBuilder(32); if (entry.getProtein() != null && entry.getProtein().getName() != null) { + boolean first = true; for (String nm : entry.getProtein().getName()) { - desc.append(nm).append(" "); + if (!first) + { + desc.append(" "); + } + first = false; + desc.append(nm); } } return desc.toString(); @@ -265,7 +312,9 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy public static String getUniprotEntryId(UniprotEntry entry) { StringBuilder name = new StringBuilder(32); - name.append("UniProt/Swiss-Prot"); + // name.append("UniProt/Swiss-Prot"); + // use 'canonicalised' name for optimal id matching + name.append(DBRefSource.UNIPROT); for (String accessionId : entry.getAccession()) { name.append(BAR_DELIMITER);