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