Created
September 17, 2018 21:26
-
-
Save chasemc/92af4104ac3de61ebd51fe946ef9b354 to your computer and use it in GitHub Desktop.
This gets the sha1 [single] (SHA of entire mzXML file up the SHA1 node) and the filesha1 [maybe multiple] (the SHA of the original data files)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # requires xml2 and magrittr | |
| findmzXMLsha <- function(singlemzXMLpath){ | |
| sha <- list(sha1 = NA, filesha1 = NA) | |
| singlemzXMLpath %>% | |
| xml2::read_xml() %>% | |
| xml2::xml_ns_strip() %>% | |
| xml2::xml_find_first(., "//mzXML/sha1" ) %>% | |
| xml2::xml_text() %>% | |
| return(.) -> sha$sha1 | |
| singlemzXMLpath %>% | |
| xml2::read_xml() %>% | |
| xml2::xml_ns_strip() %>% | |
| xml2::xml_find_all(., "//mzXML/msRun/parentFile" ) %>% | |
| xml2::xml_attrs() %>% | |
| lapply(., function(x) as.character(x["fileSha1"])) %>% | |
| unlist() %>% | |
| return(.) -> sha$filesha1 | |
| sha | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment