Mercurial > repos > prog > lcmsmatching
comparison ChemspiderCompound.R @ 1:253d531a0193 draft
planemo upload for repository https://github.com/workflow4metabolomics/lcmsmatching.git commit 36c9d8099c20a1ae848f1337c16564335dd8fb2b
| author | prog |
|---|---|
| date | Sat, 03 Sep 2016 17:02:01 -0400 |
| parents | e66bb061af06 |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e66bb061af06 | 1:253d531a0193 |
|---|---|
| 38 | 38 |
| 39 # Get accession | 39 # Get accession |
| 40 accession <- xpathSApply(xml, "//li[starts-with(., 'ChemSpider ID')]", xmlValue) | 40 accession <- xpathSApply(xml, "//li[starts-with(., 'ChemSpider ID')]", xmlValue) |
| 41 if (length(accession) > 0) { | 41 if (length(accession) > 0) { |
| 42 accession <- sub('^ChemSpider ID([0-9]+)$', '\\1', accession, perl = TRUE) | 42 accession <- sub('^ChemSpider ID([0-9]+)$', '\\1', accession, perl = TRUE) |
| 43 compound$setField(RBIODB.ACCESSION, accession) | 43 compound$setField(BIODB.ACCESSION, accession) |
| 44 } | 44 } |
| 45 | 45 |
| 46 compounds <- c(compounds, compound) | 46 compounds <- c(compounds, compound) |
| 47 } | 47 } |
| 48 | 48 |
| 49 # Replace elements with no accession id by NULL | 49 # Replace elements with no accession id by NULL |
| 50 compounds <- lapply(compounds, function(x) if (is.na(x$getField(RBIODB.ACCESSION))) NULL else x) | 50 compounds <- lapply(compounds, function(x) if (is.na(x$getField(BIODB.ACCESSION))) NULL else x) |
| 51 | 51 |
| 52 # If the input was a single element, then output a single object | 52 # If the input was a single element, then output a single object |
| 53 if (drop && length(contents) == 1) | 53 if (drop && length(contents) == 1) |
| 54 compounds <- compounds[[1]] | 54 compounds <- compounds[[1]] |
| 55 | 55 |
