42 const QJsonObject ¶meters)
47 if(parameters.value(
"fragment_tolerance_unit").toString() ==
"dalton")
50 parameters.value(
"fragment_tolerance").toDouble());
52 else if(parameters.value(
"fragment_tolerance_unit").toString() ==
"ppm")
58 QJsonObject spectrum_param = parameters.value(
"spectrum").toObject();
60 m_minimumMz = spectrum_param.value(
"minimum_mz").toDouble();
62 m_deisotope = spectrum_param.value(
"deisotope").toBool();
82 m_countScanProcessed += m_bufferScanSize;
84 monitor.
setStatus(QObject::tr(
"%1 scan processed").arg(m_countScanProcessed));
99 if(!m_decoyPrefix.isEmpty())
104 for(
auto &it_protein : m_proteinMap.getProteinMap())
106 new_decoy_protein = it_protein.second;
108 std::make_shared<Protein>(*new_decoy_protein.
protein_sp.get());
109 new_decoy_protein.
protein_sp.get()->reverse();
110 new_decoy_protein.
protein_sp.get()->setAccession(
111 m_decoyPrefix + new_decoy_protein.
protein_sp.get()->getAccession());
123 QCborMap cbor_peptidoms_parameters = QCborValue::fromJsonValue(m_specpeptidomsParameters).toMap();
125 m_cborParameterMap.insert(QString(
"peptidoms"), cbor_peptidoms_parameters);
127 mp_cborOutput->append(
"parameter_map");
128 mp_cborOutput->writeCborMap(m_cborParameterMap);
162 if(!keys().contains(
"id"))
166 if(keys().contains(
"psm_list"))
173 mp_psmSpecPeptidOms->filterMassSpectrum(
174 *(qualified_mass_spectrum.get()->getMassSpectrumSPtr().get()));
177 std::make_shared<pappso::specpeptidoms::SpOMSSpectrum>(
178 *qualified_mass_spectrum.get(),
179 mp_psmSpecPeptidOms->m_fragmentTolerance,
180 mp_psmSpecPeptidOms->getAaCode());
184 mp_psmSpecPeptidOms->m_scoreValues,
185 mp_psmSpecPeptidOms->m_fragmentTolerance,
186 mp_psmSpecPeptidOms->m_aaCode);
189 QCborArray new_psm_arr;
190 for(QCborValue cbor_psm : value(
"psm_list").toArray())
192 QCborMap old_cbor_psm_map = cbor_psm.toMap();
195 if(!old_cbor_psm_map.keys().contains(
"proforma"))
198 QObject::tr(
"missing proforma in psm %1").arg(old_cbor_psm_map.keys().size()));
201 old_cbor_psm_map.value(
"proforma").toString());
205 peptide_sp.get()->getSequence(),
206 mp_psmSpecPeptidOms->m_aaCode);
208 sequenceAlignment(
false,
211 experimental_spectrum,
212 semi_global_alignment,
215 if(!m_decoyPrefix.isEmpty())
217 QString sequence = peptide_sp.get()->getSequence();
218 std::reverse(sequence.begin(), sequence.end());
221 m_decoyPrefix + old_cbor_psm_map.value(
"proforma").toString(),
223 mp_psmSpecPeptidOms->m_aaCode);
225 sequenceAlignment(
true,
228 experimental_spectrum,
229 semi_global_alignment,
238 remove(QString(
"psm_list"));
239 insert(QString(
"psm_list"), new_psm_arr);
241 filterPsmListUniqueUniqueProforma();
250 const QCborMap &old_cbor_psm_map,
251 QCborArray &new_psm_arr,
257 std::vector<pappso::specpeptidoms::Location> locations;
258 std::vector<double> potential_mass_errors;
259 const QString &sequence = protein_ptr->
getSequence();
264 if((sequence.size() >= 8) &&
268 semi_global_alignment.
fastAlign(*experimental_spectrum.get(), protein_ptr);
272 qDebug() <<
"locations.size():" << locations.size();
273 for(
auto loc : locations)
275 QCborMap new_cbor_psm;
276 qDebug() <<
"beginning=" << loc.beginning <<
"length=" << loc.length
277 <<
"tree=" << loc.tree <<
"score=" << loc.score
278 <<
"protein=" << loc.proteinPtr->getAccession();
280 *experimental_spectrum.get(), loc.proteinPtr, loc.beginning, loc.length);
281 qDebug() <<
"Completed preciseAlign";
289 if(best_alignment.
end > (std::size_t)sequence.size())
292 "(std::size_t)sequence.size() : %1 %2")
293 .arg(best_alignment.
end)
294 .arg(sequence.size()));
297 best_alignment.
shifts.size() > 0)
300 potential_mass_errors =
302 mp_psmSpecPeptidOms->m_aaCode, best_alignment, sequence);
308 potential_mass_errors);
310 qDebug() <<
"semi_global_alignment.getBestAlignment()";
313 if(best_post_processed_alignment.
SPC > best_alignment.
SPC)
315 qDebug() <<
"Best post-processed alignment"
317 << best_post_processed_alignment.
score <<
"SPC"
318 << best_post_processed_alignment.
SPC;
319 storeAlignment(is_reverse,
323 best_post_processed_alignment);
327 qDebug() <<
"no improvement in post-processing";
328 storeAlignment(is_reverse,
338 storeAlignment(is_reverse,
345 if(!new_cbor_psm.isEmpty())
347 new_psm_arr.push_back(new_cbor_psm);
356 std::size_t max_psm = mp_psmSpecPeptidOms->m_maxInterpretationsPerSpectrum;
359 struct sortPsmResults
365 QCborArray old_psm_arr = value(
"psm_list").toArray();
366 QCborArray new_psm_arr;
370 std::vector<sortPsmResults> sort_psm_list;
371 for(
auto it_psm : old_psm_arr)
373 QCborMap psm_map = it_psm.toMap();
375 psm_map.value(
"eval").toMap().value(
"peptidoms").toMap().value(
"score").toInteger();
376 sort_psm_list.push_back({score, psm_map});
379 std::sort(sort_psm_list.begin(), sort_psm_list.end(), [](sortPsmResults &
a, sortPsmResults &
b) {
380 return a.score > b.score;
384 auto it_end = sort_psm_list.begin() + max_psm;
387 qDebug() << sort_psm_list.size();
388 for(
auto it = sort_psm_list.begin(); it != sort_psm_list.end() && it != it_end; it++)
391 new_psm_arr.append(it->psm);
396 remove(QString(
"psm_list"));
397 insert(QString(
"psm_list"), new_psm_arr);
404 const QCborMap &old_cbor_psm,
405 QCborMap &new_cbor_psm,
406 const QString &accession,
409 qDebug() << accession;
411 if(alignment.
score > 0)
447 new_cbor_psm.insert(QString(
"proforma"), peptide_key);
450 new_cbor_psm.insert(QString(
"protein_list"), old_cbor_psm.value(
"protein_list"));
456 QCborMap cbor_peptidoms;
463 cbor_peptidoms.insert(QString(
"spc"), (qint64)alignment.
SPC);
464 cbor_peptidoms.insert(QString(
"score"), alignment.
score);
469 cbor_eval.insert(QString(
"matcher"), old_cbor_psm.value(
"eval").toMap().value(
"matcher"));
473 cbor_eval.insert(QString(
"peptidoms"), cbor_peptidoms);
475 new_cbor_psm.insert(QString(
"eval"), cbor_eval);
481 QCborMap &new_cbor_psm,
482 std::size_t offset_position)
const
484 QCborArray new_protein_list;
485 for(
auto qcbor_protein : new_cbor_psm.value(
"protein_list").toArray())
489 QCborArray positions;
492 protein.insert(QString(
"accession"),
493 m_decoyPrefix + qcbor_protein.toMap().value(
"accession").toString());
494 for(
auto position : qcbor_protein.toMap().value(
"positions").toArray())
496 positions.append(position.toInteger() + (qint64)offset_position);
502 protein.insert(QString(
"accession"), qcbor_protein.toMap().value(
"accession"));
503 for(
auto position : qcbor_protein.toMap().value(
"positions").toArray())
505 positions.append(position.toInteger() + (qint64)offset_position);
509 protein.insert(QString(
"positions"), positions.toCborValue());
511 new_protein_list.append(protein);
513 new_cbor_psm.insert(QString(
"protein_list"), new_protein_list);
collection of integer code for each amino acid 0 => null 1 to 20 => amino acid sorted by there mass (...
void addAaModification(char aa_letter, AaModificationP aaModification)
add a modification on an amino acid for example carbamido on C
static AaModificationP getInstance(const QString &accession)
Trace & filter(Trace &data_points) const override
get all the datapoints and remove different isotope and add their intensity and change to charge = 1 ...
keep N datapoints form the greatest intensities to the lowest
Trace & filter(Trace &data_points) const override
Trace & filter(Trace &trace) const override
Class to represent a mass spectrum.
static PrecisionPtr getPpmInstance(pappso_double value)
get a ppm precision pointer
static PrecisionPtr getDaltonInstance(pappso_double value)
get a Dalton precision pointer
virtual void setStatus(const QString &status)=0
current status of the process
Basic PSM file reader to process scan (parallelized scan processing) and write a new resulting PSM fi...
void delayProteinMapInMemory()
virtual void proteinMapReady(pappso::UiMonitorInterface &monitor) override
virtual void processBufferScanDone(pappso::UiMonitorInterface &monitor) override
void sequenceAlignment(bool is_reverse, const QCborMap &old_cbor_psm_map, QCborArray &new_psm_arr, pappso::specpeptidoms::SpOMSSpectrumCsp &experimental_spectrum, pappso::specpeptidoms::SemiGlobalAlignment &semi_global_alignment, const pappso::specpeptidoms::SpOMSProtein *protein_ptr)
void storeAlignment(bool is_reverse, const QCborMap &old_cbor_psm, QCborMap &new_cbor_psm, const QString &accession, const pappso::specpeptidoms::Alignment &alignment)
void fixPositionStart(bool is_reverse, QCborMap &new_cbor_psm, std::size_t offset_position) const
virtual ~PsmSpecPeptidOmsScan()
virtual void filterAndSortPsmList() override
const PsmSpecPeptidOms * mp_psmSpecPeptidOms
PsmSpecPeptidOmsScan(const PsmSpecPeptidOms &psm_specpeptidoms, pappso::PrecisionPtr fragment_tolerance)
void parameterMapReady(pappso::UiMonitorInterface &monitor) override
virtual void proteinMapReady(pappso::UiMonitorInterface &monitor) override
PsmSpecPeptidOms(std::size_t buffer_scan_size, CborStreamWriter *cbor_output_p, const QJsonObject ¶meters)
const pappso::AaCode & getAaCode() const
void filterMassSpectrum(pappso::MassSpectrum &mass_spectrum) const
std::size_t m_nMostIntense
virtual ~PsmSpecPeptidOms()
pappso::PrecisionPtr m_fragmentTolerance
std::size_t m_maxInterpretationsPerSpectrum
QJsonObject m_specpeptidomsParameters
CborScanMapBase * newCborScanMap() override
virtual void processBufferScanDone(pappso::UiMonitorInterface &monitor) override
std::vector< Location > getLocations() const
Returns a vector containing the saved locations.
QString toProForma() const
QString toInterpretation() const
const Alignment & getBestAlignment() const
Returns a const ref to m_best_alignment.
void postProcessingAlign(const SpOMSSpectrum &spectrum, const SpOMSProtein *protein_ptr, std::size_t beginning, std::size_t length, const std::vector< double > &shifts)
performs the post-processing : generates corrected spectra and align them
void preciseAlign(const SpOMSSpectrum &spectrum, const SpOMSProtein *protein_ptr, const std::size_t beginning, const std::size_t length)
performs the second alignment search between a protein subsequence and a spectrum.
void fastAlign(const SpOMSSpectrum &spectrum, const SpOMSProtein *protein_ptr)
perform the first alignment search between a protein sequence and a spectrum. The member location hea...
static bool checkSequenceDiversity(const QString &sequence, std::size_t window, std::size_t minimum_aa_diversity)
check that the sequence has a minimum of amino acid checkSequenceDiversity
static std::vector< double > getPotentialMassErrors(const pappso::AaCode &aa_code, const Alignment &alignment, const QString &protein_seq)
Returns a list of the potential mass errors corresponding to the provided alignment in the provided p...
LocationSaver getLocationSaver() const
Returns a copy of m_location_saver.
const QString & getSequence() const
const QString getAccession() const
std::shared_ptr< const SpOMSSpectrum > SpOMSSpectrumCsp
std::shared_ptr< QualifiedMassSpectrum > QualifiedMassSpectrumSPtr
std::shared_ptr< const Peptide > PeptideSp
std::shared_ptr< Protein > protein_sp
double getNonAlignedMass() const
convenient function to get the remaining non explained mass shift
std::vector< double > shifts
std::size_t getPositionStart() const
get position of start on the protein sequence
PeptideModel m_peptideModel