| 937 | } |
| 938 | |
| 939 | void SpectraIDViewTab::saveIDs_() |
| 940 | { |
| 941 | // no valid peak layer attached |
| 942 | if (layer_ == nullptr || layer_->getPeakData()->empty() || layer_->type != LayerDataBase::DT_PEAK) |
| 943 | { |
| 944 | return; |
| 945 | } |
| 946 | |
| 947 | // synchronize PeptideHits with the annotations in the spectrum |
| 948 | dynamic_cast<LayerData1DPeak*>(layer_)->synchronizePeakAnnotations(); |
| 949 | |
| 950 | vector<ProteinIdentification> prot_id = (*layer_->getPeakData()).getProteinIdentifications(); |
| 951 | vector<PeptideIdentification> all_pep_ids; |
| 952 | |
| 953 | // collect PeptideIdentifications from each spectrum, while making sure each spectrum is only considered once |
| 954 | // otherwise duplicates will be stored, if more than one PeptideHit is contained in a PeptideIdentification |
| 955 | set<int> added_spectra; |
| 956 | for (int r = 0; r < table_widget_->rowCount(); ++r) |
| 957 | { |
| 958 | // get spectrum index of current table line |
| 959 | int spectrum_index = table_widget_->item(r, Clmn::SPEC_INDEX)->data(Qt::DisplayRole).toInt(); |
| 960 | |
| 961 | // skip this row, if this spectrum was already processed |
| 962 | if (added_spectra.find(spectrum_index) != added_spectra.end()) |
| 963 | { |
| 964 | continue; |
| 965 | } |
| 966 | added_spectra.insert(spectrum_index); |
| 967 | |
| 968 | // collect all PeptideIdentifications from this spectrum |
| 969 | const vector<PeptideIdentification>& pep_id = (*layer_->getPeakData())[spectrum_index].getPeptideIdentifications(); |
| 970 | copy(pep_id.begin(), pep_id.end(), back_inserter(all_pep_ids)); |
| 971 | } |
| 972 | |
| 973 | QString filename = GUIHelpers::getSaveFilename(this, "Save file", "", FileTypeList({FileTypes::IDXML, FileTypes::MZIDENTML}), true, FileTypes::IDXML); |
| 974 | if (filename.isEmpty()) |
| 975 | { |
| 976 | return; |
| 977 | } |
| 978 | if (FileHandler::getTypeByFileName(filename) == FileTypes::MZIDENTML) |
| 979 | { |
| 980 | MzIdentMLFile().store(filename, prot_id, all_pep_ids); |
| 981 | } |
| 982 | else |
| 983 | { |
| 984 | IdXMLFile().store(filename, prot_id, all_pep_ids); |
| 985 | } |
| 986 | } |
| 987 | |
| 988 | void SpectraIDViewTab::updatedSingleProteinCell_(QTableWidgetItem* /*item*/) |
| 989 | { |
nothing calls this directly
no test coverage detected