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

better proticdbml check

parent 1d4e8f2e
No related branches found
No related tags found
No related merge requests found
...@@ -68,7 +68,7 @@ ProticdbMl::~ProticdbMl() ...@@ -68,7 +68,7 @@ ProticdbMl::~ProticdbMl()
void ProticdbMl::close() { void ProticdbMl::close() {
_output_stream->writeEndDocument(); _output_stream->writeEndDocument();
_output_file->close(); _output_file->close();
qDebug() << "ProticdbMl::close end duration = " << _duracel.elapsed() << "ms"; qDebug() << "ProticdbMl::close end duration = " << _duracel.elapsed() << "ms";
} }
...@@ -563,91 +563,121 @@ void ProticdbMl::writeMatchs(IdentificationGroup * p_identification) { ...@@ -563,91 +563,121 @@ void ProticdbMl::writeMatchs(IdentificationGroup * p_identification) {
_output_stream->writeEndElement();// "matchs"); _output_stream->writeEndElement();// "matchs");
} }
const QString & ProticdbMl::getPeptideXmlId(const PeptideMatch* p_peptide_match) const {
void ProticdbMl::writeMatch(std::vector<const ProteinMatch *> & protein_match_sg_list) { QString peptide_key = getProticPeptideHitKey(p_peptide_match);
auto it = _peptidekey_to_id.find(peptide_key);
if (protein_match_sg_list.size() == 0) return; if (it == _peptidekey_to_id.end()) {
//for (SubGroup sg : group.getSubGroupSet().getSubGroupList()) { throw pappso::PappsoException(QObject::tr("Error peptide key %1 not found for peptide match %2 sample=%3 scan=%4 start=%5").arg(peptide_key)
_output_stream->writeStartElement("match"); .arg(p_peptide_match->getPeptideXtpSp().get()->toString())
.arg(p_peptide_match->getMsRunP()->getXmlId())
// samples .arg(p_peptide_match->getScan())
QStringList sample_name_list; .arg(p_peptide_match->getStart())
for (const PeptideMatch * p_peptide_match: protein_match_sg_list[0]->getPeptideMatchList(ValidationState::grouped)) { );
sample_name_list << p_peptide_match->getMsRunP()->getSampleName();
}
sample_name_list = sample_name_list.toSet().toList();
for (QString sample_name :sample_name_list) {
_output_stream->writeStartElement("matchSample");
_output_stream->writeAttribute(
"sample_id",_sample_to_id[sample_name]);
_output_stream->writeAttribute("name", sample_name);
_output_stream->writeEndElement();// "matchSample");
} }
return it->second;
// proteins }
for (const ProteinMatch * p_protein_match: protein_match_sg_list) { const QString & ProticdbMl::getProteinXmlId(const ProteinMatch* p_protein_match) const {
_output_stream->writeStartElement("proteinHit"); auto it = _map_accession2xmlid.find(p_protein_match->getProteinXtpSp().get()->getAccession());
_output_stream->writeAttribute("sequence_id",QString("%1 %2").arg(p_protein_match->getProteinXtpSp().get()->getAccession()).arg(p_protein_match->getProteinXtpSp().get()->getDescription())); if (it == _map_accession2xmlid.end()) {
// proteinHit.setAttribute("score", ""); throw pappso::PappsoException(QObject::tr("Error protein accession %1 not found for protein %2")
_output_stream->writeAttribute("rank", QString("%1").arg(p_protein_match->getGrpProteinSp().get()->getRank())); .arg(p_protein_match->getProteinXtpSp().get()->getAccession())
.arg(p_protein_match->getProteinXtpSp().get()->getAccession()));
// //cvparam
writeCvParam("PROTICdbO:0000284",QString("%1").arg(p_protein_match->getProteinXtpSp().get()->getMass()),
"MW computation");
// evalue
writeCvParam("PROTICdbO:0000291", Utils::getXmlDouble(p_protein_match->getLogEvalue())
, "Xtandem log evalue");
// coverage
writeCvParam(
"PROTICdbO:0000285", Utils::getXmlDouble(p_protein_match->getCoverage()),
"protein coverage");
// [Term]
// id: PROTICdbO:0000335
// name: X!TandemPipeline PAI
writeCvParam("PROTICdbO:0000335",Utils::getXmlDouble(p_protein_match->getPAI()), "PAI");
// [Term]
// id: PROTICdbO:0000337
// name: protein group number
writeCvParam("PROTICdbO:0000337",p_protein_match->getGrpProteinSp().get()->getGroupingId(), "grouping number");
_output_stream->writeEndElement();// "proteinHit");
} }
return it->second;
}
void ProticdbMl::writeMatch(std::vector<const ProteinMatch *> & protein_match_sg_list) {
try {
if (protein_match_sg_list.size() == 0) return;
//for (SubGroup sg : group.getSubGroupSet().getSubGroupList()) {
_output_stream->writeStartElement("match");
// samples
QStringList sample_name_list;
for (const PeptideMatch * p_peptide_match: protein_match_sg_list[0]->getPeptideMatchList(ValidationState::grouped)) {
sample_name_list << p_peptide_match->getMsRunP()->getSampleName();
}
sample_name_list = sample_name_list.toSet().toList();
for (QString sample_name :sample_name_list) {
_output_stream->writeStartElement("matchSample");
_output_stream->writeAttribute(
"sample_id",_sample_to_id[sample_name]);
_output_stream->writeAttribute("name", sample_name);
_output_stream->writeEndElement();// "matchSample");
}
for (const ProteinMatch * p_protein_match: protein_match_sg_list) { // proteins
//peptides for (const ProteinMatch * p_protein_match: protein_match_sg_list) {
for (const PeptideMatch * p_peptide_match: p_protein_match->getPeptideMatchList(ValidationState::grouped)) { _output_stream->writeStartElement("proteinHit");
// peptidesHitRef _output_stream->writeAttribute("sequence_id",QString("%1 %2").arg(p_protein_match->getProteinXtpSp().get()->getAccession()).arg(p_protein_match->getProteinXtpSp().get()->getDescription()));
QString peptide_key = getProticPeptideHitKey(p_peptide_match); // proteinHit.setAttribute("score", "");
QString peptide_xml_id = _peptidekey_to_id.at(peptide_key); _output_stream->writeAttribute("rank", QString("%1").arg(p_protein_match->getGrpProteinSp().get()->getRank()));
// //cvparam
writeCvParam("PROTICdbO:0000284",QString("%1").arg(p_protein_match->getProteinXtpSp().get()->getMass()),
"MW computation");
// evalue
writeCvParam("PROTICdbO:0000291", Utils::getXmlDouble(p_protein_match->getLogEvalue())
, "Xtandem log evalue");
// coverage
writeCvParam(
"PROTICdbO:0000285", Utils::getXmlDouble(p_protein_match->getCoverage()),
"protein coverage");
// [Term]
// id: PROTICdbO:0000335
// name: X!TandemPipeline PAI
writeCvParam("PROTICdbO:0000335",Utils::getXmlDouble(p_protein_match->getPAI()), "PAI");
// [Term]
// id: PROTICdbO:0000337
// name: protein group number
writeCvParam("PROTICdbO:0000337",p_protein_match->getGrpProteinSp().get()->getGroupingId(), "grouping number");
_output_stream->writeEndElement();// "proteinHit");
}
_output_stream->writeStartElement("peptideHitRef"); for (const ProteinMatch * p_protein_match: protein_match_sg_list) {
_output_stream->writeAttribute("peptide_hit_id", peptide_xml_id); //peptides
for (const PeptideMatch * p_peptide_match: p_protein_match->getPeptideMatchList(ValidationState::grouped)) {
// peptidesHitRef
QString peptide_xml_id = getPeptideXmlId(p_peptide_match);
_output_stream->writeStartElement("peptideHitRef");
_output_stream->writeAttribute("peptide_hit_id", peptide_xml_id);
_output_stream->writeStartElement("fromSeq");
_output_stream->writeAttribute(
"seq_id", getProteinXmlId(p_protein_match));
_output_stream->writeAttribute("start", QString("%1").arg(p_peptide_match->getStart()+1));
_output_stream->writeAttribute("stop", QString("%1").arg(p_peptide_match->getStop()+1));
QString residue_before_nter = "-";
if (p_peptide_match->getStart() > 0) {
residue_before_nter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(p_peptide_match->getStart()-1,1);
}
_output_stream->writeAttribute("residue_before_nter", residue_before_nter);
QString residue_after_cter = "-";
if (p_peptide_match->getStop() < (p_protein_match->getProteinXtpSp().get()->getSequence().size()-1)) {
residue_after_cter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(p_peptide_match->getStop(),1);
}
_output_stream->writeAttribute("residue_after_cter", residue_after_cter);
_output_stream->writeStartElement("fromSeq"); _output_stream->writeEndElement();// fromSeq
_output_stream->writeAttribute( _output_stream->writeEndElement();// peptideHitRef
"seq_id",_map_accession2xmlid.at(p_protein_match->getProteinXtpSp().get()->getAccession()));
_output_stream->writeAttribute("start", QString("%1").arg(p_peptide_match->getStart()+1));
_output_stream->writeAttribute("stop", QString("%1").arg(p_peptide_match->getStop()+1));
QString residue_before_nter = "-";
if (p_peptide_match->getStart() > 0) {
residue_before_nter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(p_peptide_match->getStart()-1,1);
}
_output_stream->writeAttribute("residue_before_nter", residue_before_nter);
QString residue_after_cter = "-";
if (p_peptide_match->getStop() < (p_protein_match->getProteinXtpSp().get()->getSequence().size()-1)) {
residue_after_cter = p_protein_match->getProteinXtpSp().get()->getSequence().mid(p_peptide_match->getStop(),1);
} }
_output_stream->writeAttribute("residue_after_cter", residue_after_cter);
_output_stream->writeEndElement();// fromSeq
_output_stream->writeEndElement();// peptideHitRef
} }
_output_stream->writeEndElement();// "match");
}
catch (pappso::PappsoException &error)
{
throw pappso::PappsoException(QObject::tr("Error in ProticdbMl::writeMatch :\n%1").arg(error.qwhat()));
}
catch (std::exception &error)
{
throw pappso::PappsoException(QObject::tr("Error in ProticdbMl::writeMatch stdex :\n%1").arg(error.what()));
} }
_output_stream->writeEndElement();// "match");
} }
void ProticdbMl::writeOboModif(pappso::AaModificationP mod) { void ProticdbMl::writeOboModif(pappso::AaModificationP mod) {
_output_stream->writeStartElement("cvParam"); _output_stream->writeStartElement("cvParam");
......
...@@ -66,6 +66,9 @@ private : ...@@ -66,6 +66,9 @@ private :
void writeMatchs(IdentificationGroup * p_identification); void writeMatchs(IdentificationGroup * p_identification);
void writeMatch(std::vector<const ProteinMatch *> & protein_match_sg_list); void writeMatch(std::vector<const ProteinMatch *> & protein_match_sg_list);
const QString & getPeptideXmlId(const PeptideMatch* p_peptide_match) const;
const QString & getProteinXmlId(const ProteinMatch* p_protein_match) const;
private : private :
QFile * _output_file; QFile * _output_file;
QXmlStreamWriter * _output_stream; QXmlStreamWriter * _output_stream;
......
...@@ -12,5 +12,4 @@ ...@@ -12,5 +12,4 @@
<mod at="Nter" value="36.0" acc="MOD:00638"/> <mod at="Nter" value="36.0" acc="MOD:00638"/>
<mod at="K" value="36.0" acc="MOD:00638"/> <mod at="K" value="36.0" acc="MOD:00638"/>
</isotope_label> </isotope_label>
</isotope_label_list>
</catalog> </catalog>
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