Commit 57e1b627 authored by Edlira Nano's avatar Edlira Nano
Browse files

cleaning up for new relese

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2257 e4b6dbb4-9209-464b-83f7-6257456c460c
parent 541c8b6f
...@@ -127,36 +127,36 @@ SET(VIEWXIC_MOC_HDRS ...@@ -127,36 +127,36 @@ SET(VIEWXIC_MOC_HDRS
./qtquanti/choose_mz_precision_widget.h ./qtquanti/choose_mz_precision_widget.h
) )
SET(GUI_SRCS # SET(GUI_SRCS
./gui/mainwindow.cpp # ./gui/mainwindow.cpp
./gui/masschroq_gui.cpp # ./gui/masschroq_gui.cpp
./gui/xicSelectionWidget.cpp # ./gui/xicSelectionWidget.cpp
./gui/filterBackgroundWidget.cpp # ./gui/filterBackgroundWidget.cpp
./gui/plotStyle.cpp # ./gui/plotStyle.cpp
./gui/xicProfile.cpp # ./gui/xicProfile.cpp
./gui/xicPlot.cpp # ./gui/xicPlot.cpp
./gui/plot.cpp # ./gui/plot.cpp
./gui/mcqThread.cpp # ./gui/mcqThread.cpp
./gui/msrunLoaderThread.cpp # ./gui/msrunLoaderThread.cpp
./gui/runningBarr.cpp # ./gui/runningBarr.cpp
) # )
# another list, this time it includes all header files that should be treated with moc # # another list, this time it includes all header files that should be treated with moc
SET(GUI_MOC_HDRS # SET(GUI_MOC_HDRS
./gui/mainwindow.h # ./gui/mainwindow.h
./gui/xicSelectionWidget.h # ./gui/xicSelectionWidget.h
./gui/filterBackgroundWidget.h # ./gui/filterBackgroundWidget.h
./gui/xicProfile.h # ./gui/xicProfile.h
./gui/plot.h # ./gui/plot.h
./gui/mcqThread.h # ./gui/mcqThread.h
./gui/msrunLoaderThread.h # ./gui/msrunLoaderThread.h
./gui/runningBarr.h # ./gui/runningBarr.h
) # )
set(CMAKE_MODULE_PATH ${masschroq_SOURCE_DIR}/modules) set(CMAKE_MODULE_PATH ${masschroq_SOURCE_DIR}/modules)
set(Qwt5_DIR ${masschroq_SOURCE_DIR}/Modules) # set(Qwt5_DIR ${masschroq_SOURCE_DIR}/Modules)
FIND_PACKAGE(Qwt5 REQUIRED) # FIND_PACKAGE(Qwt5 REQUIRED)
# this command will generate rules that will run rcc on all files from SAMPLE_RCS # this command will generate rules that will run rcc on all files from SAMPLE_RCS
...@@ -168,14 +168,13 @@ FIND_PACKAGE(Qwt5 REQUIRED) ...@@ -168,14 +168,13 @@ FIND_PACKAGE(Qwt5 REQUIRED)
# and finally this will run moc: # and finally this will run moc:
QT4_WRAP_CPP( VIEWXIC_MOC_SRCS ${VIEWXIC_MOC_HDRS} ) # QT4_WRAP_CPP( VIEWXIC_MOC_SRCS ${VIEWXIC_MOC_HDRS} )
# QT4_WRAP_CPP( GUI_MOC_SRCS ${GUI_MOC_HDRS} )
QT4_WRAP_CPP( GUI_MOC_SRCS ${GUI_MOC_HDRS} )
# we need this to be able to include headers produced by uic in our code # we need this to be able to include headers produced by uic in our code
# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake) # (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake)
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${Qwt5_INCLUDE_DIR}) # INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ${Qwt5_INCLUDE_DIR})
IF (WIN32) IF (WIN32)
...@@ -209,11 +208,11 @@ INSTALL(TARGETS ${MASSCHROQ_LIB_NAME} LIBRARY DESTINATION lib) ...@@ -209,11 +208,11 @@ INSTALL(TARGETS ${MASSCHROQ_LIB_NAME} LIBRARY DESTINATION lib)
# if lib quanti is graphical # if lib quanti is graphical
#TARGET_LINK_LIBRARIES(masschroq libmasschroq ${QT_LIBRARIES} ${Qwt5_Qt4_LIBRARY}) #TARGET_LINK_LIBRARIES(masschroq libmasschroq ${QT_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
ADD_EXECUTABLE(viewxic qtquanti/viewxic.cpp ${VIEWXIC_SRCS} ${VIEWXIC_MOC_SRCS}) # ADD_EXECUTABLE(viewxic qtquanti/viewxic.cpp ${VIEWXIC_SRCS} ${VIEWXIC_MOC_SRCS})
TARGET_LINK_LIBRARIES(viewxic ${MASSCHROQ_LIB_NAME} ${QT_LIBRARIES} ${Qwt5_Qt4_LIBRARY}) # TARGET_LINK_LIBRARIES(viewxic ${MASSCHROQ_LIB_NAME} ${QT_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
ADD_EXECUTABLE(mcq_gui gui/gui.cpp ${GUI_SRCS} ${GUI_MOC_SRCS}) # ADD_EXECUTABLE(mcq_gui gui/gui.cpp ${GUI_SRCS} ${GUI_MOC_SRCS})
TARGET_LINK_LIBRARIES(mcq_gui ${MASSCHROQ_LIB_NAME} ${QT_LIBRARIES} ${Qwt5_Qt4_LIBRARY}) # TARGET_LINK_LIBRARIES(mcq_gui ${MASSCHROQ_LIB_NAME} ${QT_LIBRARIES} ${Qwt5_Qt4_LIBRARY})
#ADD_EXECUTABLE(visualqms visualqms.cpp ${VIEWXIC_SRCS} ${VIEWXIC_MOC_SRCS} ${SAXLIB_SRCS} ${OBWARP_SRCS}) #ADD_EXECUTABLE(visualqms visualqms.cpp ${VIEWXIC_SRCS} ${VIEWXIC_MOC_SRCS} ${SAXLIB_SRCS} ${OBWARP_SRCS})
......
...@@ -14,295 +14,318 @@ ...@@ -14,295 +14,318 @@
#include <QStringList> #include <QStringList>
#include <algorithm> #include <algorithm>
Quantificator::Quantificator(const QString & xml_id, const msRunHashGroup * quanti_group, Quantificator::Quantificator(const QString & xml_id,
QuantificationMethod * quanti_method) const msRunHashGroup * quanti_group,
: QuantificationMethod * quanti_method)
_xml_id(xml_id) :
_xml_id(xml_id)
{ {
set_quanti_group(quanti_group); set_quanti_group(quanti_group);
set_quanti_method(quanti_method); set_quanti_method(quanti_method);
_quanti_items = new std::vector<QuantiItemBase *>; _quanti_items = new std::vector<QuantiItemBase *>;
const mcq_double coeff_match_range = const mcq_double coeff_match_range =
(_quanti_method->getDetectionMethod())->get_coeff_detect_range(); (_quanti_method->getDetectionMethod())->get_coeff_detect_range();
_peak_matcher = new PeakMatcher(coeff_match_range); _peak_matcher = new PeakMatcher(coeff_match_range);
} }
Quantificator::~Quantificator() { Quantificator::~Quantificator() {
std::vector<QuantiItemBase *>::iterator it; std::vector<QuantiItemBase *>::iterator it;
for (it = _quanti_items->begin(); for (it = _quanti_items->begin();
it != _quanti_items->end(); it != _quanti_items->end();
++it) { ++it)
if (*it != 0) { {
delete (*it); if (*it != 0)
*it = 0; {
} delete (*it);
} *it = 0;
}
}
if (_quanti_items != 0) { if (_quanti_items != 0)
delete _quanti_items; {
_quanti_items = 0; delete _quanti_items;
} _quanti_items = 0;
}
if (_peak_matcher != 0) { if (_peak_matcher != 0)
delete _peak_matcher; {
_peak_matcher = 0; delete _peak_matcher;
} _peak_matcher = 0;
}
} }
void void
Quantificator::set_quanti_group(const msRunHashGroup * quanti_group) { Quantificator::set_quanti_group(const msRunHashGroup * quanti_group)
_group_to_quantify = quanti_group; {
_group_to_quantify = quanti_group;
} }
void void
Quantificator::set_quanti_method(QuantificationMethod * quanti_method) { Quantificator::set_quanti_method(QuantificationMethod * quanti_method)
_quanti_method = quanti_method; {
_quanti_method = quanti_method;
} }
void void
Quantificator::set_matching_mode(const mcq_matching_mode & match_mode) { Quantificator::set_matching_mode(const mcq_matching_mode & match_mode)
_peak_matcher->set_matching_mode(match_mode); {
_peak_matcher->set_matching_mode(match_mode);
} }
const QString & const QString &
Quantificator::get_quanti_group_id() const { Quantificator::get_quanti_group_id() const
return (_group_to_quantify->getXmlId()); {
return (_group_to_quantify->getXmlId());
} }
void void
Quantificator::add_peptide_quanti_items(vector<const Peptide *> & isotope_peptides) { Quantificator::add_peptide_quanti_items(vector<const Peptide *> & isotope_peptides)
{
XicExtractionMethodBase * extraction_method = XicExtractionMethodBase * extraction_method =
_quanti_method->getXicExtractionMethod(); _quanti_method->getXicExtractionMethod();
QuantiItemBase * quanti_item; QuantiItemBase * quanti_item;
vector<const Peptide *>::const_iterator itpep; vector<const Peptide *>::const_iterator itpep;
/// for each peptide (or isotope in the vector), we will create a peptide quanti item /// for each peptide (or isotope in the vector), we will create a peptide quanti item
for (itpep = isotope_peptides.begin(); for (itpep = isotope_peptides.begin();
itpep != isotope_peptides.end(); itpep != isotope_peptides.end();
++itpep) { ++itpep)
{
/// get the set of charges z the peptide is observed in the current group, /// get the set of charges z the peptide is observed in the current group,
/// and construct a quantification item for each peptide/z /// and construct a quantification item for each peptide/z
std::set<unsigned int> * s_charges = (*itpep)->getCharges(*_group_to_quantify); std::set<unsigned int> * s_charges = (*itpep)->getCharges(*_group_to_quantify);
// for each z do // for each z do
std::set<unsigned int>::const_iterator itz; std::set<unsigned int>::const_iterator itz;
for (itz = s_charges->begin(); for (itz = s_charges->begin();
itz != s_charges->end(); itz != s_charges->end();
++itz) { ++itz)
/// calculate the mean bestRt for this peptide/z {
mcq_double rt((*itpep)->getMeanBestRt(*_group_to_quantify)); /// calculate the mean bestRt for this peptide/z
/// this test is not necessary here mcq_double rt((*itpep)->getMeanBestRt(*_group_to_quantify));
if (rt != -1) { /// this test is not necessary here
extraction_method->setMz((*itpep)->getMz(*itz)); if (rt != -1)
quanti_item = new QuantiItemPeptide(*extraction_method, {
extraction_method->setMz((*itpep)->getMz(*itz));
quanti_item = new QuantiItemPeptide(*extraction_method,
*itpep, *itpep,
*itz, *itz,
*_group_to_quantify, *_group_to_quantify,
_peak_matcher->get_match_mode()); _peak_matcher->get_match_mode());
_quanti_items->push_back(quanti_item); _quanti_items->push_back(quanti_item);
} }
} }
delete (s_charges); delete (s_charges);
} }
} }
void void
Quantificator::add_mz_quanti_items(const QStringList & mz_list) { Quantificator::add_mz_quanti_items(const QStringList & mz_list)
{
XicExtractionMethodBase * extraction_method = XicExtractionMethodBase * extraction_method =
_quanti_method->getXicExtractionMethod(); _quanti_method->getXicExtractionMethod();
QuantiItemBase * quanti_item; QuantiItemBase * quanti_item;
QStringList::const_iterator it; QStringList::const_iterator it;
for (it = mz_list.begin(); it != mz_list.end(); ++it) { for (it = mz_list.begin(); it != mz_list.end(); ++it)
{
extraction_method->setMz(it->toDouble()); extraction_method->setMz(it->toDouble());
quanti_item = new QuantiItemBase(*extraction_method); quanti_item = new QuantiItemBase(*extraction_method);
_quanti_items->push_back(quanti_item); _quanti_items->push_back(quanti_item);
} }
} }
void void
Quantificator::add_mzrt_quanti_item(const QString & mz, const QString & rt) { Quantificator::add_mzrt_quanti_item(const QString & mz, const QString & rt)
{
XicExtractionMethodBase * extraction_method = XicExtractionMethodBase * extraction_method =
_quanti_method->getXicExtractionMethod(); _quanti_method->getXicExtractionMethod();
extraction_method->setMz(mz.toDouble()); extraction_method->setMz(mz.toDouble());
QuantiItemBase * quanti_item = QuantiItemBase * quanti_item =
new QuantiItemMzRt(*extraction_method, new QuantiItemMzRt(*extraction_method,
rt.toDouble()); rt.toDouble());
_quanti_items->push_back(quanti_item); _quanti_items->push_back(quanti_item);
} }
void void
Quantificator::setMonitor(MonitorBase * monitor) { Quantificator::setMonitor(MonitorBase * monitor)
_monitor = monitor; {
_monitor = monitor;
} }
struct CmpQuantiItems { struct CmpQuantiItems
bool operator() (const QuantiItemBase * l1, const QuantiItemBase * l2) { {
const mcq_double mz1 = l1->get_mz(); bool operator() (const QuantiItemBase * l1, const QuantiItemBase * l2)
const mcq_double mz2 = l2->get_mz(); {
return (mz1 < mz2); const mcq_double mz1 = l1->get_mz();
} const mcq_double mz2 = l2->get_mz();
return (mz1 < mz2);
}
} QuantiItemsCmp; } QuantiItemsCmp;
void void
Quantificator::sortQuantiItems() { Quantificator::sortQuantiItems()
sort(_quanti_items->begin(), _quanti_items->end(), QuantiItemsCmp); {
sort(_quanti_items->begin(), _quanti_items->end(), QuantiItemsCmp);
} }
void void
Quantificator::quantify() { Quantificator::quantify()
{
sortQuantiItems(); sortQuantiItems();
QString group_id = _group_to_quantify->getXmlId(); QString group_id = _group_to_quantify->getXmlId();
QString quanti_method_id = _quanti_method->getXmlId(); QString quanti_method_id = _quanti_method->getXmlId();
XicExtractionMethodBase * xic_extraction_method = _quanti_method->getXicExtractionMethod(); XicExtractionMethodBase * xic_extraction_method = _quanti_method->getXicExtractionMethod();
const mcq_xic_type xic_type = _quanti_method->getXicType(); const mcq_xic_type xic_type = _quanti_method->getXicType();
const vector<const filterBase *> xic_filters = _quanti_method->getXicFilters(); const vector<const filterBase *> xic_filters = _quanti_method->getXicFilters();
peakDetectionBase * detection_method = _quanti_method->getDetectionMethod(); peakDetectionBase * detection_method = _quanti_method->getDetectionMethod();
const peakExtractor * peak_extractor = new peakExtractor(detection_method); const peakExtractor * peak_extractor = new peakExtractor(detection_method);
cout << "MS run group '" << group_id.toStdString() cout << "MS run group '" << group_id.toStdString()
<< "': quantification method '" << quanti_method_id.toStdString() << "': quantification method '" << quanti_method_id.toStdString()
<< "': quantification begin" << endl; << "': quantification begin" << endl;
_quanti_method->printInfos(cout); _quanti_method->printInfos(cout);
_monitor->setCurrentQuantify(_xml_id); _monitor->setCurrentQuantify(_xml_id);
_monitor->setCurrentGroup(_group_to_quantify); _monitor->setCurrentGroup(_group_to_quantify);
// launch quantification in group // launch quantification in group
Msrun * current_msrun; Msrun * current_msrun;
msRunHashGroup::const_iterator itmsrun; msRunHashGroup::const_iterator itmsrun;
unsigned int count_msruns(1); unsigned int count_msruns(1);
QuantiItemBase * current_mz; QuantiItemBase * current_mz;
vector<QuantiItemBase *>::const_iterator itmz; vector<QuantiItemBase *>::const_iterator itmz;
xicBase * current_xic; xicBase * current_xic;
unsigned int quanti_items_size = _quanti_items->size(); unsigned int quanti_items_size = _quanti_items->size();
for (itmsrun = _group_to_quantify->begin(); for (itmsrun = _group_to_quantify->begin();
itmsrun != _group_to_quantify->end(); itmsrun != _group_to_quantify->end();
++itmsrun, ++count_msruns) ++itmsrun, ++count_msruns)
{ {
current_msrun = itmsrun->second; current_msrun = itmsrun->second;
cout << "\tQuantifying in MS run '" cout << "\tQuantifying in MS run '"
<< (current_msrun->getXmlId()).toStdString() << (current_msrun->getXmlId()).toStdString()
<< "' : " << count_msruns << "/" << _group_to_quantify->size() << "' : " << count_msruns << "/" << _group_to_quantify->size()
<< " in group '" << group_id.toStdString() << " in group '" << group_id.toStdString()
<< "'" << endl; << "'" << endl;
_monitor->setCurrentMsrun(current_msrun); _monitor->setCurrentMsrun(current_msrun);
current_msrun->prepareSpectraForQuantification(xic_extraction_method); current_msrun->prepareSpectraForQuantification(xic_extraction_method);
int count_xic(1); int count_xic(1);
for (itmz = _quanti_items->begin(); for (itmz = _quanti_items->begin();
itmz != _quanti_items->end(); itmz != _quanti_items->end();
++itmz, ++count_xic) ++itmz, ++count_xic)
{ {
cout << "\r\t\textracting XIC and detecting peaks on XIC " cout << "\r\t\textracting XIC and detecting peaks on XIC "
<< count_xic << "/" << quanti_items_size; << count_xic << "/" << quanti_items_size;
current_mz = *itmz; current_mz = *itmz;
_monitor->setCurrentSearchItem(current_mz); _monitor->setCurrentSearchItem(current_mz);
current_xic = current_msrun->extractXic(xic_type, current_mz); current_xic = current_msrun->extractXic(xic_type, current_mz);
if (current_xic == 0) { if (current_xic == 0)
qDebug() << "detectAndQuantify null xic "; qDebug() << "detectAndQuantify null xic ";
}
current_xic->setMonitor(*_monitor); current_xic->setMonitor(*_monitor);
_monitor->setXic(current_xic); _monitor->setXic(current_xic);
// apply filters to the extracted Xic // apply filters to the extracted Xic
// monitor is passed to Xic class which calls // monitor is passed to Xic class which calls
// monitor.setFilteredXics() method // monitor.setFilteredXics() method
current_xic->applyFilters(xic_filters); current_xic->applyFilters(xic_filters);
// extract all peaks from xic // extract all peaks from xic
vector<xicPeak *> * all_peaks_list = vector<xicPeak *> * all_peaks_list =
peak_extractor->newAllPeaksList(current_xic); peak_extractor->newAllPeaksList(current_xic);
_monitor->setAllPeaks(all_peaks_list); _monitor->setAllPeaks(all_peaks_list);
delete (current_xic); delete (current_xic);
// match the peaks // match the peaks
vector<xicPeak *> * matched_peak_list = vector<xicPeak *> * matched_peak_list =
_peak_matcher->newMatchedPeaks(current_mz, all_peaks_list, current_msrun); _peak_matcher->newMatchedPeaks(current_mz, all_peaks_list, current_msrun);
_monitor->setMatchedPeaks(matched_peak_list); _monitor->setMatchedPeaks(matched_peak_list);
_monitor->setEndCurrentSearchItem(); _monitor->setEndCurrentSearchItem();
// clean up // clean up
if (matched_peak_list != 0) { if (matched_peak_list != 0)
delete matched_peak_list; {
matched_peak_list = 0; delete matched_peak_list;
} matched_peak_list = 0;
} }
cout << endl; }
current_msrun->doneWithSpectra(); cout << endl;
_monitor->setEndCurrentMsrun(); current_msrun->doneWithSpectra();
_monitor->setEndCurrentMsrun();
} }
delete (peak_extractor); delete (peak_extractor);
cout << "MS run group '" << group_id.toStdString() cout << "MS run group '" << group_id.toStdString()
<< "': quantification method '" << quanti_method_id.toStdString() << "': quantification method '" << quanti_method_id.toStdString()
<< "': quantification finished" << endl; << "': quantification finished" << endl;
cout << "MS run group '" << group_id.toStdString() performPostMatching();
<< "': post matching begin" << endl; _monitor->setEndCurrentGroup();
performPostMatching();
_monitor->setEndCurrentGroup();
} }
void void
Quantificator::performPostMatching() { Quantificator::performPostMatching()
if (_peak_matcher->isPostMatchingRequired()) { {
_monitor->setPostMatchingOn(); if (_peak_matcher->isPostMatchingRequired())
QString group_id = _group_to_quantify->getXmlId(); {
vector<QuantiItemBase *>::const_iterator itmz; QString group_id = _group_to_quantify->getXmlId();
Msrun * current_msrun; cout << "MS run group '" << group_id.toStdString()
unsigned int count_msruns<