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

new labeling method object

parent caecf14e
No related branches found
No related tags found
No related merge requests found
......@@ -54,6 +54,8 @@ SET(CPP_FILES
core/identificationgroup.cpp
core/identification_sources/identificationdatasource.cpp
core/identification_sources/identificationxtandemfile.cpp
core/labeling/label.cpp
core/labeling/labelingmethod.cpp
core/msrun.cpp
core/peptidematch.cpp
core/peptidextp.cpp
......
/**
* \file core/label.cpp
* \date 20/5/2017
* \author Olivier Langella
* \brief description of a label
*/
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include "label.h"
#include <pappsomspp/amino_acid/aamodification.h>
#include <pappsomspp/pappsoexception.h>
#include <QDebug>
Label::Label(QDomNode & label_node) {
//<isotope_label id="light">
_xml_id =label_node.toElement().attribute("id");
qDebug() <<"Label::Label begin "<<_xml_id;
try {
//<mod at="Nter" value="28.0" acc="MOD:00429"/>
//<mod at="K" value="28.0" acc="MOD:00429"/>
QDomNode child = label_node.firstChild();
while (!child.isNull()) {
if (child.toElement().tagName() == "mod") {
if (child.toElement().attribute("acc").isEmpty()) {
throw pappso::PappsoException(QObject::tr("acc attribute is empty : PSIMOD accession required"));
}
qDebug() <<"Label::Label mod at="<<child.toElement().attribute("at") << " mod="<< child.toElement().attribute("acc");
LabelModification label_modification = {child.toElement().attribute("at"), pappso::AaModification::getInstance( child.toElement().attribute("acc"))};
_modification_list.push_back (label_modification);
}
child = child.nextSibling();
}
}
catch (pappso::PappsoException error) {
throw pappso::PappsoException(QObject::tr("error creating Label : %1").arg(error.qwhat()));
}
}
Label::Label( const Label & other) {
_xml_id = other._xml_id;
_modification_list = other._modification_list;
}
/**
* \file core/label.h
* \date 20/5/2017
* \author Olivier Langella
* \brief description of a label
*/
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#ifndef LABEL_H
#define LABEL_H
#include <QString>
#include <vector>
#include <QDomNode>
#include <pappsomspp/amino_acid/aamodification.h>
struct LabelModification {
QString at;
pappso::AaModificationP modification;
};
class Label
{
public:
Label(QDomNode & method_node);
Label( const Label & other);
private:
QString _xml_id;
std::vector<LabelModification> _modification_list;
};
#endif // LABEL_H
/**
* \file core/labelingmethod.cpp
* \date 20/5/2017
* \author Olivier Langella
* \brief labeling method
*/
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#include "labelingmethod.h"
#include <pappsomspp/pappsoexception.h>
#include <QFile>
#include <QDomDocument>
LabelingMethod::LabelingMethod(const QString & method_id):_xml_id(method_id) {
qDebug() <<"LabelingMethod::LabelingMethod begin "<<_xml_id;
QDomDocument *dom = new QDomDocument("labeling_methods");
QFile xml_doc(":/labeling/resources/catalog_label.xml");
if(!xml_doc.open(QIODevice::ReadOnly))
{
//error
throw pappso::PappsoException(QObject::tr("error opening catalog_label resource file"));
}
if (!dom->setContent(&xml_doc)) {
xml_doc.close();
throw pappso::PappsoException(QObject::tr("error opening catalog_label xml content"));
}
QDomNode child = dom->documentElement().firstChild();
while (!child.isNull()) {
if (child.toElement().tagName() == "isotope_label_list") {
if (child.toElement().attribute("id")== _xml_id) {
parseMethod(child);
}
}
child = child.nextSibling();
}
xml_doc.close();
delete dom;
}
LabelingMethod::LabelingMethod( const LabelingMethod & other):_xml_id(other._xml_id) {
for (Label * p_label: other._label_list) {
_label_list.push_back( new Label(*p_label));
}
}
LabelingMethod::~LabelingMethod() {
for (Label * p_label: _label_list) {
delete p_label;
}
}
LabelingMethodSp LabelingMethod::makeLabelingMethodSp() const {
return std::make_shared<LabelingMethod>(*this);
}
void LabelingMethod::parseMethod(QDomNode & method_node) {
QDomNode child = method_node.firstChild();
while (!child.isNull()) {
if (child.toElement().tagName() == "isotope_label") {
_label_list.push_back( new Label(child));
}
child = child.nextSibling();
}
}
/**
* \file core/labelingmethod.h
* \date 20/5/2017
* \author Olivier Langella
* \brief labeling method
*/
/*******************************************************************************
* Copyright (c) 2017 Olivier Langella <olivier.langella@u-psud.fr>.
*
* This file is part of XTPcpp.
*
* XTPcpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XTPcpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XTPcpp. If not, see <http://www.gnu.org/licenses/>.
*
* Contributors:
* Olivier Langella <olivier.langella@u-psud.fr> - initial API and implementation
******************************************************************************/
#ifndef LABELINGMETHOD_H
#define LABELINGMETHOD_H
#include <QString>
#include <QDomNode>
#include <vector>
#include <memory>
#include "label.h"
class LabelingMethod;
typedef std::shared_ptr<LabelingMethod> LabelingMethodSp;
class LabelingMethod
{
public:
LabelingMethod(const QString & method_id);
LabelingMethod( const LabelingMethod & other);
~LabelingMethod();
LabelingMethodSp makeLabelingMethodSp() const;
private :
void parseMethod(QDomNode & method_node);
void parseLabel(QDomNode & method_node);
private:
const QString _xml_id;
std::vector<Label *> _label_list;
};
#endif // LABELINGMETHOD_H
......@@ -27,6 +27,7 @@
#include <QFile>
#include <QDomDocument>
#include <QMessageBox>
#include "../../core/labeling/labelingmethod.h"
EditLabelMethods::EditLabelMethods(ProjectWindow *parent):
QDialog(parent),
......@@ -97,6 +98,8 @@ void EditLabelMethods::ItemClicked (QModelIndex index )
{
qDebug() << "EditLabelMethods::ItemClicked begin" << index.data().toString();
ui->ok_button->setDisabled(false);
LabelingMethod method(index.data().toString());
}
......
......@@ -5,12 +5,12 @@
<mod at="K" value="28.0" acc="MOD:00429"/>
</isotope_label>
<isotope_label id="inter">
<mod at="Nter" value="32.0" />
<mod at="K" value="32.0" />
<mod at="Nter" value="32.0" acc="MOD:00552"/>
<mod at="K" value="32.0" acc="MOD:00552"/>
</isotope_label>
<isotope_label id="heavy">
<mod at="Nter" value="36.0" />
<mod at="K" value="36.0" />
<mod at="Nter" value="36.0" acc="MOD:00638"/>
<mod at="K" value="36.0" acc="MOD:00638"/>
</isotope_label>
</isotope_label_list>
</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