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

valid and checked design

parent c1bb0995
No related branches found
No related tags found
No related merge requests found
......@@ -53,9 +53,10 @@ configure_file (${CMAKE_SOURCE_DIR}/src/config.h.cmake ${CMAKE_SOURCE_DIR}/src/c
# File list
SET(CPP_FILES
core/automaticfilterparameters.cpp
core/identificationgroup.cpp
core/peptidematch.cpp
core/project.cpp
./core/project.cpp
core/proteinmatch.cpp
core/identification_sources/identificationdatasource.cpp
core/identification_sources/identificationxtandemfile.cpp
......
......@@ -38,11 +38,12 @@ IdentificationGroup::~IdentificationGroup()
}
}
bool IdentificationGroup::isValid(ProteinMatch* p_protein_match) const {
return _p_project->isValid(p_protein_match);
void IdentificationGroup::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
for (auto & p_protein_match : _protein_match_list) {
p_protein_match->updateAutomaticFilters(automatic_filter_parameters);
}
}
void IdentificationGroup::addProteinMatch(ProteinMatch * protein_match) {
_protein_match_list.push_back(protein_match);
}
......
......@@ -47,9 +47,9 @@ public:
void addMsRunIdSp(pappso::MsRunIdSp ms_run_sp);
/** @brief is it valid regarding threshold and project rules
*/
bool isValid(ProteinMatch* p_protein_match) const;
/** @brief validate or invalidate peptides and proteins based automatic filters and manual checks
* */
void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters);
pappso::GrpExperiment * _p_grp_experiment= nullptr;
private :
......
......@@ -28,6 +28,13 @@ PeptideMatch::PeptideMatch(pappso::MsRunIdSp msrunid_sp, unsigned int scan) {
_scan = scan;
}
void PeptideMatch::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
_proxy_valid = false;
if (_evalue <= automatic_filter_parameters.getFilterPeptideEvalue()) {
_proxy_valid = true;
}
}
void PeptideMatch::setRetentionTime(pappso::pappso_double rt) {
_rt = rt;
}
......@@ -56,10 +63,16 @@ void PeptideMatch::setChecked(bool arg1) {
_checked = arg1;
}
bool PeptideMatch::isValid() const {
return _proxy_valid;
}
bool PeptideMatch::isChecked() const {
return _checked;
}
bool PeptideMatch::isValidAndChecked() const{
return _proxy_valid && _checked;
}
void PeptideMatch::setIdentificationDataSource(IdentificationDataSource* identification_source) {
_p_identification_source = identification_source;
}
......@@ -79,3 +92,7 @@ unsigned int PeptideMatch::getCharge() const {
pappso::PeptideSp PeptideMatch::getPeptideSp() const {
return _peptide_sp;
}
const pappso::MsRunIdSp & PeptideMatch::getMsRunIdSp() const {
return _msrunid_sp;
}
\ No newline at end of file
......@@ -27,6 +27,7 @@
#include <pappsomspp/types.h>
#include <pappsomspp/peptide/peptide.h>
#include "identification_sources/identificationdatasource.h"
#include "automaticfilterparameters.h"
class PeptideMatch
{
......@@ -42,7 +43,10 @@ public :
void setIdentificationDataSource(IdentificationDataSource* identification_source);
void setChecked(bool arg1);
bool isChecked() const;
bool isValid() const;
bool isValidAndChecked() const;
const pappso::MsRunIdSp & getMsRunIdSp() const;
IdentificationDataSource* getIdentificationDataSource () const;
unsigned int getScan() const;
pappso::pappso_double getRetentionTime() const;
......@@ -50,6 +54,10 @@ public :
pappso::PeptideSp getPeptideSp() const;
pappso::pappso_double getEvalue() const;
/** @brief validate or invalidate peptides and proteins based automatic filters and manual checks
* */
void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters);
private :
pappso::MsRunIdSp _msrunid_sp;
unsigned int _scan;
......
......@@ -39,7 +39,12 @@ Project::~Project()
}
}
void Project::updateAutomaticFilters() {
void Project::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
_automatic_filter_parameters = automatic_filter_parameters;
for (auto & p_id_group : _identification_goup_list) {
p_id_group->updateAutomaticFilters(_automatic_filter_parameters);
}
}
ProjectSp Project::makeProjectSp() const {
return std::make_shared<Project>(*this);
......@@ -83,17 +88,3 @@ void Project::readXpipFile(QFileInfo xpip_fileinfo) {
IdentificationGroup* Project::getCurrentIdentificationGroupP() const {
return _p_current_identification_group;
}
bool Project::isValid(PeptideMatch* p_peptide_match) const {
if (p_peptide_match->getEvalue() > _filter_minimum_peptide_evalue) {
return false;
}
return true;
}
bool Project::isValid(ProteinMatch* p_protein_match) const {
if (p_protein_match->getEvalue() > _filter_minimum_protein_evalue) {
return false;
}
return true;
}
......@@ -33,9 +33,8 @@ typedef std::shared_ptr<Project> ProjectSp;
class PeptideMatch;
class ProteinMatch;
class Project : public QObject
class Project
{
Q_OBJECT
public:
Project();
~Project();
......@@ -44,22 +43,11 @@ public:
void readXpipFile(QFileInfo xpip_source);
IdentificationGroup* newIdentificationGroup();
IdentificationGroup* getCurrentIdentificationGroupP() const;
/** @brief is it valid regarding threshold and project rules
*/
bool isValid(PeptideMatch* p_peptide_match) const;
/** @brief is it valid regarding threshold and project rules
*/
bool isValid(ProteinMatch* p_protein_match) const;
/** @brief validate or invalidate peptides and proteins based automatic filters and manual checks
* */
void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters);
signals:
/** @brief signal when automatic filters are applied and project is ready
* */
void projectReady();
private :
std::vector<IdentificationGroup *> _identification_goup_list;
......
......@@ -22,6 +22,7 @@
******************************************************************************/
#include "proteinmatch.h"
#include <pappsomspp/msrun/msrunid.h>
ProteinMatch::ProteinMatch()
......@@ -38,6 +39,37 @@ ProteinMatch::~ProteinMatch()
}
}
void ProteinMatch::updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters) {
_proxy_valid = false;
unsigned int _number_of_valid_peptides =0;
std::map<const pappso::MsRunId*, unsigned int> _count_per_msrun;
bool cross_sample = automatic_filter_parameters.getFilterCrossSamplePeptideNumber();
for (auto & p_peptide_match : _peptide_match_list) {
p_peptide_match->updateAutomaticFilters(automatic_filter_parameters);
//count valid and checked peptides :
if (p_peptide_match->isValidAndChecked()) {
if (cross_sample) {
_number_of_valid_peptides++;
}
else {
std::pair<std::map<const pappso::MsRunId*, unsigned int>::iterator,bool> ret = _count_per_msrun.insert(std::pair<const pappso::MsRunId*, unsigned int>(p_peptide_match->getMsRunIdSp().get(),0));
ret.first->second +=1;
if (ret.first->second > _number_of_valid_peptides) {
_number_of_valid_peptides = ret.first->second;
}
}
}
}
if (_number_of_valid_peptides >= automatic_filter_parameters.getFilterMinimumPeptidePerMatch()) {
if (_evalue <= automatic_filter_parameters.getFilterProteinEvalue()) {
_proxy_valid = true;
}
}
}
const pappso::ProteinSp & ProteinMatch::getProteinSp() const {
return _protein_sp;
}
......@@ -52,9 +84,18 @@ void ProteinMatch::setProteinSp(pappso::ProteinSp protein_sp) {
_protein_sp = protein_sp;
}
bool ProteinMatch::isValid() const {
return _proxy_valid;
}
bool ProteinMatch::isChecked() const {
return _checked;
}
bool ProteinMatch::isValidAndChecked() const{
return _proxy_valid && _checked;
}
void ProteinMatch::setChecked(bool arg1) {
_checked = arg1;
}
......
......@@ -28,6 +28,7 @@
#include <pappsomspp/types.h>
#include <pappsomspp/protein/protein.h>
#include "peptidematch.h"
#include "automaticfilterparameters.h"
class ProteinMatch
{
......@@ -42,7 +43,15 @@ public:
void addPeptideMatch(PeptideMatch * peptide_match);
std::vector<PeptideMatch *> & getPeptideMatchList();
void setChecked(bool arg1);
bool isChecked() const;
bool isValid() const;
bool isValidAndChecked() const;
/** @brief validate or invalidate peptides and proteins based automatic filters and manual checks
* */
void updateAutomaticFilters(const AutomaticFilterParameters & automatic_filter_parameters);
private:
std::vector<PeptideMatch *> _peptide_match_list;
pappso::ProteinSp _protein_sp = nullptr;
......
......@@ -191,7 +191,7 @@ void PeptideTableModel::onTableClicked(const QModelIndex &index)
}
bool PeptideTableModel::acceptRow(int source_row) {
if (_p_project->isValid(_p_protein_match->getPeptideMatchList().at(source_row))) {
if (_p_protein_match->getPeptideMatchList().at(source_row)->isValid()) {
return true;
}
return false;
......
......@@ -223,7 +223,7 @@ bool ProteinTableModel::acceptRow(int source_row) {
return false;
}
}
if (_p_identification_group->isValid(protein_match)) {
if (protein_match->isValid()) {
return true;
}
return false;
......
......@@ -134,12 +134,12 @@ bool XpipSaxHandler::startElement_filter_params(QXmlAttributes attributes) {
//<filter_params pep_evalue="0.01" prot_evalue="-2.0" pep_number="1" filter_to_all="false" database_filter="contaminants_standarts.fasta"/>
qDebug() << "startElement_filter_params ";
_p_project->setFilterPeptideEvalue( attributes.value("pep_evalue").simplified().toDouble());
_p_project->setFilterProteinEvalue( std::pow ((double) 10.0,attributes.value("prot_evalue").simplified().toDouble()));
_p_project->setFilterMinimumPeptidePerMatch( attributes.value("pep_number").simplified().toUInt());
_p_project->setFilterCrossSamplePeptideNumber(false);
_automatic_filter_parameters.setFilterPeptideEvalue( attributes.value("pep_evalue").simplified().toDouble());
_automatic_filter_parameters.setFilterProteinEvalue( std::pow ((double) 10.0,attributes.value("prot_evalue").simplified().toDouble()));
_automatic_filter_parameters.setFilterMinimumPeptidePerMatch( attributes.value("pep_number").simplified().toUInt());
_automatic_filter_parameters.setFilterCrossSamplePeptideNumber(false);
if (attributes.value("filter_to_all").simplified() == "true") {
_p_project->setFilterCrossSamplePeptideNumber(true);
_automatic_filter_parameters.setFilterCrossSamplePeptideNumber(true);
}
qDebug() << "startElement_filter_params end" ;
return true;
......@@ -331,6 +331,7 @@ QString XpipSaxHandler::errorString() const {
bool XpipSaxHandler::endDocument() {
_p_project->updateAutomaticFilters(_automatic_filter_parameters);
return true;
}
......
......@@ -78,6 +78,7 @@ private:
std::vector<QString> _tag_stack;
QString _errorStr;
QString _current_text;
AutomaticFilterParameters _automatic_filter_parameters;
Project * _p_project;
ProteinMatch * _p_protein_match;
......
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