Skip to content
Snippets Groups Projects
Commit 58f57e45 authored by Langella Olivier's avatar Langella Olivier
Browse files

WIP: refactoring using PeptideEvidence

parent 7773df8a
No related branches found
No related tags found
No related merge requests found
......@@ -47,7 +47,6 @@ PeptideEvidence::PeptideEvidence(const PeptideEvidence & other): PeptideEvidence
_rt = other._rt;
_evalue = other._evalue;
_exp_mass = other._exp_mass;
_start=other._start;
_charge= other._charge;
_p_identification_source = other._p_identification_source;
_params = other._params;
......@@ -115,29 +114,9 @@ pappso::pappso_double PeptideEvidence::getExperimentalMz() const {
void PeptideEvidence::setExperimentalMass(pappso::pappso_double exp_mass) {
_exp_mass =exp_mass;
}
void PeptideEvidence::setStart(unsigned int start) {
_start =start;
}
pappso::mz PeptideEvidence::getDeltaMass() const {
return (_peptide_sp.get()->getMz(1) - (_exp_mass+pappso::MHPLUS));
}
unsigned int PeptideEvidence::getStart() const {
return _start;
}
unsigned int PeptideEvidence::getStop() const {
return _start+_peptide_sp.get()->size();
}
bool PeptideEvidence::containsPosition(unsigned int position) const {
if (position < _start) {
return false;
}
if (position < getStop()) {
return true;
}
return false;
}
void PeptideEvidence::setCharge(unsigned int charge) {
_charge =charge;
}
......
......@@ -85,14 +85,6 @@ public :
const std::map<PeptideMatchParam, QVariant> & getParamList() const;
/** @brief set start position of this peptide inside the protein sequence
* @param start position in the protein amino acid sequence (starts at 0)
* */
void setStart(unsigned int start);
/** @brief get start position of this peptide inside the protein sequence
* @return start position in the protein amino acid sequence (starts at 0)
* */
unsigned int getStart() const;
/** @brief get stop position of this peptide inside the protein sequence
* @return stop position in the protein amino acid sequence (starts at 0)
* */
......@@ -143,7 +135,6 @@ private :
pappso::pappso_double _rt;
pappso::pappso_double _evalue=0;
pappso::pappso_double _exp_mass;
unsigned int _start=0;
unsigned int _charge;
IdentificationDataSource* _p_identification_source = nullptr;
std::map<PeptideMatchParam, QVariant> _params;
......
......@@ -58,6 +58,12 @@ unsigned int PeptideMatch::getStop() const {
return _start+_p_peptide_evidence->getPeptideXtpSp().get()->size();
}
bool PeptideMatch::operator<(const PeptideMatch& r) const
{
return std::tie(_start, _p_peptide_evidence)
< std::tie(r._start, r._p_peptide_evidence); // keep the same order
}
bool PeptideMatch::containsPosition(unsigned int position) const {
if (position < _start) {
return false;
......
......@@ -56,6 +56,9 @@ public :
void setPeptideEvidenceSp(PeptideEvidenceSp sp_peptide_evidence);
const PeptideEvidence * getPeptideEvidence() const;
PeptideEvidence * getPeptideEvidence();
bool operator<(const PeptideMatch& r) const;
private :
unsigned int _start=0;
......
......@@ -354,7 +354,7 @@ const QString ProteinMatch::getHtmlSequence(PeptideEvidence * peptide_evidence_t
for (auto & peptide_match : _peptide_match_list) {
if (peptide_match.getPeptideEvidence()->isValidAndChecked()) {
size_t size = peptide_match.getPeptideEvidence()->getPeptideXtpSp().get()->size();
size_t offset = peptide_match.getPeptideEvidence()->getStart();
size_t offset = peptide_match.getStart();
if (offset >= 0) {
for (size_t i=0; (i < size) && (offset < prot_size) ; i++,offset++) {
cover_bool[offset] = true;
......
......@@ -105,9 +105,9 @@ std::vector<std::size_t> PtmIsland::getSampleScanSet() const {
sample_scan_set.erase(std::unique(sample_scan_set.begin(), sample_scan_set.end()), sample_scan_set.end());
return sample_scan_set;
}
bool PtmIsland::containsPeptideMatch(const PeptideMatch* peptide_match) const {
bool PtmIsland::containsPeptideMatch(const PeptideMatch & peptide_match) const {
return std::any_of(_peptide_match_list.begin(), _peptide_match_list.end(), [peptide_match](const PeptideMatch* element) {
return std::any_of(_peptide_match_list.begin(), _peptide_match_list.end(), [peptide_match](const PeptideMatch & element) {
return ( peptide_match == element);
});
}
......@@ -138,7 +138,7 @@ unsigned int PtmIsland::getProteinStartPosition() const {
}
bool PtmIsland::merge(PtmIslandSp ptm_island_sp) {
if (std::none_of(_peptide_match_list.begin(), _peptide_match_list.end(), [ptm_island_sp](const PeptideMatch* element) {
if (std::none_of(_peptide_match_list.begin(), _peptide_match_list.end(), [ptm_island_sp](const PeptideMatch & element) {
return ptm_island_sp.get()->containsPeptideMatch(element);
})) {
return false;
......@@ -146,7 +146,10 @@ bool PtmIsland::merge(PtmIslandSp ptm_island_sp) {
else {
//so we merge
_peptide_match_list.insert(_peptide_match_list.begin(),ptm_island_sp.get()->_peptide_match_list.begin(),ptm_island_sp.get()->_peptide_match_list.end());
std::sort(_peptide_match_list.begin(), _peptide_match_list.end());
std::sort(_peptide_match_list.begin(), _peptide_match_list.end(), [](const PeptideMatch & a, const PeptideMatch & b)
{
return (a.operator<(b));
});
auto last = std::unique(_peptide_match_list.begin(), _peptide_match_list.end());
_peptide_match_list.erase(last, _peptide_match_list.end());
......
......@@ -56,7 +56,7 @@ public:
* */
bool merge(PtmIslandSp ptm_island_sp);
bool containsPeptideMatch(const PeptideMatch* element) const;
bool containsPeptideMatch(const PeptideMatch & element) const;
std::vector<std::size_t> getSampleScanSet() const;
const ProteinMatch * getProteinMatch() const;
unsigned int getProteinStartPosition() const;
......
......@@ -261,7 +261,7 @@ bool XpipSaxHandler::startElement_peptide(QXmlAttributes attributes) {
_p_peptide_evidence->setEvalue(attributes.value("evalue").simplified().toDouble());
pappso::pappso_double exp_mass = attributes.value("mhplus_obser").simplified().toDouble() - pappso::MHPLUS;
_p_peptide_evidence->setExperimentalMass(exp_mass);
_p_peptide_evidence->setStart(attributes.value("start").simplified().toUInt()-1);
_current_peptide_match.setStart(attributes.value("start").simplified().toUInt()-1);
_p_peptide_evidence->setCharge(attributes.value("charge").simplified().toUInt());
_p_peptide_evidence->setParam(PeptideMatchParam::tandem_hyperscore, QVariant( attributes.value("hypercorr").toDouble()));
......@@ -297,9 +297,10 @@ bool XpipSaxHandler::endElement_peptide() {
qDebug() << "endElement_peptide ";
PeptideXtpSp peptide_const = PeptideXtp(*(_current_peptide_sp.get())).makePeptideXtpSp();
peptide_const = _p_project->getPeptideStore().getInstance(peptide_const);
_p_peptide_match->setPeptideXtpSp(peptide_const);
_p_protein_match->addPeptideMatchSp(_p_peptide_match->getIdentificationDataSource()->getPeptideMatchStore().getInstance(_p_peptide_match));
delete _p_peptide_match;
_p_peptide_evidence->setPeptideXtpSp(peptide_const);
_current_peptide_match.setPeptideEvidenceSp(_p_peptide_evidence->getIdentificationDataSource()->getPeptideEvidenceStore().getInstance(_p_peptide_evidence));
_p_protein_match->addPeptideMatch(_current_peptide_match);
delete _p_peptide_evidence;
return true;
}
......
......@@ -85,6 +85,7 @@ private:
Project * _p_project;
ProteinMatch * _p_protein_match;
PeptideEvidence * _p_peptide_evidence;
PeptideMatch _current_peptide_match;
ProteinXtp _current_protein;
PeptideXtpSp _current_peptide_sp;
IdentificationGroup * _current_identification_group_p;
......
......@@ -284,10 +284,10 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) {
// valeur généric du scan
_current_peptide_sp = PeptideXtp(attributes.value("seq").simplified()).makePeptideXtpSp();
_p_peptide_match = new PeptideMatch(_sp_msrun.get(), attributes.value("id").simplified().section(".",0,0).toUInt());
_p_peptide_evidence = new PeptideEvidence(_sp_msrun.get(), attributes.value("id").simplified().section(".",0,0).toUInt());
_p_peptide_match->setRetentionTime(_retention_time);
_p_peptide_match->setEvalue(attributes.value("expect").simplified().toDouble());
_p_peptide_evidence->setRetentionTime(_retention_time);
_p_peptide_evidence->setEvalue(attributes.value("expect").simplified().toDouble());
//qDebug() << "XtandemSaxHandler::startElement_domain evalue " << _p_peptide_match->getEvalue() << " scan " << _p_peptide_match->getScan();
pappso::pappso_double xtandem_mhtheo = attributes.value("mh").simplified().toDouble();
......@@ -295,14 +295,14 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) {
pappso::pappso_double exp_mass = xtandem_mhtheo + xtandem_delta - pappso::MHPLUS;
_p_peptide_match->setExperimentalMass(exp_mass);
_p_peptide_match->setStart(attributes.value("start").simplified().toUInt()-1);
_p_peptide_match->setCharge(_charge);
_p_peptide_evidence->setExperimentalMass(exp_mass);
_current_peptide_match.setStart(attributes.value("start").simplified().toUInt()-1);
_p_peptide_evidence->setCharge(_charge);
_p_peptide_match->setParam(PeptideMatchParam::tandem_hyperscore, QVariant( attributes.value("hyperscore").toDouble()));
_p_peptide_evidence->setParam(PeptideMatchParam::tandem_hyperscore, QVariant( attributes.value("hyperscore").toDouble()));
_p_peptide_match->setIdentificationDataSource( _p_identification_data_source);
_p_peptide_match->setChecked(true);
_p_peptide_evidence->setIdentificationDataSource( _p_identification_data_source);
_p_peptide_evidence->setChecked(true);
......@@ -320,7 +320,7 @@ bool XtandemSaxHandler::startElement_aa(QXmlAttributes attributes) {
//qDebug() << "startElement_aa ";
pappso::AaModificationP modif = Utils::guessAaModificationPbyMonoisotopicMassDelta(attributes.value("modified").simplified().toDouble());
unsigned int position_in_prot = attributes.value("at").simplified().toUInt()-1;
_current_peptide_sp.get()->addAaModification(modif, position_in_prot-_p_peptide_match->getStart());
_current_peptide_sp.get()->addAaModification(modif, position_in_prot-_current_peptide_match.getStart());
//qDebug() << "startElement_aa end" ;
return is_ok;
}
......
......@@ -86,7 +86,8 @@ private:
MsRunSp _sp_msrun;
ProteinMatch * _p_protein_match;
PeptideMatch * _p_peptide_match;
PeptideEvidence * _p_peptide_evidence;
PeptideMatch _current_peptide_match;
ProteinXtp _current_protein;
PeptideXtpSp _current_peptide_sp;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment