Skip to content

Commit

Permalink
Issue #54: mapping check script - under development
Browse files Browse the repository at this point in the history
  • Loading branch information
cycle20 committed Sep 26, 2022
1 parent ed45cc7 commit dd04759
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions R/uniprot_mapping_check.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
library(rvest)
library(xml2)
library(glue)

UNIPROT_API <- 'https://rest.uniprot.org/uniprotkb/{UniProtId}?format=xml'

checkUniProt <- function(UniProtId, geneName) {
doc <- xml2::read_xml(glue::glue(UNIPROT_API))
xml2::xml_ns_strip(doc)
nodeset <- xml2::xml_find_all(doc, xpath = '/uniprot/entry/gene/name[@type="primary"]')
firstValue <- xml2::xml_text(nodeset[1])
if (length(nodeset) > 1 || geneName != firstValue) {
print(paste0(UniProtId, " length: ", length(nodeset)))
# } else {
# print(glue::glue('{UniProtId}: {geneName} ok'))
}
}

checkUniProt('Q6P093', 'AADACL2')

0 comments on commit dd04759

Please sign in to comment.