MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / store

Method store

src/openms/source/FORMAT/MzTabFile.cpp:2878–2978  ·  view source on GitHub ↗

stream IDs to file

Source from the content-addressed store, hash-verified

2876 }
2877 // stream IDs to file
2878 void MzTabFile::store(
2879 const String& filename,
2880 const std::vector<ProteinIdentification>& protein_identifications,
2881 const std::vector<PeptideIdentification>& peptide_identifications,
2882 bool first_run_inference_only,
2883 bool export_empty_pep_ids,
2884 bool export_all_psms,
2885 const String& title)
2886 {
2887 if (!(FileHandler::hasValidExtension(filename, FileTypes::MZTAB) || FileHandler::hasValidExtension(filename, FileTypes::TSV)))
2888 {
2889 throw Exception::UnableToCreateFile(__FILE__, __LINE__, OPENMS_PRETTY_FUNCTION, filename, "invalid file extension, expected '"
2890 + FileTypes::typeToName(FileTypes::MZTAB) + "' or '" + FileTypes::typeToName(FileTypes::TSV) + "'");
2891 }
2892
2893 vector<const PeptideIdentification*> pep_ids_ptr;
2894 pep_ids_ptr.reserve(peptide_identifications.size());
2895 for (const PeptideIdentification& pi : peptide_identifications) { pep_ids_ptr.push_back(&pi); }
2896
2897 vector<const ProteinIdentification*> prot_ids_ptr;
2898 prot_ids_ptr.reserve(protein_identifications.size());
2899 for (const ProteinIdentification& pi : protein_identifications) { prot_ids_ptr.push_back(&pi); }
2900
2901 ofstream tab_file;
2902 tab_file.open(filename, ios::out | ios::trunc);
2903
2904 MzTab::IDMzTabStream s(
2905 prot_ids_ptr,
2906 pep_ids_ptr,
2907 filename,
2908 first_run_inference_only,
2909 export_empty_pep_ids,
2910 export_all_psms,
2911 title);
2912
2913 // generate full meta data section and write to file
2914 MzTabMetaData meta_data = s.getMetaData();
2915
2916 {
2917 StringList out;
2918 generateMzTabMetaDataSection_(meta_data, out);
2919 for (const String & line : out) { tab_file << line << "\n"; }
2920 }
2921
2922 Size n_best_search_engine_score = meta_data.protein_search_engine_score.size();
2923
2924 {
2925 MzTabProteinSectionRow row;
2926 bool first = true;
2927 size_t n_header_columns = 0;
2928 while (s.nextPRTRow(row))
2929 {
2930 if (first)
2931 { // add header
2932 tab_file << "\n" << generateMzTabProteinHeader_(
2933 row,
2934 n_best_search_engine_score,
2935 s.getProteinOptionalColumnNames(),

Callers

nothing calls this directly

Calls 15

generateMzTabSection_Function · 0.85
nextPRTRowMethod · 0.80
nextPSMRowMethod · 0.80
nextPEPRowMethod · 0.80
atMethod · 0.80

Tested by

no test coverage detected