| 26 | namespace OpenMS |
| 27 | { |
| 28 | void MzQCFile::store(const String& input_file, |
| 29 | const String& output_file, |
| 30 | const MSExperiment& exp, |
| 31 | const String& contact_name, |
| 32 | const String& contact_address, |
| 33 | const String& description, |
| 34 | const String& label, |
| 35 | const FeatureMap& feature_map, |
| 36 | vector<ProteinIdentification>& prot_ids, |
| 37 | vector<PeptideIdentification>& pep_ids) const |
| 38 | { |
| 39 | // -------------------------------------------------------------------- |
| 40 | // preparing output stream, quality metrics json object, CV, status |
| 41 | // and initialize QC metric classes |
| 42 | // -------------------------------------------------------------------- |
| 43 | ofstream os(output_file.c_str()); |
| 44 | if (!os) |
| 45 | { |
| 46 | throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, output_file); |
| 47 | } |
| 48 | |
| 49 | using json = nlohmann::ordered_json; |
| 50 | json quality_metrics = {}; |
| 51 | |
| 52 | ControlledVocabulary cv; |
| 53 | cv.loadFromOBO("PSI-MS", File::find("/CV/psi-ms.obo")); |
| 54 | cv.loadFromOBO("QC", File::find("/CV/qc-cv.obo")); |
| 55 | |
| 56 | QCBase::Status status; |
| 57 | if (!input_file.empty()) |
| 58 | { |
| 59 | status |= QCBase::Requires::RAWMZML; |
| 60 | } |
| 61 | if (!feature_map.empty()) |
| 62 | { |
| 63 | status |= QCBase::Requires::PREFDRFEAT; |
| 64 | } |
| 65 | if (!prot_ids.empty() && !pep_ids.empty()) |
| 66 | { |
| 67 | status |= QCBase::Requires::ID; |
| 68 | } |
| 69 | |
| 70 | TIC tic; |
| 71 | SpectrumCount spectrum_count; |
| 72 | FeatureSummary feature_summary; |
| 73 | IdentificationSummary identification_summary; |
| 74 | |
| 75 | // --------------------------------------------------------------- |
| 76 | // function to add quality metrics to quality_metrics |
| 77 | // --------------------------------------------------------------- |
| 78 | auto addMetric = [&cv, &quality_metrics](const String& accession, const auto& value) -> void |
| 79 | { |
| 80 | json qm; |
| 81 | qm["accession"] = accession; |
| 82 | if (cv.exists(accession)) |
| 83 | { |
| 84 | qm["name"] = cv.getTerm(accession).name; |
| 85 | } |
nothing calls this directly
no test coverage detected