def test_DateTime(self): try: zqc = qc.MzQcFile(version="0.1.0", creationDate=datetime.now().isoformat(), runQualities=[], setQualities=[], controlledVocabularies=[]) except Exception as error: raise AssertionError(f"An unexpected exception {error} raised.")
def test_SyntaxCheck(): cvt = qc.CvParameter(cvRef="REF", accession="TEST:123", name="testname", value=99) infi = qc.InputFile(name="file.raw", location="file:///dev/null", fileFormat=qc.CvParameter("MS", "MS:1000584", "mzML format"), fileProperties=[ qc.CvParameter(cvRef="MS", accession="MS:1000747", name="completion time", value="2017-12-08-T15:38:57Z") ]) anso = qc.AnalysisSoftware( cvRef="QC", accession="QC:9999999", name="bigwhopqc", version="1.2.3", uri="file:///dev/null") # isn't requiring a uri a bit too much? meta = qc.MetaDataParameters(inputFiles=[infi], analysisSoftware=[anso]) qm = qc.QualityMetric(cvRef="QC", accession="QC:4000053", name="RT duration", value=99) qm2 = qc.QualityMetric(cvRef="QC", accession="QC:4000061", name="Maximal MS2 frequency", value=999) qm3 = qc.QualityMetric(cvRef="QC", accession="QC:4000055", name="MS1 quantiles RT fraction", value=9) rq = qc.RunQuality(metadata=meta, qualityMetrics=[qm, qm2]) sq = qc.SetQuality(metadata=meta, qualityMetrics=[qm3]) cv = qc.ControlledVocabulary(ref="QC", name="QCvocab", uri="www.qc.ml") cv2 = qc.ControlledVocabulary(ref="REF", name="TEST", uri="www.eff.off") mzqc = qc.MzQcFile(version="0.0.11", runQualities=[rq], setQualities=[sq], controlledVocabularies=[cv, cv2]) # with open('tests/mzqc_lib_out.mzqc', 'w') as f: # f.write("{ \"mzQC\": " + qc.JsonSerialisable.ToJson(mzqc) + " }") syn_check = sy.SyntacticCheck() syn_check.validate("{ \"mzQC\": " + qc.JsonSerialisable.ToJson(mzqc) + " }")
def mzqc_assembly(rqs, sqs, out): # TODO check all the metrics to see which ontologies were used cv_qc = qc.ControlledVocabulary( ref="QC", name="Proteomics Standards Initiative Quality Control Ontology", version="0.1.0", uri= "https://github.com/HUPO-PSI/qcML-development/blob/master/cv/v0_1_0/qc-cv.obo" ) cv_ms = qc.ControlledVocabulary( ref="MS", name="Proteomics Standards Initiative Mass Spectrometry Ontology", version="4.1.7", uri="https://github.com/HUPO-PSI/psi-ms-CV/blob/master/psi-ms.obo") return qc.MzQcFile(version="0.1.0", creationDate=datetime.now().isoformat(), runQualities=rqs, setQualities=sqs, controlledVocabularies=[cv_qc, cv_ms])
anso = qc.AnalysisSoftware( cvRef="QC", accession="QC:9999999", name="bigwhopqc", version="1.2.3", uri="file:///dev/null") # isn't requiring a uri a bit too much? meta = qc.MetaDataParameters(inputFiles=[infi], analysisSoftware=[anso]) qm = qc.QualityMetric(cvRef="QC", accession="QC:4000053", name="RT duration", value=99) rq = qc.RunQuality(metadata=meta, qualityMetrics=[qm]) sq = qc.SetQuality(metadata=meta, qualityMetrics=[qm]) cv = qc.ControlledVocabulary(ref="REF", name="TEST", uri="www.eff.off") mzqc = qc.MzQcFile(version="0.0.11", runQualities=[rq], setQualities=[sq], controlledVocabularies=[cv]) class TestSerialisation: def test_ControlledVocabulary(self): assert qc.JsonSerialisable.ToJson(cv) == CV def test_CvParameter(self): assert qc.JsonSerialisable.ToJson(cvt) == CVT def test_AnalysisSoftware(self): assert qc.JsonSerialisable.ToJson(anso) == ANSO def test_InputFile(self): assert qc.JsonSerialisable.ToJson(infi) == INFI