57 if(!keys().contains(
"id"))
61 return value(
"id").toMap();
67 if(!keys().contains(
"precursor"))
71 return value(
"precursor").toMap();
77 if(!keys().contains(
"psm_list"))
81 return value(
"psm_list").toArray();
85std::vector<double>::iterator
87 const QString &eval_value_key,
88 std::vector<double>::iterator itbegin,
89 std::vector<double>::const_iterator itend)
91 std::vector<double>::iterator it = itbegin;
92 if(keys().contains(
"psm_list"))
96 QCborArray new_psm_arr;
97 for(QCborValue cbor_psm : value(
"psm_list").toArray())
99 QCborMap cbor_psm_map = cbor_psm.toMap();
101 if(!cbor_psm_map.keys().contains(
"proforma"))
104 QObject::tr(
"missing proforma in psm %1").arg(cbor_psm_map.keys().size()));
106 QCborMap cbor_psm_eval_newvalues;
112 QObject::tr(
"no more values to add in psm %1").arg(cbor_psm_map.keys().size()));
114 cbor_psm_eval_newvalues.insert(eval_value_key, *it);
118 QCborMap psm_eval = cbor_psm_map.value(
"eval").toMap();
119 psm_eval.remove(eval_name);
120 psm_eval.insert(eval_name, cbor_psm_eval_newvalues);
121 cbor_psm_map.remove(QString(
"eval"));
122 cbor_psm_map.insert(QString(
"eval"), psm_eval);
124 new_psm_arr.push_back(cbor_psm_map);
128 remove(QString(
"psm_list"));
129 insert(QString(
"psm_list"), new_psm_arr);
142 if(!contains(QString(
"precursor")))
146 const QCborMap cbor_precursor(value(
"precursor").toMap());
147 if(!contains(QString(
"ms2")))
151 const QCborMap cbor_ms2(value(
"ms2").toMap());
153 if(!contains(QString(
"id")))
157 const QCborMap cbor_id(value(
"id").toMap());
159 if(!cbor_id.keys().contains(
"index"))
164 if(!cbor_ms2.keys().contains(
"spectrum"))
169 const QCborMap cbor_spectrum(cbor_ms2.value(
"spectrum").toMap());
171 if(!cbor_spectrum.keys().contains(
"mz"))
175 if(!cbor_spectrum.keys().contains(
"intensity"))
186 if(cbor_id.keys().contains(
"native_id"))
188 ms_id.
setNativeId(cbor_id.value(
"native_id").toString());
191 std::vector<DataPoint> data_point_vector;
193 for(
auto cbor_mz_value : cbor_spectrum.value(
"mz").toArray())
195 data_point_vector.push_back(
196 {cbor_mz_value.toDouble(), cbor_spectrum.value(
"intensity").toArray().at(i).toDouble()});
208 if(cbor_precursor.keys().contains(
"z"))
210 precursor_ion_data.
charge = cbor_precursor.value(
"z").toInteger();
212 if(cbor_precursor.keys().contains(
"mz"))
214 precursor_ion_data.
mz = cbor_precursor.value(
"mz").toDouble();
216 if(cbor_precursor.keys().contains(
"intensity"))
218 precursor_ion_data.
intensity = cbor_precursor.value(
"intensity").toDouble();
221 if(cbor_ms2.keys().contains(
"rt"))
223 qualified_mass_spectrum.
setRtInSeconds(cbor_ms2.value(
"rt").toDouble());
237 if(!contains(QString(
"psm_list")))
242 for(
auto it_psm : value(
"psm_list").toArray())
244 QCborMap
psm = it_psm.toMap();
245 if(!
psm.contains(QString(
"protein_list")))
248 QObject::tr(
"ERROR: no protein_list in psm, psm_list in scan"));
251 for(
auto it_protein :
psm.value(
"protein_list").toArray())
254 old_protein_map.
getByAccession(it_protein.toMap().value(
"accession").toString()));
272 struct uniquePsmResult
278 QCborArray old_psm_arr = value(
"psm_list").toArray();
279 QCborArray new_psm_arr;
283 std::vector<uniquePsmResult> all_psm_list;
284 for(
auto it_psm : old_psm_arr)
286 QCborMap psm_map = it_psm.toMap();
287 all_psm_list.push_back({psm_map.value(
"proforma").toString(), psm_map});
290 std::sort(all_psm_list.begin(), all_psm_list.end(), [](uniquePsmResult &
a, uniquePsmResult &
b) {
291 return a.proforma > b.proforma;
295 std::vector<uniquePsmResult> unique_psm_list;
297 for(
auto it = all_psm_list.begin(); it != all_psm_list.end(); it++)
299 qDebug() << it->proforma;
300 if(unique_psm_list.size() > 0)
302 if(unique_psm_list.back().proforma == it->proforma)
309 unique_psm_list.push_back(*it);
314 unique_psm_list.push_back(*it);
321 qDebug() << unique_psm_list.size();
322 for(
auto it = unique_psm_list.begin(); it != unique_psm_list.end(); it++)
324 new_psm_arr.append(it->psm);
329 remove(QString(
"psm_list"));
330 insert(QString(
"psm_list"), new_psm_arr);
void setNativeId(const QString &native_id)
void setSpectrumIndex(std::size_t index)
Class to represent a mass spectrum.
MassSpectrumSPtr makeMassSpectrumSPtr() const
MS run identity MsRunId identifies an MS run with a unique ID (XmlId) and contains eventually informa...
void setSampleName(const QString &name)
set a sample name for this MsRunId
Class representing a fully specified mass spectrum.
void appendPrecursorIonData(const PrecursorIonData &precursor_ion_data)
void setMsLevel(uint ms_level)
Set the mass spectrum level.
QualifiedMassSpectrumSPtr makeQualifiedMassSpectrumSPtr() const
void setMassSpectrumSPtr(MassSpectrumSPtr massSpectrum)
Set the MassSpectrumSPtr.
void setRtInSeconds(pappso_double rt)
Set the retention time in seconds.
QCborMap getCborScanPrecursor() const
virtual void filterAndSortPsmList()
void filterPsmListUniqueUniqueProforma()
std::vector< double >::iterator addPsmEvalVectorDouble(const QString &eval_name, const QString &eval_value_key, std::vector< double >::iterator begin, std::vector< double >::const_iterator end)
add a new eval key and double values (from a vector) to each PSM
const PsmFileScanProcess & m_PsmFileScanProcess
QCborArray getCborPsmList() const
CborScanMapBase(const PsmFileScanProcess &psm_file_scan_process)
virtual ~CborScanMapBase()
void populateProteinMapUsingOldProteinMap(const PsmProteinMap &old_protein_map, PsmProteinMap &new_protein_map) const
QCborMap getCborScanId() const
pappso::QualifiedMassSpectrumSPtr getCurrentQualifiedMassSpectrumSPtr() const
static void mergePsmProteinRefList(QCborMap &cbor_psm_destination, const QCborMap &cbor_psm_source)
Basic PSM file reader to process scan (parallelized scan processing).
store PsmProtein in a map with accession as key
const pappso::cbor::psm::PsmProtein & getByAccession(const QString &accession) const
retrieve a PsmProtein with its accession
std::pair< std::map< QString, PsmProtein >::iterator, bool > insert(const PsmProtein &psm_protein)
standard map insert of a PsmProtein (accession is the key)
tries to keep as much as possible monoisotopes, removing any possible C13 peaks and changes multichar...
std::shared_ptr< QualifiedMassSpectrum > QualifiedMassSpectrumSPtr
std::shared_ptr< const MsRunId > MsRunIdCstSPtr