Commit 65d2315f authored by Edlira Nano's avatar Edlira Nano
Browse files

loaded entire msRUN (simple + spectra) at once in the beginning: completes task id 3267

git-svn-id: https://subversion.renater.fr/masschroq/trunk@2249 e4b6dbb4-9209-464b-83f7-6257456c460c
parent 79eb1427
......@@ -2,6 +2,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QDockWidget>
#include <QStatusBar>
#include "mainwindow.h"
#include "xicSelectionWidget.h"
......@@ -15,7 +16,7 @@ MainWindow::MainWindow(QWidget *parent)
QMainWindow(parent)
{
_masschroq_gui = new MasschroqGui();
_masschroq_gui = new MasschroqGui(this);
// Central Widget
......@@ -32,9 +33,13 @@ MainWindow::MainWindow(QWidget *parent)
createActions();
createMenus();
//createToolBars();
//createStatusBar();
createStatusBar();
}
void
MainWindow::createStatusBar() {
statusBar()->showMessage(tr("Ready"));
}
void
MainWindow::createMenus() {
......@@ -58,7 +63,7 @@ void
MainWindow::createActions() {
_loadMsrunAct = new QAction(tr("&Load MS-run"), this);
_loadMsrunAct->setShortcuts(QKeySequence::Open);
_loadMsrunAct->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_L));
_loadMsrunAct->setStatusTip(tr("Load an MS-run file"));
connect(_loadMsrunAct, SIGNAL(triggered()), this, SLOT(loadMsrun()));
......@@ -94,8 +99,6 @@ MainWindow::loadMsrun() {
_current_msrun_file = filename;
_masschroq_gui->setMsRun(filename);
}
cout << "end loading" << endl;
}
void
......@@ -133,4 +136,15 @@ void MainWindow::about() {
tr("This is <b>MassChroQ GUI</b> version beta."));
}
void MainWindow::setPlotAreaTitle(const QString & filename) {
_plot_area->setWindowFilePath(filename);
QString title("Xic plots : ");
title.append(strippedFilename(filename));
_plot_area->setTitle(title);
}
QString
MainWindow::strippedFilename(const QString & fullFilename) {
return QFileInfo(fullFilename).fileName();
}
......@@ -13,6 +13,8 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget * parent = 0);
void setPlotAreaTitle(const QString & filename);
private slots:
......@@ -33,10 +35,11 @@ private:
void createActions();
void createMenus();
//createToolbars();
//createStatusBar();
//createDockWindows();
void createStatusBar();
//void createDockWindows();
//void createToolbars();
QString strippedFilename(const QString & fullFilename);
//QListWidget * filtersList;
//QListWidget * quantiItemsList;
......
......@@ -6,6 +6,7 @@
#include "masschroq_gui.h"
#include "mainwindow.h"
#include "xicProfile.h"
#include "xicSelectionWidget.h"
#include "../lib/mcq_error.h"
......@@ -15,17 +16,21 @@
#include "../lib/quanti_items/quantiItemMzRt.h"
#include "../lib/xic/xic_base.h"
#include <QMessageBox>
#include <QStatusBar>
#include <math.h>
MasschroqGui::MasschroqGui() {
MasschroqGui::MasschroqGui(MainWindow * mainwindow)
:
_mainwindow(mainwindow)
{
}
MasschroqGui::~MasschroqGui() {
}
void
MasschroqGui::setMsRun(const QString & filename) {
QFileInfo filenameInfo(filename);
......@@ -57,45 +62,40 @@ MasschroqGui::setMsRun(const QString & filename) {
msgBox.exec();
return;
}
mcq_double size_in_bytes = filenameInfo.size();
Msrun * msrun;
if (size_in_bytes < MAX_SLICE_SIZE ) {
try {
MsrunClassic * msrun = new MsrunClassic(filename);
cout << "MS run classic '"
<< filename.toStdString()
<< "' : parsing begin" << endl;
msrun->set_from_xml(filename, format);
this->addMsRun(filename, msrun);
_current_loaded_msrun = msrun;
} catch (mcqError error) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("Problem loading MS run '%1':\n%2").arg(filename, error.what()));
msgBox.exec();
return;
}
msrun = new MsrunClassic(filename);
cout << "MS run classic '"
<< filename.toStdString()
<< "' : parsing begin" << endl;
} else {
mcq_double nb_of_slices_double = ceil(size_in_bytes/MAX_SLICE_SIZE);
int nb_of_slices = static_cast<int> (nb_of_slices_double);
try {
MsrunSliced * msrun = new MsrunSliced(filename, nb_of_slices);
cout << "MS run sliced '"
<< filename.toStdString()
<< "', number of slices " << nb_of_slices
<<", : parsing begin" << endl;
msrun->set_from_xml(filename, format);
this->addMsRun(filename, msrun);
_current_loaded_msrun = msrun;
} catch (mcqError error) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("Problem loading MS run '%1':\n%2").arg(filename, error.what()));
msgBox.exec();
return;
}
msrun = new MsrunSliced(filename, nb_of_slices);
cout << "MS run sliced '"
<< filename.toStdString()
<< "', number of slices " << nb_of_slices
<<", : parsing begin" << endl;
}
try {
msrun->set_from_xml(filename, format);
this->addMsRun(filename, msrun);
_current_loaded_msrun = msrun;
// Parsing of Msrun spectra
msrun->prepareSpectraForQuantification(NULL);
_mainwindow->statusBar()->showMessage(QObject::tr("MS run '%1' loaded").arg(filename), 4000);
_mainwindow->setPlotAreaTitle(filename);
} catch (mcqError error) {
QMessageBox msgBox;
msgBox.setIcon(QMessageBox::Critical);
msgBox.setText(QObject::tr("Problem loading MS run '%1':\n%2").arg(filename, error.what()));
msgBox.exec();
return;
}
}
void
......@@ -150,7 +150,6 @@ MasschroqGui::extractXicProfile(XicProfile * xic_profile,
}
// extract XIC
msrun->prepareSpectraForQuantification(extraction_method);
xicBase * current_xic = msrun->extractXic(xic_type, quanti_item);
if (current_xic == 0) {
qDebug() << "MsrunSelectionXic null xic ";
......@@ -160,5 +159,4 @@ MasschroqGui::extractXicProfile(XicProfile * xic_profile,
*(current_xic->getIntensities()) );
delete (current_xic);
msrun->doneWithSpectra();
}
......@@ -40,6 +40,7 @@
class XicProfile;
class XicSelectionWidget;
class MainWindow;
/**
* \class MasschroqGui
......@@ -50,7 +51,7 @@ class MasschroqGui {
public:
MasschroqGui();
MasschroqGui(MainWindow * mainwindow);
virtual ~MasschroqGui();
/// creates and sets an msrun
......@@ -68,8 +69,9 @@ class MasschroqGui {
std::map<QString, Msrun *> _msrun_map;
Msrun * _current_loaded_msrun;
MainWindow * _mainwindow;
};
#endif /* MASSCHROQ_GUI_H_ */
......@@ -28,6 +28,7 @@
#define XIC_SELECTION_WIDGET_H_ 1
#include "../mcq_types.h"
#include <QWidget>
class QButtonGroup;
class QGroupBox;
......@@ -35,7 +36,6 @@ class QDialogButtonBox;
class QAbstractButton;
class XicExtractionMethodBase;
/**
* \class XicSelectionWidget
* \brief Xic Selection Widget
......
......@@ -102,6 +102,9 @@ MasschroqWriter::writeInputParameters() {
if (name =="masschroq") {
QString mcq_xml_version(MASSCHROQ_SCHEMA_VERSION);
_output_stream->writeAttribute("version", mcq_xml_version);
//QString type("result");
// _output_stream->writeAttribute("type", type);
}
}
else if (token == QXmlStreamReader::Comment) {
......
......@@ -32,13 +32,13 @@
/**
* \class MasschroqWriter
* \brief Xml type of output containing quantification results as well
* \brief masschroqML type of output containing quantification results as well
* as xic traces
* This type of result produces an XML file that contains the XML input file
* This type of result produces a masschroqML result file that contains the XML input file
* used to generate these results plus the quantification results and the
* xic traces produced if any. The output XML file follows the same schema as
* the input XML file.
* xic traces produced if any. The output masschroqML file follows the same schema as
* the input masschroqML file.
*/
......
......@@ -23,8 +23,7 @@ MsrunClassic::~MsrunClassic() {
this->deleteSpectra();
}
/// write the spectra of this msrun from RAM to disk
/// (temporary file _p_spectrum_cache_file)
/// delete the spectra of this msrun, we do not need it anymore
void
MsrunClassic::deleteSpectra() {
std::map<mcq_double, spectrum *>::iterator it;
......@@ -95,82 +94,3 @@ MsrunClassic::setXicVectors(xicBase * ptr_on_xic) const {
}
}
}
// void
// MsrunClassic::priv_quantify(QuantificationMethod * quantification_method,
// PeakMatcher * peak_matcher,
// const vector<const QuantiItemBase *> * v_mass_to_look_for,
// MonitorBase & monitors) {
// cout << "\tparsing spectra in MSrun " << _xml_id.toStdString() << endl;
// prepareSpectraForQuantification();
// const QuantiItemBase * current_mz;
// vector<const QuantiItemBase *>::const_iterator itmz;
// const QString xic_type = quantification_method->getXicType();
// const vector<const filterBase *> xic_filters = quantification_method->getXicFilters();
// xicBase * current_xic;
// peakDetectionBase * detection_method = quantification_method->getDetectionMethod();
// const peakExtractor * p_extract_peaks = new peakExtractor(detection_method);
// unsigned int v_mass_size = v_mass_to_look_for->size();
// //for each mass :
// int count_xic(1);
// for (itmz = v_mass_to_look_for->begin();
// itmz != v_mass_to_look_for->end();
// ++itmz, ++count_xic)
// {
// cout << "\r\t\textracting XIC and detecting peaks on XIC "
// << count_xic << "/" << v_mass_size;
// current_mz = *itmz;
// monitors.setCurrentSearchItem(current_mz);
// // extract XIC for this msrun and this mz
// current_xic = this->extractXic(xic_type, current_mz);
// if (current_xic == NULL) {
// qDebug() << "detectAndQuantify null xic ";
// }
// // set this xic's monitor
// current_xic->setMonitor(monitors);
// // set this xic in the monitor
// monitors.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 = p_extract_peaks->newAllPeaksList(current_xic);
// monitors.setAllPeaks(all_peaks_list);
// delete (current_xic);
// // match the peaks
// vector<xicPeak *> * matched_peak_list =
// peak_matcher->newMatchedPeaks(current_mz, all_peaks_list, this);
// // set peaks in monitor
// monitors.setSelectedPeaks(matched_peak_list);
// monitors.setEndCurrentSearchItem();
// // clean up
// for (unsigned int i = 0; i < matched_peak_list->size(); i++) {
// delete matched_peak_list->at(i);
// }
// delete matched_peak_list;
// }
// cout << endl;
// delete (p_extract_peaks);
// this->deleteSpectra();
// // post matching
// peak_matcher->performPostMatching();
//}
......@@ -63,7 +63,12 @@ MsrunSliced::setSlicer(const XicExtractionMethodBase * xic_extraction_method) {
deleteSlicer();
const mcq_double min_mz = this->get_low_mz();
const mcq_double max_mz = this->get_high_mz();
const mcq_double overlap_range = xic_extraction_method->getMzRangeForMz(max_mz);
mcq_double overlap_range;
if (xic_extraction_method != NULL) {
overlap_range = xic_extraction_method->getMzRangeForMz(max_mz);
} else {
overlap_range = 5;
}
qDebug() << "initializing slicer with _nb_of_slices, low_mz, high_mz " << _nb_of_slices
<< ", " << min_mz << ", " << max_mz;
_slicer = new Slicer(_nb_of_slices, min_mz, max_mz, overlap_range);
......
......@@ -140,7 +140,6 @@ Slice::closeCache() {
void
Slice::wakeUpSpectra() {
if (this->isSleeping()) {
qDebug() << "Waking slice " << _index_id;
_is_sleeping = false;
_current_spectrum_cache_file->open();
QDataStream in(_current_spectrum_cache_file);
......@@ -150,9 +149,27 @@ Slice::wakeUpSpectra() {
}
_current_spectrum_cache_file->close();
deleteCache();
_current_spectrum_cache_file = new QTemporaryFile(_fullTmpFilename);
}
}
void
Slice::sleepSpectraOnDisk() {
if (this->isSleeping()) {
//already sleeping
} else {
_is_sleeping = true;
_current_spectrum_cache_file->open();
_current_spectrum_out_stream = new QDataStream(_current_spectrum_cache_file);
QDataStream out (_current_spectrum_cache_file);
std::vector<spectrum *>::iterator it;
for (it = _spectra_v.begin(); it != _spectra_v.end(); ++it) {
(*it)->sleepOnDisk(out);
}
_current_spectrum_cache_file->close();
}
}
void
Slice::setXicVectors(xicBase * ptr_on_xic) {
/// the rt in xics have to be in ascending order, but as we have slept spectra
......
......@@ -69,6 +69,8 @@ class Slice {
void sleep_current_spectrum(const mcq_double rt);
void wakeUpSpectra();
void sleepSpectraOnDisk();
void setCache();
......
......@@ -46,7 +46,6 @@ Slicer::setSlices() {
if (_nb_of_slices <= 0) {
throw mcqError(QObject::tr("error in msrun slicer: nonsense, the number of slices is set to %1, but it should be a positive non zero integer :)\n").arg(_nb_of_slices));
}
// qDebug() << "setSlices begin: number of slices " << _nb_of_slices;
_slices.resize(_nb_of_slices);
mcq_double slice_begin_mz(_min_mz_range);
......@@ -100,7 +99,7 @@ Slicer::compute_mz_range_per_slice() {
void
Slicer::setSpectrumInSlices(const mcq_double rt, spectrum * the_spectrum) {
/// create nb_of_slices empty spectra, one for each slice
/// create nb_of_slices empty new spectra, one for each slice
std::vector<Slice * >::iterator it_slice;
for (it_slice = _slices.begin();
it_slice != _slices.end();
......@@ -123,17 +122,15 @@ Slicer::setSpectrumInSlices(const mcq_double rt, spectrum * the_spectrum) {
(*it_slice)->putMzIntInSpectrum(*it_mz, *it_int);
}
}
/// sleep the newly created spectra (one for each slice) on disk
/// sleep the newly created spectra on disk
for (it_slice = _slices.begin();
it_slice != _slices.end();
++it_slice) {
(*it_slice)->sleep_current_spectrum(rt);
}
}
void
Slicer::closeCacheInSlices() {
std::vector<Slice * >::iterator it_slice;
......@@ -182,8 +179,8 @@ Slicer::wakeUpSliceForMz(const QuantiItemBase * quanti_item) {
return;
}
/// else we have found a new corresponding slice, but before waking it up
/// we have to sleep (clear) the old one
clearSlice(_current_waked_slice);
/// we have to sleep the old one on disk
sleepSlice(_current_waked_slice);
/// finally, wake the new slice
_current_waked_slice = slice_index;
qDebug() << "WakeUpSlice:Waking slice "<< slice_index << endl;
......@@ -191,13 +188,13 @@ Slicer::wakeUpSliceForMz(const QuantiItemBase * quanti_item) {
}
void
Slicer::clearSlice(const mcq_slice_index_id index_id) {
if (index_id < _nb_of_slices) {
Slicer::sleepSlice(const mcq_slice_index_id index_id) {
if (index_id < _nb_of_slices) {
if (index_id != NULL_SLICE_ID) {
_slices[index_id]->clear();
_slices[index_id]->sleepSpectraOnDisk();
}
} else {
throw mcqError(QObject::tr("error in msrun slicer: pfoui, this is a bug, you are trying to wakeunexisting slice index_id '%1'.\n").arg(index_id));
throw mcqError(QObject::tr("error in msrun slicer: pfoui, this is a bug, you are trying to sleep an unexisting slice index_id '%1'.\n").arg(index_id));
}
}
......@@ -208,10 +205,20 @@ Slicer::wakeUpSlice(const mcq_slice_index_id index_id) {
_slices[index_id]->wakeUpSpectra();
}
} else {
throw mcqError(QObject::tr("error in msrun slicer: pfoui, this is a bug, you are trying to wakeunexisting slice index_id '%1'.\n").arg(index_id));
throw mcqError(QObject::tr("error in msrun slicer: pfoui, this is a bug, you are trying to wake up an unexisting slice index_id '%1'.\n").arg(index_id));
}
}
void
Slicer::setXicVectors(xicBase * ptr_on_xic) const {
if ( (_current_waked_slice != NULL_SLICE_ID)
&&
(_current_waked_slice < _nb_of_slices) ) {
_slices[_current_waked_slice]->setXicVectors(ptr_on_xic);
} else {
throw mcqError(QObject::tr("error in msrun slicer: pfoui, this is a bug, the current waked slice index is -1.\n"));
}
}
void
Slicer::clearSlices() {
......@@ -224,15 +231,3 @@ Slicer::clearSlices() {
}
_current_waked_slice = NULL_SLICE_ID;
}
void
Slicer::setXicVectors(xicBase * ptr_on_xic) const {
if ( (_current_waked_slice != NULL_SLICE_ID)
&&
(_current_waked_slice < _nb_of_slices) ) {
_slices[_current_waked_slice]->setXicVectors(ptr_on_xic);
} else {
throw mcqError(QObject::tr("error in msrun slicer: pfoui, this is a bug, the current waked slice index is -1.\n"));
}
}
......@@ -58,14 +58,22 @@ class Slicer {
~Slicer();
/// Each spectrum decoded in the msrun file is divided into nb_of_slices slices of spectra
/// containing the (mz, int) portion of values allowed for each slice.
void setSpectrumInSlices(const mcq_double rt, spectrum * the_spectrum);
/// Once all the spectra decoded from the msrun file are divided into nb_of_slices
/// portion of spectra, we need to close the cache file/stream corresponding to each slice
void closeCacheInSlices();
/// Given a quanti_item, find the slice that contains teh right portion of spectra and wake up
/// its cache file (from disk to RAM)
void wakeUpSliceForMz(const QuantiItemBase * quanti_item);
/// Given an empty xic, set its data from the current waked slice
void setXicVectors(xicBase * ptr_on_xic) const;
/// Empty, clear all cache and everything in all slices, done with this slicer
void clearSlices();
private :
......@@ -77,8 +85,9 @@ class Slicer {
void setSlices();
const mcq_slice_index_id getSliceIdForMz(const QuantiItemBase * quanti_item) const;
void clearSlice(const mcq_slice_index_id index_id);
void wakeUpSlice(const mcq_slice_index_id index_id);
void sleepSlice(const mcq_slice_index_id index_id);
const int _nb_of_slices;
mcq_double _min_mz_range;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment