X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Fdbsources%2FUniprot.java;h=7261cba4910eb80a35d3db2141afd487416919ff;hb=136c0793b90b72b928c4d77dc109dd5c644e00d3;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..7261cba 100644 --- a/src/jalview/ws/dbsources/Uniprot.java +++ b/src/jalview/ws/dbsources/Uniprot.java @@ -28,18 +28,20 @@ import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; -import jalview.datamodel.UniprotEntry; -import jalview.datamodel.UniprotFile; +import jalview.datamodel.xdb.uniprot.UniprotEntry; +import jalview.datamodel.xdb.uniprot.UniprotFeature; +import jalview.datamodel.xdb.uniprot.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 +50,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 +65,6 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy public Uniprot() { super(); - addDbSourceProperty(DBRefSource.SEQDB, DBRefSource.SEQDB); - addDbSourceProperty(DBRefSource.PROTSEQDB); } /* @@ -125,9 +127,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 +166,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) @@ -193,7 +194,8 @@ public class Uniprot extends DbSourceProxyImpl implements DbSourceProxy * UniprotEntry * @return SequenceI instance created from the UniprotEntry instance */ - public SequenceI uniprotEntryToSequenceI(UniprotEntry entry){ + public SequenceI uniprotEntryToSequenceI(UniprotEntry entry) + { String id = getUniprotEntryId(entry); SequenceI sequence = new Sequence(id, entry.getUniprotSequence() .getContent()); @@ -205,10 +207,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,18 +224,54 @@ 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("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 ("Ensembl".equals(pdb.getType())) + { + /*UniprotXML + * + * + * + * + * + */ + String cdsId = (String) pdb.getProperty("protein sequence ID"); + if (cdsId != null && cdsId.trim().length() > 0) + { + dbr = new DBRefEntry(DBRefSource.ENSEMBL, DBRefSource.UNIPROT + + ":" + dbVersion, cdsId.trim()); + dbRefs.add(dbr); + + } + } } sequence.setPDBId(onlyPdbEntries); if (entry.getFeature() != null) { - for (SequenceFeature sf : entry.getFeature()) + for (UniprotFeature uf : entry.getFeature()) { - sf.setFeatureGroup("Uniprot"); - sequence.addSequenceFeature(sf); + SequenceFeature copy = new SequenceFeature(uf.getType(), + uf.getDescription(), uf.getBegin(), uf.getEnd(), "Uniprot"); + copy.setStatus(uf.getStatus()); + sequence.addSequenceFeature(copy); } } - sequence.setDBRefs(dbRefs.toArray(new DBRefEntry[0])); + for (DBRefEntry dbr : dbRefs) + { + sequence.addDBRef(dbr); + } return sequence; } @@ -248,9 +286,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 +309,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);