public void BuildMzqcAndWrite(string path, Run run, Dictionary <string, dynamic> qcParams, string inputFileInclPath) { List <JsonClasses.QualityParameters> qualityParameters = new List <JsonClasses.QualityParameters>(); foreach (var metric in qcParams) { var matchingMetric = QualityParameterLookup.SingleOrDefault(x => x.accession == metric.Key); if (matchingMetric != null) { matchingMetric.value = metric.Value; qualityParameters.Add(matchingMetric); } else { Logger.Warn("Term \"{0}\" was not found in the MZQC definition when attempting to write output. This term was ignored.", metric.Key); } } //Now for the other stuff JsonClasses.FileFormat fileFormat = new JsonClasses.FileFormat() { }; List <JsonClasses.FileProperties> fileProperties = new List <JsonClasses.FileProperties>() { }; JsonClasses.FileProperties fileProperty = new JsonClasses.FileProperties("MS", run.FilePropertiesAccession, "SHA-1", run.SourceFileChecksums.First()); JsonClasses.FileProperties completionTime = new JsonClasses.FileProperties("MS", "MS:1000747", "completion time", run.CompletionTime); fileProperties.Add(fileProperty); List <JsonClasses.InputFiles> inputFiles = new List <JsonClasses.InputFiles>(); JsonClasses.InputFiles inputFile = new JsonClasses.InputFiles("file://" + inputFileInclPath, run.SourceFileNames.First(), fileFormat, fileProperties); inputFiles.Add(inputFile); List <JsonClasses.AnalysisSoftware> analysisSoftwarelist = new List <JsonClasses.AnalysisSoftware>(); JsonClasses.AnalysisSoftware analysisSoftware = new JsonClasses.AnalysisSoftware() { cvRef = "MS", accession = "XXXXXXXXXXXXXX", name = "SwaMe", uri = "https://github.com/PaulBrack/Yamato/tree/master/Console", version = "1.0" }; analysisSoftwarelist.Add(analysisSoftware); JsonClasses.MetaData metadata = new JsonClasses.MetaData() { inputFiles = inputFiles, analysisSoftware = analysisSoftwarelist }; JsonClasses.RunQuality runQualitySingle = new JsonClasses.RunQuality() { metadata = metadata, qualityParameters = qualityParameters.ToArray() }; List <JsonClasses.RunQuality> runQuality = new List <JsonClasses.RunQuality>(); runQuality.Add(runQualitySingle); JsonClasses.NUV qualityControl = new JsonClasses.NUV() { name = "Proteomics Standards Initiative Quality Control Ontology", uri = "https://raw.githubusercontent.com/HUPO-PSI/mzqc/master/cv/v0_0_11/qc-cv.obo", version = "0.1.0" }; JsonClasses.NUV massSpectrometry = new JsonClasses.NUV() { name = "Proteomics Standards Initiative Mass Spectrometry Ontology", uri = "https://raw.githubusercontent.com/HUPO-PSI/psi-ms-CV/master/psi-ms.obo", version = "4.1.7" }; JsonClasses.NUV UnitOntology = new JsonClasses.NUV() { name = "Unit Ontology", uri = "https://raw.githubusercontent.com/bio-ontology-research-group/unit-ontology/master/unit.obo", version = "09:04:2014 13:37" }; JsonClasses.CV cV = new JsonClasses.CV() { QC = qualityControl, MS = massSpectrometry, UO = UnitOntology }; JsonClasses.MzQC metrics = new JsonClasses.MzQC() { runQuality = runQuality, cv = cV }; //Then save: WriteMzqc(path, metrics); }
/// <param name="outputFileName">The path to the output file to be opened, or null to send to stdout</param> public void BuildMzqcAndWrite(string outputFileName, Run <Scan> run, Dictionary <string, dynamic> qcParams, string inputFileInclPath, object analysisSettings) { List <JsonClasses.QualityParameters> qualityParameters = new List <JsonClasses.QualityParameters>(); foreach (var metric in qcParams) { // Note that this code smashes a value into the given QualityParameters; this will fail if the same one is used more than once, or the initialisation of those parameters is made static. if (QualityParametersByAccession.TryGetValue(metric.Key, out var matchingMetric)) { matchingMetric.value = metric.Value; qualityParameters.Add(matchingMetric); } else { Logger.Warn("Term \"{0}\" was not found in the MZQC definition when attempting to write output. This term was ignored.", metric.Key); } } //Now for the other stuff JsonClasses.InputFiles inputFile = new JsonClasses.InputFiles( "file://" + inputFileInclPath, run.SourceFileNames.First(), ToFileFormat(ms, "MS:1000584"), new List <JsonClasses.FileProperties>() { // ToFileProperties("MS", "MS:1000747", run.CompletionTime), // TODO: Include this? ToFileProperties(ms, run.FilePropertiesAccession, run.SourceFileChecksums.First()) } ); Term swaMe = ms.GetById("XXXXXXXXXXXXXX"); JsonClasses.AnalysisSoftware analysisSoftware = new JsonClasses.AnalysisSoftware() { cvRef = ms.PrimaryNamespace, accession = swaMe.Id, name = swaMe.Name, uri = "https://github.com/PaulBrack/Yamato/tree/master/Console", version = typeof(MzqcWriter).Assembly.GetName().Version.ToString(), analysisSettings = analysisSettings }; JsonClasses.MzQC metrics = new JsonClasses.MzQC() { version = "0.0.11", runQuality = new List <JsonClasses.RunQuality> { new JsonClasses.RunQuality() { metadata = new JsonClasses.MetaData() { inputFiles = new List <JsonClasses.InputFiles>() { inputFile }, analysisSoftware = new List <JsonClasses.AnalysisSoftware>() { analysisSoftware } }, qualityParameters = qualityParameters.ToArray() } }, cv = cvLibrary.ControlledVocabularies.ToDictionary(cv => cv.PrimaryNamespace, ToNUV) }; //Then save: WriteMzqc(outputFileName, metrics); }