/** * @param uniprotDoc * @return * @throws Exception */ private String getSequence(Document uniprotDoc) throws Exception { Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); Element sequenceElement = XMLHelper.selectSingleElement(entryElement, "sequence"); String seqdata = sequenceElement.getTextContent(); return seqdata; }
/** @return */ public AccessionID getAccession() { AccessionID accessionID = new AccessionID(); if (uniprotDoc == null) { return accessionID; } try { Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); Element nameElement = XMLHelper.selectSingleElement(entryElement, "name"); accessionID = new AccessionID(nameElement.getTextContent(), DataSource.UNIPROT); } catch (Exception e) { logger.error("Exeception: ", e); } return accessionID; }
/** * The Uniprot mappings to other database identifiers for this sequence * * @return * @throws Exception */ public LinkedHashMap<String, ArrayList<DBReferenceInfo>> getDatabaseReferences() throws Exception { LinkedHashMap<String, ArrayList<DBReferenceInfo>> databaseReferencesHashMap = new LinkedHashMap<String, ArrayList<DBReferenceInfo>>(); if (uniprotDoc == null) { return databaseReferencesHashMap; } Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); ArrayList<Element> dbreferenceElementList = XMLHelper.selectElements(entryElement, "dbReference"); for (Element element : dbreferenceElementList) { String type = element.getAttribute("type"); String id = element.getAttribute("id"); ArrayList<DBReferenceInfo> idlist = databaseReferencesHashMap.get(type); if (idlist == null) { idlist = new ArrayList<DBReferenceInfo>(); databaseReferencesHashMap.put(type, idlist); } DBReferenceInfo dbreferenceInfo = new DBReferenceInfo(type, id); ArrayList<Element> propertyElementList = XMLHelper.selectElements(element, "property"); for (Element propertyElement : propertyElementList) { String propertyType = propertyElement.getAttribute("type"); String propertyValue = propertyElement.getAttribute("value"); dbreferenceInfo.addProperty(propertyType, propertyValue); } idlist.add(dbreferenceInfo); } return databaseReferencesHashMap; }
/** * Get the organism name assigned to this sequence * * @return * @throws Exception */ public String getOrganismName() throws Exception { if (uniprotDoc == null) { return ""; } Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); Element organismElement = XMLHelper.selectSingleElement(entryElement, "organism"); if (organismElement == null) { return ""; } Element nameElement = XMLHelper.selectSingleElement(organismElement, "name"); if (nameElement == null) { return ""; } return nameElement.getTextContent(); }
/** * Pull uniprot key words which is a mixed bag of words associated with this sequence * * @return * @throws Exception */ public ArrayList<String> getKeyWords() throws Exception { ArrayList<String> keyWordsList = new ArrayList<String>(); if (uniprotDoc == null) { return keyWordsList; } Element uniprotElement = uniprotDoc.getDocumentElement(); Element entryElement = XMLHelper.selectSingleElement(uniprotElement, "entry"); ArrayList<Element> keyWordElementList = XMLHelper.selectElements(entryElement, "keyword"); for (Element element : keyWordElementList) { keyWordsList.add(element.getTextContent()); } return keyWordsList; }