Created
April 14, 2020 14:42
-
-
Save sneumann/0f0d22027eda4db8ab28175de06b77f2 to your computer and use it in GitHub Desktop.
This file contains 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
library(httr) | |
library(rmzTabM) | |
library(xcms) | |
library(faahKO) | |
data(faahko3) | |
faahkoMzTab <- rmzTabM::MzTab$new( | |
metadata=Metadata$new( | |
'mzTab-version' = "2.2.0-M", | |
'mzTab-ID' = "faahKO", | |
# title = "faahKO", | |
# description = "faahKO", | |
# sample_processing = "Just do it", | |
# instrument = "Some TripleQ", | |
software=list(Software$new(id=1, parameter=Parameter$new(id=1, cv_label="MS", cv_accession="MS:4711", name="xcms", value="3.1.1"), setting = "bla")), | |
assay=mapply(function(id, name) Assay$new(id=id, name=name), seq(1,nrow(pData(faahko3))), pData(faahko3)$sample_name), | |
sample=mapply(function(id, name) Sample$new(id=id, name=name), seq(1,nrow(pData(faahko3))), pData(faahko3)$sample_name), | |
ms_run=mapply(function(id, location) MsRun$new(id=id, location=location), seq(1,nrow(pData(faahko3))), processingData(faahko3)@files), | |
study_variable = mapply(function(id, level, assays) StudyVariable$new(id=id, name=level, description=level, assays=assays), | |
seq(1:length(unique(phenoData(faahko3)$sample_group))), | |
unique(phenoData(faahko3)$sample_group), | |
sapply(unique(phenoData(faahko3)$sample_group), | |
function(group) paste("assay[", which(phenoData(faahko3)$sample_group==group), "]", sep="", collapse=" | ")) | |
), | |
cv=list(CV$new(label="MS", full_name="PSI-MS controlled vocabulary", version="4.0.9", uri="https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo")) | |
) | |
) | |
cat(faahkoMzTab$toJSONString(), file="/tmp/faahko3.mzTab.json") | |
url <- ("https://apps.lifs.isas.de/mztabvalidator/rest/v2/validate?level=info&maxErrors=100&semanticValidation=true") | |
resp <- POST(url, body = faahkoMzTab$toJSONString(), content_type_json()) | |
content(resp)$message | |
## Results in: | |
# [1] "JSON parse error: Missing type id when trying to resolve | |
# subtype of [simple type, class de.isas.mztab2.model.Software]: | |
# missing type id property 'elementType' (for POJO property 'software'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What happens if you use
SoftwareAllOf$new
instead ofSoftware$new
? I think SoftwareAllOf is needed, because it is the specialization class of Software and IndexedElement.https://gist.github.com/sneumann/0f0d22027eda4db8ab28175de06b77f2#file-rmztabm-object-creation-r-L15
Same would apply to Assay -> AssayAllOf, Sample -> SampleAllOf, MsRun -> MsRunAllOf, StudyVariable -> StudyVariableAllOf, CV -> CVAllOf