void addBoxPlotQPs(std::map<String,String> nums, std::map<String,String> nams, String set, QcMLFile& qcmlfile) { for (std::map<String, String >::const_iterator it = nums.begin(); it != nums.end(); ++it) { QcMLFile::QualityParameter qp; qp.name = nams[it->first]; ///< Name qp.id = set + it->first; ///< Identifier qp.cvRef = "QC"; ///< cv reference qp.cvAcc = it->first; qp.value = it->second; qcmlfile.addSetQualityParameter(set, qp); } }
ExitCodes main_(int, const char**) { //------------------------------------------------------------- // parsing parameters //------------------------------------------------------------- String in = getStringOption_("in"); String out = getStringOption_("out"); String mappi = getStringOption_("mapping"); String tab = getStringOption_("table"); ControlledVocabulary cv; cv.loadFromOBO("PSI-MS", File::find("/CV/psi-ms.obo")); cv.loadFromOBO("QC", File::find("/CV/qc-cv.obo")); //------------------------------------------------------------- // reading input //------------------------------------------------------------ QcMLFile qcmlfile; if (in != "") { qcmlfile.load(in); } if (mappi != "" && tab != "") { CsvFile csv_file(tab); CsvFile map_file(mappi); if (map_file.size()<2) //assumed that first row is the header of table and second row is the according qc { cerr << "Error: You have to give a mapping of your table (first row is the header of table and second row is the according qc). Aborting!" << endl; return ILLEGAL_PARAMETERS; } StringList header,according; map_file.getRow(0, header); map_file.getRow(1, according); if (header.size() != according.size()) { cerr << "Error: You have to give a mapping of your table (first row is the header of table and second row is the according qc). Aborting!" << endl; return ILLEGAL_PARAMETERS; } //~ std::map<String,String> mapping; //~ std::transform( header.begin(), header.end(), according.begin(), std::inserter(mapping, mapping.end() ), std::make_pair<String,String> ); int runset_col = -1; for (Size i = 0; i < according.size(); ++i) { if (!cv.exists(according[i])) { try { const ControlledVocabulary::CVTerm& term = cv.getTermByName(according[i]); header[i] = term.name; according[i] = term.id; } catch (...) { cerr << "Error: You have to specify a correct cv with accession or name in col "<< String(i) <<". Aborting!" << endl; //~ cerr << "Header was: "<< header[i] << " , according value was: " << according[i] << endl; return ILLEGAL_PARAMETERS; } } else { const ControlledVocabulary::CVTerm& term = cv.getTerm(according[i]); header[i] = term.name; } if (header[i] == "raw data file") //TODO add set name as possibility! { runset_col = i; } } if (runset_col < 0) { cerr << "Error: You have to give a mapping of your table - rows to runs/sets. Aborting!" << endl; return ILLEGAL_PARAMETERS; } if (csv_file.size()>1) { StringList li; for (Size i = 1; i < csv_file.size(); ++i) { StringList li; csv_file.getRow(i, li); if (li.size() < according.size()) { cerr << "Error: You have to give a correct mapping of your table - row " << String(i+1) <<" is too short. Aborting!" << endl; return ILLEGAL_PARAMETERS; } std::vector< QcMLFile::QualityParameter > qps; String id; bool set = false; for (Size j = 0; j < li.size(); ++j) { if (j==runset_col) { if (qcmlfile.existsRun(li[j])) //TODO this only works for real run IDs { id = li[j]; } else if (qcmlfile.existsSet(li[j])) //TODO this only works for real set IDs { id = li[j]; set = true; } else { id = li[j]; qcmlfile.registerRun(id,id); //TODO warn that if this was supposed to be a set - now it is not! } } QcMLFile::QualityParameter def; def.name = header[j]; ///< Name def.id = String(UniqueIdGenerator::getUniqueId()); def.cvRef = "QC"; ///< cv reference ('full name') def.cvAcc = according[j]; def.value = li[j]; qps.push_back(def); } if (id!="") { for (std::vector<QcMLFile::QualityParameter>::const_iterator qit = qps.begin(); qit != qps.end(); ++qit) { if (!set) { qcmlfile.addRunQualityParameter(id, *qit); } else { qcmlfile.addSetQualityParameter(id, *qit); } } } } } } qcmlfile.store(out); return EXECUTION_OK; }