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

reading Xtandem files seems to work!

parent c74b0fad
No related branches found
No related tags found
No related merge requests found
......@@ -78,6 +78,7 @@ void IdentificationXtandemFile::parseTo(Project* p_project) {
}
}
identification_group_p->addMsRunSp(msrun_sp);
XtandemSaxHandler * parser = new XtandemSaxHandler(p_project, identification_group_p, this);
QXmlSimpleReader simplereader;
......
......@@ -66,12 +66,20 @@ void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) {
if (accession.isEmpty()) {
throw pappso::PappsoException(QObject::tr("Error adding protein match : accession is empty"));
}
bool push = true;
for (ProteinMatch * p_protein_match : _protein_match_list) {
if ((p_protein_match != protein_match) && (p_protein_match->getProteinXtpSp().get()->getAccession() == accession)) {
throw pappso::PappsoException(QObject::tr("Error adding protein match : accession %1 already registered").arg(accession));
if (p_protein_match == protein_match) {
push = false;
}
else {
if(p_protein_match->getProteinXtpSp().get()->getAccession() == accession) {
throw pappso::PappsoException(QObject::tr("Error adding protein match : accession %1 already registered").arg(accession));
}
}
}
if (push) {
_protein_match_list.push_back(protein_match);
}
_protein_match_list.push_back(protein_match);
}
bool IdentificationGroup::contains (const MsRun * p_msrun) const {
......@@ -81,7 +89,10 @@ bool IdentificationGroup::contains (const MsRun * p_msrun) const {
return false;
}
void IdentificationGroup::addMsRunSp(MsRunSp ms_run_sp) {
_ms_run_list.push_back(ms_run_sp);
auto it = std::find (_ms_run_list.begin() ,_ms_run_list.end(),ms_run_sp);
if (it == _ms_run_list.end()) {
_ms_run_list.push_back(ms_run_sp);
}
}
const std::vector<MsRunSp> & IdentificationGroup::getMsRunSpList() const {
return _ms_run_list;
......
......@@ -58,12 +58,14 @@ void XtpLoaderThread::doLoadingResults(bool is_individual, AutomaticFilterParame
qDebug() << "XtpLoaderThread::doLoadingResults begin ";
try {
ProjectSp project_sp = Project().makeProjectSp();
project_sp.get()->setCombineMode(!is_individual);
project_sp.get()->setCombineMode(!is_individual);
for (QString filename : file_list) {
emit loadingMessage(tr("loading result file %1").arg(filename));
project_sp.get()->readResultFile(filename);
}
emit loadingMessage(tr("filtering proteins"));
project_sp.get()->updateAutomaticFilters(param);
emit projectReady(project_sp);
......@@ -114,6 +116,8 @@ MainWindow::MainWindow(QWidget *parent):
connect(worker, SIGNAL(projectReady(ProjectSp)), this,SLOT(doProjectReady(ProjectSp)));
connect(this, SIGNAL(operateLoadingResults(bool,AutomaticFilterParameters,QStringList)), worker,SLOT(doLoadingResults(bool,AutomaticFilterParameters,QStringList)));
connect(_p_load_results_dialog, SIGNAL(accepted()), this,SLOT(doAcceptedLoadResultDialog()));
connect(worker, SIGNAL(loadingMessage(QString)), this,SLOT(doDisplayLoadingMessage(QString)));
connect(worker, SIGNAL(projectNotReady(QString)), this,SLOT(doProjectNotReady(QString)));
/*
connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater()));
connect(this, SIGNAL(operateMsDataFile(QString)), worker,SLOT(doMsDataFileLoad(QString)));
......@@ -147,6 +151,7 @@ void MainWindow::viewError(QString error) {
}
void MainWindow::doDisplayLoadingMessage(QString message) {
qDebug() << "MainWindow::doDisplayLoadingMessage " << message;
ui->statusbar->showMessage(message);
}
......@@ -168,13 +173,17 @@ void MainWindow::doAcceptedLoadResultDialog() {
void MainWindow::doProjectReady(ProjectSp project_sp) {
qDebug() << "MainWindow::doProjectReady begin";
try {
doDisplayLoadingMessage(tr("grouping proteins"));
project_sp.get()->startGrouping();
}
catch (pappso::PappsoException & error) {
viewError(tr("Error while grouping :\n%1").arg(error.qwhat()));
}
_project_window->setProjectSp(project_sp);
qDebug() << "MainWindow::doProjectReady end";
}
......
......@@ -96,6 +96,9 @@ bool XtandemSaxHandler::endElement(const QString & namespaceURI, const QString &
if (qName == "note")
{
is_ok = endElement_note();
} else if (qName == "domain")
{
is_ok = endElement_domain();
}
// end of detection_moulon
......@@ -159,14 +162,15 @@ bool XtandemSaxHandler::startElement_protein(QXmlAttributes attributes) {
_current_protein.setAccession(accession);
if (_p_protein_match == nullptr) {
_p_protein_match = new ProteinMatch();
//qDebug() << "startElement_protein p_protein_match 2 " << _p_protein_match;
//qDebug() << "startElement_protein p_protein_match 2 " << _p_protein_match;
_p_protein_match->setChecked(false);
}
//qDebug() << "startElement_protein p_protein_match 3 " << _p_protein_match;
ProteinXtpSp sp_xtp_protein = _current_protein.makeProteinXtpSp();
_p_protein_match->setProteinXtpSp(_p_project->getProteinStore().getInstance(sp_xtp_protein));
_p_protein_match->setChecked(true);
_p_identification_group->addProteinMatch(_p_protein_match);
//qDebug() << "startElement_protein end" ;
return is_ok;
......@@ -187,7 +191,7 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) {
//<domain id="1976.1.1" start="620" end="629" expect="9.7e-04" mh="1120.5307" delta="-0.0012" hyperscore="29.9"
//nextscore="10.2" y_score="10.4" y_ions="7" b_score="11.2" b_ions="3" pre="QLYR" post="RYGV"
//seq="AQEEMAQVAK" missed_cleavages="0">
qDebug() << "startElement_domain ";
//qDebug() << "startElement_domain ";
bool is_ok = true;
_current_text = _current_text.simplified().replace(" ", "");
if (!_current_text.isEmpty()) {
......@@ -206,21 +210,19 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) {
_p_peptide_match->setRetentionTime(_retention_time);
_p_peptide_match->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();
pappso::pappso_double xtandem_delta = attributes.value("delta").simplified().toDouble();
pappso::pappso_double exp_mass = xtandem_mhtheo - xtandem_delta;
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_match->setIdentificationDataSource( _p_identification_data_source);
_p_peptide_match->setChecked(false);
if (attributes.value("validate").simplified().toLower() == "true") {
_p_peptide_match->setChecked(true);
}
_p_peptide_match->setChecked(true);
_p_protein_match->addPeptideMatch(_p_peptide_match);
......@@ -236,14 +238,21 @@ bool XtandemSaxHandler::startElement_domain(QXmlAttributes attributes) {
bool XtandemSaxHandler::startElement_aa(QXmlAttributes attributes) {
//<aa type="M" at="624" modified="15.99491" />
bool is_ok = true;
qDebug() << "startElement_aa ";
//qDebug() << "startElement_aa ";
pappso::AaModificationP modif = getAaModificationP(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());
qDebug() << "startElement_aa end" ;
//qDebug() << "startElement_aa end" ;
return is_ok;
}
bool XtandemSaxHandler::endElement_domain() {
bool is_ok = true;
_current_peptide_sp = _p_project->getPeptideStore().getInstance(_current_peptide_sp);
_p_peptide_match->setPeptideXtpSp(_current_peptide_sp);
return is_ok;
}
bool XtandemSaxHandler::endElement_note() {
//<note label="description">GRMZM2G083841_P01 P04711 Phosphoenolpyruvate carboxylase 1 (PEPCase 1)(PEPC 1)(EC //4.1.1.31) seq=translation; coord=9:61296279..61301686:1; parent_transcript=GRMZM2G083841_T01;
////parent_gene=GRMZM2G083841</note>
......
......@@ -72,6 +72,7 @@ private:
bool startElement_file(QXmlAttributes attributes);
bool startElement_aa(QXmlAttributes attributes);
bool startElement_domain(QXmlAttributes attributes);
bool endElement_domain();
bool endElement_note();
pappso::AaModificationP getAaModificationP(pappso::mz mass) const;
......
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