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

xpip export system is going on

parent 6769a3b3
No related branches found
No related tags found
No related merge requests found
......@@ -184,6 +184,9 @@ const std::vector<MsRunSp> & IdentificationGroup::getMsRunSpList() const {
const std::vector<IdentificationDataSource *> & IdentificationGroup::getIdentificationDataSourceList() const {
return _id_source_list;
}
const std::vector<ProteinMatch *> & IdentificationGroup::getProteinMatchList() const {
return _protein_match_list;
}
std::vector<ProteinMatch *> & IdentificationGroup::getProteinMatchList() {
return _protein_match_list;
}
......
......@@ -50,6 +50,7 @@ public:
const GroupStore & getGroupStore() const;
void addProteinMatch(ProteinMatch * protein_match);
std::vector<ProteinMatch *> & getProteinMatchList();
const std::vector<ProteinMatch *> & getProteinMatchList() const;
void addIdentificationDataSourceP(IdentificationDataSource * p_identification_source);
const PtmGroupingExperiment * getPtmGroupingExperiment() const;
......
......@@ -85,6 +85,10 @@ const QString & Label::getXmlId() const {
return _xml_id;
}
const std::vector<LabelModification> & Label::getLabelModifictionList() const {
return _modification_list;
}
void Label::writeMassChroqMl(QXmlStreamWriter* output_stream) const {
......@@ -95,11 +99,11 @@ void Label::writeMassChroqMl(QXmlStreamWriter* output_stream) const {
// <mod at="K" value="28.0" acc="MOD:00429"/>
for (const LabelModification label_modification: _modification_list) {
output_stream->writeStartElement("mod");
output_stream->writeAttribute("at",label_modification.at);
output_stream->writeAttribute("at",label_modification.at);
output_stream->writeAttribute("value",Utils::getXmlDouble(label_modification.modification->getMass()));
output_stream->writeAttribute("acc",label_modification.modification->getAccession());
output_stream->writeEndElement();
output_stream->writeComment(label_modification.modification->getName());
output_stream->writeEndElement();
output_stream->writeComment(label_modification.modification->getName());
}
// </isotope_label>
output_stream->writeEndElement();
......
......@@ -52,6 +52,9 @@ public:
pappso::PeptideSp getLabeledPeptideSp(const pappso::Peptide * p_peptide) const;
void writeMassChroqMl(QXmlStreamWriter* output_stream) const;
const QString & getXmlId() const;
const std::vector<LabelModification> & getLabelModifictionList() const;
private:
QString _xml_id;
std::vector<LabelModification> _modification_list;
......
......@@ -42,7 +42,7 @@ public:
PeptideXtpSp makePeptideXtpSp() const;
/** \brief get the tehoretical mass to use for grouping
/** \brief get the theoretical mass to use for grouping
* This mass might be different than the true peptide mass to recognize that a tagged
* peptide with taget modification is a light, inter or heavy version of the same peptide
*/
......
......@@ -31,6 +31,8 @@
#include "../config.h"
#include <QDateTime>
#include <pappsomspp/pappsoexception.h>
#include <pappsomspp/utils.h>
#include <QDebug>
Xpip::Xpip(const QString & out_filename)
{
......@@ -117,8 +119,10 @@ void Xpip::write(ProjectSp sp_project) {
writeMsrunList(_sp_project.get()->getMsRunStore());
writeIdentificationDataSourceList(_sp_project.get()->getIdentificationDataSourceStore());
writeProteinList();
writePeptideList();
writeIdentificationGroupList();
_output_stream->writeEndDocument();
}
void Xpip::writeDoubleAttribute(const QString & attribute, pappso::pappso_double value) {
......@@ -135,13 +139,14 @@ void Xpip::writeBooleanAttribute(const QString & attribute, bool value) {
}
void Xpip::writeFilterParameters(const AutomaticFilterParameters & filters) {
qDebug() << "Xpip::writeFilterParameters begin";
_output_stream->writeStartElement("filter_params");
writeDoubleAttribute("pep_evalue",filters.getFilterPeptideEvalue());
writeDoubleAttribute("prot_evalue",filters.getFilterProteinEvalue());
_output_stream->writeAttribute("pep_number",QString("%1").arg(filters.getFilterMinimumPeptidePerMatch()));
writeBooleanAttribute("cross_sample",filters.getFilterCrossSamplePeptideNumber());
_output_stream->writeEndElement();
qDebug() << "Xpip::writeFilterParameters end";
}
void Xpip::writeDescription() {
......@@ -206,6 +211,7 @@ void Xpip::writeMsrunList(const MsRunStore & msrun_store) {
}
void Xpip::writeFastaFileList(const FastaFileStore & fasta_store) {
qDebug() << "Xpip::writeFastaFileList begin";
_output_stream->writeStartElement("fasta_file_list");
for (FastaFileSp fasta_file_sp : fasta_store.getFastaFileList()) {
_output_stream->writeStartElement("fasta_file");
......@@ -215,4 +221,149 @@ void Xpip::writeFastaFileList(const FastaFileStore & fasta_store) {
_output_stream->writeEndElement();
}
_output_stream->writeEndElement();
qDebug() << "Xpip::writeFastaFileList end";
}
void Xpip::writeProteinList() {
qDebug() << "Xpip::writeProteinList begin";
_output_stream->writeStartElement("protein_list");
const ProteinStore & protein_store = _sp_project.get()->getProteinStore();
for (std::pair<QString, ProteinXtpSp> protein_pair : protein_store.getProteinMap()) {
const ProteinXtp * p_protein = protein_pair.second.get();
_output_stream->writeStartElement("protein");
_output_stream->writeAttribute("acc",p_protein->getAccession());
_output_stream->writeAttribute("description",p_protein->getDescription());
_output_stream->writeAttribute("is_decoy","false");
if (p_protein->isDecoy()) {
_output_stream->writeAttribute("is_decoy","true");
}
_output_stream->writeAttribute("is_contaminant","false");
if (p_protein->isContaminant()) {
_output_stream->writeAttribute("is_contaminant","true");
}
_output_stream->writeStartElement("sequence");
_output_stream->writeCharacters(p_protein->getSequence());
_output_stream->writeEndElement();
for (DbXref db_xref : p_protein->getDbxrefList()) {
_output_stream->writeStartElement("dbxref");
_output_stream->writeAttribute("acc",db_xref.accession);
_output_stream->writeAttribute("database",QString("%1").arg(static_cast<std::int8_t>(db_xref.database)));
_output_stream->writeEndElement();
}
_output_stream->writeEndElement();
}
_output_stream->writeEndElement();
qDebug() << "Xpip::writeProteinList end";
}
QString Xpip::getPeptideId(std::size_t crc_peptide) const {
return QString("p%1").arg(pappso::Utils::getLexicalOrderedString(crc_peptide));
}
void Xpip::writeLabelingMethod() {
qDebug() << "Xpip::writeLabelingMethod begin";
LabelingMethod * p_labeling_method = _sp_project.get()->getLabelingMethodSp().get();
if (p_labeling_method == nullptr) return;
_output_stream->writeStartElement("label_method");
_output_stream->writeAttribute("id",p_labeling_method->getXmlId());
_output_stream->writeStartElement("label_list");
for (const Label * p_label : p_labeling_method->getLabelList()) {
_output_stream->writeStartElement("label");
_output_stream->writeAttribute("id", p_label->getXmlId());
for (const LabelModification label_modification : p_label->getLabelModifictionList()) {
_output_stream->writeStartElement("label_modification");
_output_stream->writeAttribute("at", label_modification.at);
_output_stream->writeAttribute("mod", label_modification.modification->getAccession());
_output_stream->writeEndElement();// label_modification
}
_output_stream->writeEndElement();// label
}
_output_stream->writeEndElement();// label_list
_output_stream->writeEndElement();// label_method
qDebug() << "Xpip::writeLabelingMethod end";
}
void Xpip::writePeptideList() {
qDebug() << "Xpip::writePeptideList begin";
_output_stream->writeStartElement("peptide_list");
writeLabelingMethod();
const PeptideStore & peptide_store = _sp_project.get()->getPeptideStore();
_output_stream->writeStartElement("modification_list");
for (pappso::AaModificationP mod_p : peptide_store.getModificationCollection()) {
QString id = QString("mod%1").arg(pappso::Utils::getLexicalOrderedString(_map_modifications.size()+1));
_map_modifications.insert(std::pair<pappso::AaModificationP, QString>(mod_p, id));
_output_stream->writeStartElement("modification");
_output_stream->writeAttribute("id", id);
_output_stream->writeAttribute("mod", mod_p->getAccession());
_output_stream->writeEndElement();// modification
}
_output_stream->writeEndElement();// modification_list
for (std::pair<std::size_t, PeptideXtpSp> peptide_pair : peptide_store.getPeptideMap()) {
const PeptideXtp * p_peptide = peptide_pair.second.get();
_output_stream->writeStartElement("peptide");
QString idp = QString("p%1").arg(pappso::Utils::getLexicalOrderedString(_map_peptides.size()+1));
_map_peptides.insert(std::pair<const PeptideXtp *, QString>(p_peptide, idp));
_output_stream->writeAttribute("id",idp);
_output_stream->writeAttribute("seq",p_peptide->getSequence());
const Label * p_label = p_peptide->getLabel();
if (p_label != nullptr) {
_output_stream->writeAttribute("label_id",p_label->getXmlId());
}
unsigned int i=1;
for (const pappso::Aa & amino_acid: *p_peptide) {
std::list<pappso::AaModificationP> aa_modif_list = amino_acid.getModificationList();
for (auto && aa_modif : aa_modif_list) {
if (!aa_modif->isInternal()) {
_output_stream->writeStartElement("mod");
_output_stream->writeAttribute("ref", _map_modifications.at(aa_modif));
_output_stream->writeAttribute("position", QString ("%1").arg(i));
_output_stream->writeAttribute("aa", QString(amino_acid.getLetter()));
_output_stream->writeEndElement();// mod
}
}
i++;
}
_output_stream->writeEndElement();// peptide
}
_output_stream->writeEndElement(); //peptide_list
qDebug() << "Xpip::writePeptideList end";
}
void Xpip::writeIdentificationGroupList() {
qDebug() << "Xpip::writeIdentificationGroupList begin";
_output_stream->writeStartElement("identification_group_list");
for (const IdentificationGroup * p_identification_group : _sp_project.get()->getIdentificationGroupList()) {
//std::vector<ProteinMatch *> & getProteinMatchList()
writeIdentificationGroup(p_identification_group);
}
_output_stream->writeEndElement(); //identification_group_list
qDebug() << "Xpip::writeIdentificationGroupList end";
}
void Xpip::writeIdentificationGroup(const IdentificationGroup * p_identification_group) {
qDebug() << "Xpip::writeIdentificationGroup begin";
_output_stream->writeStartElement("protein_match_list");
for (const ProteinMatch * p_protein_match : p_identification_group->getProteinMatchList()) {
//std::vector<ProteinMatch *> & getProteinMatchList()
_output_stream->writeStartElement("protein_match");
_output_stream->writeAttribute("acc", p_protein_match->getProteinXtpSp().get()->getAccession());
_output_stream->writeEndElement();// protein_match
}
_output_stream->writeEndElement(); //protein_match_list
qDebug() << "Xpip::writeIdentificationGroup end";
}
......@@ -53,12 +53,22 @@ private :
void writeFastaFileList(const FastaFileStore & fasta_store);
void writeDoubleAttribute(const QString & attribute, pappso::pappso_double value);
void writeBooleanAttribute(const QString & attribute, bool value);
void writeProteinList();
void writePeptideList();
void writeLabelingMethod();
void writeIdentificationGroupList();
void writeIdentificationGroup(const IdentificationGroup * p_identification_group);
QString getPeptideId(std::size_t crc_peptide) const;
private :
QFile * _output_file;
QXmlStreamWriter * _output_stream;
ProjectSp _sp_project;
std::map<pappso::AaModificationP, QString> _map_modifications;
std::map<const PeptideXtp *, QString> _map_peptides;
};
......
......@@ -103,3 +103,7 @@ void PeptideStore::setLabelingMethodSp(LabelingMethodSp labeling_method_sp) {
peptide_xtp.get()->applyLabelingMethod(labeling_method_sp);
}
}
const std::unordered_map<std::size_t, PeptideXtpSp> & PeptideStore::getPeptideMap() const {
return _map_crc_peptide_list;
}
......@@ -56,6 +56,8 @@ public:
/** @brief apply labeling method to all peptide match
* */
void setLabelingMethodSp(LabelingMethodSp labeling_method_sp);
const std::unordered_map<std::size_t, PeptideXtpSp> & getPeptideMap() const;
private:
/** @brief reset labeling method
* */
......
......@@ -69,6 +69,11 @@ void ProteinStore::setRegexpContaminantPattern(const QString & pattern) {
QRegExp ProteinStore::getRegexpDecoy() const {
return (_regexp_decoy);
}
const std::map<QString, ProteinXtpSp> & ProteinStore::getProteinMap() const {
return _map_accession_protein_list;
}
void ProteinStore::setRegexpDecoyPattern(const QString & pattern) {
_regexp_decoy.setPattern(pattern);
......
......@@ -69,6 +69,8 @@ public:
void setContaminantAccession(QString accession);
void setDecoyAccession(QString accession);
const std::map<QString, ProteinXtpSp> & getProteinMap() const;
private :
void setProteinInformations(ProteinXtpSp & protein_in);
......
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