Skip to content

Commit

Permalink
Merge branch 'fix_mzrollSamplesUsed' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil21 committed May 16, 2018
2 parents 8796da8 + 675aaa0 commit 21e70ce
Show file tree
Hide file tree
Showing 8 changed files with 281 additions and 297 deletions.
1 change: 1 addition & 0 deletions src/core/libmaven/mzSample.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ int mzSample::filter_mslevel = 0;
mzSample::mzSample()
: _setName(""), injectionOrder(0)
{
id = 0;
maxMz = maxRt = 0;
minMz = minRt = 0;
isBlank = false;
Expand Down
1 change: 1 addition & 0 deletions src/core/libmaven/mzSample.h
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,7 @@ class mzSample

vector<float> getIntensityDistribution(int mslevel);

unsigned int id;
deque<Scan *> scans;
string sampleName;
string fileName;
Expand Down
6 changes: 3 additions & 3 deletions src/gui/mzroll/ligandwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,9 @@ void LigandWidget::readCompoundXML(QXmlStreamReader& xml, string dbname) {
rt = xml.attributes().value("rt").toString().toFloat();
charge = xml.attributes().value("Charge").toString().toInt();
formula = xml.attributes().value("Formula").toString().toStdString();
precursormz = xml.attributes().value("Precursor Mz").toString().toFloat();
productmz = xml.attributes().value("Product Mz").toString().toFloat();
collisionenergy = xml.attributes().value("Collision Energy").toString().toFloat();
precursormz = xml.attributes().value("precursorMz").toString().toFloat();
productmz = xml.attributes().value("productMz").toString().toFloat();
collisionenergy = xml.attributes().value("collisionEnergy").toString().toFloat();

while(xml.readNextStartElement()) {
if (xml.name() == "categories") {
Expand Down
7 changes: 7 additions & 0 deletions src/gui/mzroll/mzfileio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <errorcodes.h>

mzFileIO::mzFileIO(QWidget*) {
sampleId = 0;
_mainwindow = NULL;
_stopped = true;
process = NULL;
Expand Down Expand Up @@ -79,7 +80,13 @@ mzSample* mzFileIO::loadSample(QString filename){
QString sampleNumberInfo = " | Sample Number=" + QString::number(sample->sampleNumber);
sampleName = sampleName + sampleNumberInfo;
}

sample->sampleName = string( sampleName.toLatin1().data() );

mtxSampleId.lock();
sample->id = ++sampleId;
mtxSampleId.unlock();

sample->enumerateSRMScans();

//set min and max values for rt
Expand Down
42 changes: 28 additions & 14 deletions src/gui/mzroll/mzfileio.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#ifndef MZFILEIO_H
#define MZFILEIO_H

#include <mutex>
#include "globals.h"
#include "mainwindow.h"
#include "mzAligner.h"
Expand Down Expand Up @@ -57,27 +59,27 @@ Q_OBJECT
* @return [int]
*/
int loadNISTLibrary(QString filename);
int loadMassBankLibrary(QString filename); //TODO: Sahil, Added while merging mzfileio
int loadMassBankLibrary(QString filename);
/**
* [load Pep XML]
* @param filename [name of the file]
* @return [int]
*/
int loadPepXML(QString filename);
int ThermoRawFileImport(QString fileName); //TODO: Sahil, Added while merging mzfileio
int ThermoRawFileImport(QString fileName);

bool isKnownFileType(QString filename); //TODO: Sahil, Added while merging mzfileio
bool isSampleFileType(QString filename); //TODO: Sahil, Added while merging mzfileio
bool isProjectFileType(QString filename); //TODO: Sahil, Added while merging mzfileio
bool isSpectralHitType(QString filename); //TODO: Sahil, Added while merging mzfileio
bool isPeakListType(QString filename); //TODO: Sahil, Added while merging mzfileio
bool isKnownFileType(QString filename);
bool isSampleFileType(QString filename);
bool isProjectFileType(QString filename);
bool isSpectralHitType(QString filename);
bool isPeakListType(QString filename);




public Q_SLOTS:
void readThermoRawFileImport(); //TODO: Sahil, Added while merging mzfileio
void addFileToQueue(QString f); //TODO: Sahil, Added while merging mzfileio
void readThermoRawFileImport();
void addFileToQueue(QString f);
void removeAllFilefromQueue();

Q_SIGNALS:
Expand All @@ -89,10 +91,10 @@ Q_OBJECT
* @param int [total value]
*/
void updateProgressBar(QString,int,int);
void sampleLoaded(); //TODO: Sahil, Added while merging mzfileio
void spectraLoaded(); //TODO: Sahil, Added while merging mzfileio
void projectLoaded(); //TODO: Sahil, Added while merging mzfileio
void peaklistLoaded(); //TODO: Sahil, Added while merging mzfileio
void sampleLoaded();
void spectraLoaded();
void projectLoaded();
void peaklistLoaded();
void createPeakTableSignal(QString);
void addNewSample(mzSample*);

Expand All @@ -112,7 +114,19 @@ Q_OBJECT
MainWindow* _mainwindow;
ProjectDockWidget* projectdocwidget;
bool _stopped;
QProcess* process; //TODO: Sahil, Added while merging mzfileio
QProcess* process;
/**
* @brief iterator for sample id
* @detail sampleId is unique for every sample. Everytime sample gets
* added, sampleId gets incremented by 1. Static to make sure variable
* is shared across threads
*/
unsigned int sampleId;

/**
* @brief to make updating sampleId thread safe
*/
mutex mtxSampleId;


};
Expand Down
88 changes: 18 additions & 70 deletions src/gui/mzroll/projectdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,15 @@ ProjectDockWidget::ProjectDockWidget(QMainWindow *parent):
colorButton->setToolTip("Change Sample Color");
connect(colorButton,SIGNAL(clicked()), SLOT(changeColors()));

//TODO: Sahil, Added this button while merging projectDockWidget
QToolButton* removeSamples = new QToolButton(toolBar);
removeSamples->setIcon(QIcon(rsrcPath + "/delete.png"));
removeSamples->setToolTip("Remove Samples");
connect(removeSamples,SIGNAL(clicked()), SLOT(unloadSelectedSamples()));

//TODO: Sahil, Added this button while merging projectDockWidget
QToolButton* checkUncheck = new QToolButton(toolBar);
checkUncheck->setIcon(QIcon(rsrcPath + "/checkuncheck.png"));
checkUncheck->setToolTip("Show / Hide Selected Samples");
connect(checkUncheck,SIGNAL(clicked()), SLOT(checkUncheck()));
//TODO: Giridhari, Create this button to set samples as Blank samples
QToolButton* blankButton = new QToolButton(toolBar);
blankButton->setIcon(QIcon(rsrcPath + "/blank sample.png"));
blankButton->setToolTip("Set As a Blank Sample");
Expand Down Expand Up @@ -281,10 +278,6 @@ void ProjectDockWidget::changeColors() {
_mainwindow->getEicWidget()->replot();
}

/*
@author: Sahil
*/
//TODO: Sahil, Added while merging projectdockwidget
void ProjectDockWidget::checkUncheck() {

//get selected items
Expand All @@ -307,10 +300,6 @@ void ProjectDockWidget::checkUncheck() {
_mainwindow->getEicWidget()->replot();
}

/*
@author: Sahil
*/
//TODO: Sahil, Added while merging projectdockwidget
void ProjectDockWidget::unloadSelectedSamples() {
//get selected items
QList<QTreeWidgetItem*>selected = _treeWidget->selectedItems();
Expand Down Expand Up @@ -353,8 +342,7 @@ void ProjectDockWidget::unloadSelectedSamples() {
_mainwindow->alignmentVizAllGroupsWidget->replotGraph();
_mainwindow->alignmentPolyVizDockWidget->plotGraph();
}
// @author:Giridhari
//TODO: Create function to Set samples as Blank Samples

void ProjectDockWidget::SetAsBlankSamples() {

int flag =0;
Expand Down Expand Up @@ -427,10 +415,6 @@ void ProjectDockWidget::setSampleColor(QTreeWidgetItem* item, QColor color) {
item->setBackgroundColor(1,color);
}

/*
@author: Sahil
*/
//TODO: Sahil, Added while merging projectdockwidget
void ProjectDockWidget::setSampleColor(mzSample* sample, QColor color) {
if (!color.isValid()) return;
if ( sample == NULL) return;
Expand Down Expand Up @@ -563,6 +547,7 @@ void ProjectDockWidget::showSample(QTreeWidgetItem* item, int col) {
}
}
}

QTreeWidgetItem* ProjectDockWidget::getParentFolder(QString fileName) {
//get parent name of the directory containg this sample
QTreeWidgetItem* parent=NULL;
Expand Down Expand Up @@ -676,9 +661,6 @@ void ProjectDockWidget::loadProject(QString fileName) {
QXmlStreamReader xml(&data);
mzSample* currentSample=NULL;




QString projectDescription;
QStringRef currentXmlElement;

Expand All @@ -695,14 +677,18 @@ void ProjectDockWidget::loadProject(QString fileName) {
xml.setDevice(xml.device());
QString progressText;
while (!xml.atEnd()) {


xml.readNext();
if (xml.isStartElement()) {
currentXmlElement = xml.name();


if (xml.name() == "sample") {
QString fname = xml.attributes().value("filename").toString();
unsigned int id = 0;
QString sname = xml.attributes().value("name").toString();
id = xml.attributes().value("id").toInt();
QString fname = xml.attributes().value("filename").toString();
QString setname = xml.attributes().value("setName").toString();
QString sampleOrder = xml.attributes().value("sampleOrder").toString();
QString isSelected = xml.attributes().value("isSelected").toString();
Expand Down Expand Up @@ -742,10 +728,11 @@ void ProjectDockWidget::loadProject(QString fileName) {
if (sample) {
_mainwindow->addSample(sample);
currentSample=sample;
if (!sname.isEmpty() ) sample->sampleName = sname.toStdString();
if (!setname.isEmpty() ) sample->setSetName(setname.toStdString());
if (!sampleOrder.isEmpty()) sample->setSampleOrder(sampleOrder.toInt());
if (!isSelected.isEmpty()) sample->isSelected = isSelected.toInt();
if (!sname.isEmpty() ) sample->sampleName = sname.toStdString();
if (id > 0) sample->id = id;
if (!setname.isEmpty() ) sample->setSetName(setname.toStdString());
if (!sampleOrder.isEmpty()) sample->setSampleOrder(sampleOrder.toInt());
if (!isSelected.isEmpty()) sample->isSelected = isSelected.toInt();
} else {
currentSample=NULL;
}
Expand Down Expand Up @@ -806,7 +793,7 @@ void ProjectDockWidget::saveProject(QString filename, TableDockWidget* peakTable
QXmlStreamWriter stream(&file);
stream.setAutoFormatting(true);
stream.writeStartElement("project");

stream.writeAttribute("mzrollVersion", "1.0");
stream.writeStartElement("samples");

vector<mzSample*> samples = _mainwindow->getSamples();
Expand All @@ -816,6 +803,7 @@ void ProjectDockWidget::saveProject(QString filename, TableDockWidget* peakTable

stream.writeStartElement("sample");
stream.writeAttribute("name", sample->sampleName.c_str() );
stream.writeAttribute("id", QString::number(sample->id));
stream.writeAttribute("filename", sample->fileName.c_str() );
stream.writeAttribute("sampleOrder", QString::number(sample->getSampleOrder()));
stream.writeAttribute("setName", sample->getSetName().c_str());
Expand All @@ -830,7 +818,7 @@ void ProjectDockWidget::saveProject(QString filename, TableDockWidget* peakTable
stream.writeEndElement();

}
stream.writeEndElement();
stream.writeEndElement();

stream.writeStartElement("projectDescription");
stream.writeCharacters(getProjectDescription());
Expand Down Expand Up @@ -858,9 +846,9 @@ void ProjectDockWidget::saveProject(QString filename, TableDockWidget* peakTable

if (compound->charge) stream.writeAttribute("Charge", QString::number(compound->charge));
if (compound->formula.length()) stream.writeAttribute("Formula", compound->formula.c_str());
if (compound->precursorMz) stream.writeAttribute("Precursor Mz", QString::number(compound->precursorMz, 'f', 6));
if (compound->productMz) stream.writeAttribute("Product Mz", QString::number(compound->productMz, 'f', 6));
if (compound->collisionEnergy) stream.writeAttribute("Collision Energy", QString::number(compound->collisionEnergy, 'f' ,6));
if (compound->precursorMz) stream.writeAttribute("precursorMz", QString::number(compound->precursorMz, 'f', 6));
if (compound->productMz) stream.writeAttribute("productMz", QString::number(compound->productMz, 'f', 6));
if (compound->collisionEnergy) stream.writeAttribute("collisionEnergy", QString::number(compound->collisionEnergy, 'f' ,6));

if(compound->category.size() > 0) {
stream.writeStartElement("categories");
Expand Down Expand Up @@ -903,46 +891,6 @@ void ProjectDockWidget::keyPressEvent(QKeyEvent *e ) {
QDockWidget::keyPressEvent(e);
}

/*
void ProjectDockWidget::unloadSample() {
QTreeWidgetItem *item = _treeWidget->currentItem();
if (item) {
QVariant v = item->data(0,Qt::UserRole);
mzSample* sample = v.value<mzSample*>();
if ( sample == NULL) return;
item->setHidden(true);
_treeWidget->removeItemWidget(item,0);
//mark sample as unselected
sample->isSelected=false;
delete_all(sample->scans);
qDebug() << "Removing Sample " << sample->getSampleName().c_str();
qDebug() << " Empting scan data #Scans=" << sample->scans.size();
//remove sample from sample list
for(unsigned int i=0; i<_mainwindow->samples.size(); i++) {
if (_mainwindow->samples[i] == sample) {
_mainwindow->samples.erase( _mainwindow->samples.begin()+i);
break;
}
}
qDebug() << "Number of Remaining Samples =" << _mainwindow->sampleCount();
//delete(item);
}
if ( _mainwindow->getEicWidget() ) {
_mainwindow->getEicWidget()->replotForced();
}
}
*/

/*
@author: Sahil
*/
//TODO: Sahil, Added this while merging projectdockwidget
void ProjectDockWidget::unloadSample(mzSample* sample) {
if ( sample == NULL) return;

Expand Down
Loading

0 comments on commit 21e70ce

Please sign in to comment.