|
24 | 24 | */ |
25 | 25 | package org.biojava.nbio.core.sequence.loader; |
26 | 26 |
|
| 27 | +import java.io.BufferedReader; |
| 28 | +import java.io.ByteArrayInputStream; |
| 29 | +import java.io.File; |
| 30 | +import java.io.FileNotFoundException; |
| 31 | +import java.io.FileReader; |
| 32 | +import java.io.FileWriter; |
| 33 | +import java.io.IOException; |
| 34 | +import java.io.InputStreamReader; |
| 35 | +import java.net.HttpURLConnection; |
| 36 | +import java.net.URL; |
| 37 | +import java.rmi.RemoteException; |
| 38 | +import java.util.ArrayList; |
| 39 | +import java.util.Iterator; |
| 40 | +import java.util.LinkedHashMap; |
| 41 | +import java.util.List; |
| 42 | +import java.util.regex.Pattern; |
| 43 | + |
| 44 | +import javax.xml.parsers.ParserConfigurationException; |
| 45 | +import javax.xml.xpath.XPathExpressionException; |
| 46 | + |
27 | 47 | import org.biojava.nbio.core.exceptions.CompoundNotFoundException; |
28 | 48 | import org.biojava.nbio.core.sequence.AccessionID; |
29 | 49 | import org.biojava.nbio.core.sequence.DataSource; |
|
35 | 55 | import org.biojava.nbio.core.sequence.features.DatabaseReferenceInterface; |
36 | 56 | import org.biojava.nbio.core.sequence.features.FeaturesKeyWordInterface; |
37 | 57 | import org.biojava.nbio.core.sequence.storage.SequenceAsStringHelper; |
38 | | -import org.biojava.nbio.core.sequence.template.*; |
| 58 | +import org.biojava.nbio.core.sequence.template.Compound; |
| 59 | +import org.biojava.nbio.core.sequence.template.CompoundSet; |
| 60 | +import org.biojava.nbio.core.sequence.template.ProxySequenceReader; |
| 61 | +import org.biojava.nbio.core.sequence.template.SequenceMixin; |
| 62 | +import org.biojava.nbio.core.sequence.template.SequenceProxyView; |
| 63 | +import org.biojava.nbio.core.sequence.template.SequenceView; |
39 | 64 | import org.biojava.nbio.core.util.XMLHelper; |
40 | 65 | import org.slf4j.Logger; |
41 | 66 | import org.slf4j.LoggerFactory; |
42 | 67 | import org.w3c.dom.Document; |
43 | 68 | import org.w3c.dom.Element; |
44 | 69 | import org.xml.sax.SAXException; |
45 | 70 |
|
46 | | -import javax.xml.parsers.ParserConfigurationException; |
47 | | -import javax.xml.xpath.XPathExpressionException; |
48 | | -import java.io.*; |
49 | | -import java.net.HttpURLConnection; |
50 | | -import java.net.URL; |
51 | | -import java.rmi.RemoteException; |
52 | | -import java.util.ArrayList; |
53 | | -import java.util.Iterator; |
54 | | -import java.util.LinkedHashMap; |
55 | | -import java.util.List; |
56 | | -import java.util.regex.Pattern; |
57 | | - |
58 | 71 | /** |
59 | 72 | * |
60 | 73 | * Pass in a Uniprot ID and this ProxySequenceReader when passed to a ProteinSequence will get the sequence data and other data elements |
@@ -321,6 +334,28 @@ public ArrayList<AccessionID> getAccessions() throws XPathExpressionException { |
321 | 334 |
|
322 | 335 | return accessionList; |
323 | 336 | } |
| 337 | + |
| 338 | + /** |
| 339 | + * Pull uniprot protein aliases associated with this sequence |
| 340 | + * @return |
| 341 | + * @throws XPathExpressionException |
| 342 | + */ |
| 343 | + public ArrayList<String> getAliases() throws XPathExpressionException { |
| 344 | + ArrayList<String> aliasList = new ArrayList<String>(); |
| 345 | + if (uniprotDoc == null) { |
| 346 | + return aliasList; |
| 347 | + } |
| 348 | + Element uniprotElement = uniprotDoc.getDocumentElement(); |
| 349 | + Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); |
| 350 | + Element proteinElement = XMLHelper.selectSingleElement(entryElement, "protein"); |
| 351 | + ArrayList<Element> keyWordElementList = XMLHelper.selectElements(proteinElement, "alternativeName"); |
| 352 | + for (Element element : keyWordElementList) { |
| 353 | + Element fullNameElement = XMLHelper.selectSingleElement(element, "fullName"); |
| 354 | + aliasList.add(fullNameElement.getTextContent()); |
| 355 | + } |
| 356 | + |
| 357 | + return aliasList; |
| 358 | + } |
324 | 359 |
|
325 | 360 | /** |
326 | 361 | * |
|
0 commit comments