Skip to content

Commit

Permalink
Merge branch 'fix_polarity_assignment' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil21 committed Jan 10, 2018
2 parents dd2796c + b3a6229 commit f89d7f6
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 77 deletions.
2 changes: 1 addition & 1 deletion src/cli/peakdetector/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ int main(int argc, char *argv[]) {
peakdetectorCLI->mavenParameters->setAverageScanTime();

//ionization
peakdetectorCLI->mavenParameters->setIonizationMode();
peakdetectorCLI->mavenParameters->setIonizationMode(MavenParameters::AutoDetect);

//align samples
if (peakdetectorCLI->mavenParameters->samples.size() > 1 && peakdetectorCLI->mavenParameters->alignSamplesFlag){
Expand Down
38 changes: 23 additions & 15 deletions src/core/libmaven/mavenparameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MavenParameters::MavenParameters()
outputdir = "reports" + string(DIR_SEPARATOR_STR);

writeCSVFlag = false;
ionizationMode = -1;
ionizationMode = 1;
charge = 1;
keepFoundGroups = true;
showProgressFlag = true;
Expand Down Expand Up @@ -233,15 +233,9 @@ void MavenParameters::setOptionsDialogSettings(const char* key, const char* valu
mavenSettings[const_cast<char*>(key)] = const_cast<char*>(value);

if(strcmp(key, "ionizationMode") == 0){
int indexOfIonizationMode=atoi(value);
/**
* map index of ionization-mode to value (-1,0,1) of ionizationMode
*/
if(indexOfIonizationMode==1) ionizationMode=0;
else if(indexOfIonizationMode==2) ionizationMode=+1;
else if(indexOfIonizationMode==3) ionizationMode=-1;
// set auto to zero
else ionizationMode=0;
int polarity=atoi(value);
setIonizationMode((Polarity)polarity);

}

if(strcmp(key, "amuQ1") == 0)
Expand Down Expand Up @@ -437,11 +431,25 @@ int MavenParameters::getCharge(Compound* compound){
* MavenParameters::setIonizationMode In this the mode is selected my looking
* at the first sample polarity
*/
void MavenParameters::setIonizationMode() {
if (samples.size() > 0 && samples[0]->getPolarity() > 0)
ionizationMode = +1;
else
ionizationMode = -1; //set ionization mode for compound matching
void MavenParameters::setIonizationMode(Polarity polarity) {
switch(polarity){
case Neutral:
ionizationMode=0;
break;
case Positive:
ionizationMode=1;
break;
case Negative:
ionizationMode=-1;
break;
default:
if (samples.size() > 0)
ionizationMode=samples[0]->getPolarity();
else
ionizationMode = 1;
break;
}

}

void MavenParameters::setSamples(vector<mzSample*>&set) {
Expand Down
3 changes: 2 additions & 1 deletion src/core/libmaven/mavenparameters.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class MavenParameters
{
public:
MavenParameters();
enum Polarity{AutoDetect,Neutral, Positive, Negative};
boost::signals2::signal< void (const string&,unsigned int , int ) > sig;

/**
Expand Down Expand Up @@ -80,7 +81,7 @@ class MavenParameters
* [set Ionization Mode]
* @method setIonizationMode
*/
void setIonizationMode();
void setIonizationMode(Polarity polarity);

/**
* [set Samples]
Expand Down
81 changes: 35 additions & 46 deletions src/gui/mzroll/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,20 +498,20 @@ using namespace mzUtils;
connect(fileLoader,SIGNAL(sampleLoaded()),projectDockWidget, SLOT(updateSampleList()));
connect(fileLoader,SIGNAL(sampleLoaded()), SLOT(showSRMList()));
connect(fileLoader,SIGNAL(sampleLoaded()), this, SLOT(checkSRMList()));
connect(fileLoader,SIGNAL(sampleLoaded()), this, SLOT(setQComboBox()));
connect(fileLoader,SIGNAL(sampleLoaded()), this, SLOT(setIonizationModeLabel()));
connect(fileLoader,SIGNAL(sampleLoaded()), this, SLOT(setFilterLine()));

connect(fileLoader,SIGNAL(spectraLoaded()),spectralHitsDockWidget, SLOT(showAllHits()));
connect(fileLoader,SIGNAL(spectraLoaded()),spectralHitsDockWidget, SLOT(show()));
connect(fileLoader,SIGNAL(spectraLoaded()),spectralHitsDockWidget, SLOT(raise()));
connect(fileLoader,SIGNAL(spectraLoaded()), this,SLOT(setQComboBox()));
connect(fileLoader,SIGNAL(spectraLoaded()), this,SLOT(setIonizationModeLabel()));
connect(fileLoader,SIGNAL(spectraLoaded()), this, SLOT(setInjectionOrderFromTimeStamp()));

connect(fileLoader,SIGNAL(projectLoaded()),projectDockWidget, SLOT(updateSampleList()));
connect(fileLoader,SIGNAL(projectLoaded()),bookmarkedPeaks, SLOT(showAllGroups()));
connect(fileLoader,SIGNAL(projectLoaded()), SLOT(showSRMList()));
connect(fileLoader,SIGNAL(projectLoaded()), this,SLOT(checkSRMList()));
connect(fileLoader,SIGNAL(projectLoaded()), this,SLOT(setQComboBox()));
connect(fileLoader,SIGNAL(projectLoaded()), this,SLOT(setIonizationModeLabel()));
connect(fileLoader,SIGNAL(projectLoaded()), this,SLOT(deleteCrashFileTables()));
connect(fileLoader,SIGNAL(projectLoaded()), this, SLOT(setInjectionOrderFromTimeStamp()));

Expand All @@ -536,15 +536,14 @@ using namespace mzUtils;
alignmentVizAllGroupsDockWidget->raise();

createToolBars();
setIonizationMode(0);
// setIonsizationMode(0);
currentIntensityName = "Max "+quantType->currentText();
if (settings->contains("ionizationMode")) {
setIonizationMode(settings->value("ionizationMode").toInt());
}
// if (settings->contains("ionizationMode")) {
// setIonizationMode(settings->value("ionizationMode").toInt());
// }

setQComboBox();
setIonizationModeLabel();
setTotalCharge();
connect(ionizationModeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(setTotalCharge()));
connect(ionChargeBox, SIGNAL(valueChanged(int)), this, SLOT(setTotalCharge()));

// This been set here why is this here; beacuse of this
Expand Down Expand Up @@ -1115,35 +1114,31 @@ void MainWindow::setUserMassCutoff(double x) {

}

void MainWindow::setIonizationMode(int x) {
_ionizationMode = x;
massCalcWidget->setCharge(_ionizationMode);
isotopeWidget->setCharge(_ionizationMode);
}

void MainWindow::setQComboBox() {
void MainWindow::setIonizationModeLabel() {

QString ionMode = settingsForm->ionizationMode->currentText();

if (ionMode.contains("Positive")) ionizationModeComboBox->setCurrentIndex(0);
else if (ionMode.contains("Negative")) ionizationModeComboBox->setCurrentIndex(1);
else if (ionMode.contains("Neutral")) ionizationModeComboBox->setCurrentIndex(2);
else if (ionMode.contains("Auto Detect")) {

disconnect(ionizationModeComboBox, SIGNAL(currentIndexChanged(QString)), 0, 0);

if(!samples.empty()) {
int mode = samples[0]->getPolarity();
if (mode == 0) ionizationModeComboBox->setCurrentIndex(2);
else if (mode == -1) ionizationModeComboBox->setCurrentIndex(1);
else if (mode == 1) ionizationModeComboBox->setCurrentIndex(0);
else ionizationModeComboBox->setCurrentIndex(2);
}
MavenParameters::Polarity polarity;
if(ionMode.contains("Positive")) polarity=MavenParameters::Positive;
else if (ionMode.contains("Negative")) polarity=MavenParameters::Negative;
else if(ionMode.contains("Neutral")) polarity=MavenParameters::Neutral;
else polarity=MavenParameters::AutoDetect;

connect(ionizationModeComboBox, SIGNAL(currentIndexChanged(QString)), settingsForm, SLOT(setSettingsIonizationMode(QString)));
mavenParameters->setIonizationMode(polarity);

int mode=getIonizationMode();
if(polarity==MavenParameters::AutoDetect ){
QString polarityLabel=QString::number(mode);
if(mode==1) polarityLabel="+1";
ionMode=ionMode+"("+polarityLabel+")";
}
else ionizationModeComboBox->setCurrentIndex(2);

ionizationModeLabel->setText(ionMode);

massCalcWidget->setCharge(mode);
isotopeWidget->setCharge(mode);
setTotalCharge();
}

void MainWindow::setInjectionOrderFromTimeStamp() {
Expand Down Expand Up @@ -1186,13 +1181,8 @@ void MainWindow::setFilterLine() {

void MainWindow::setTotalCharge() {

int temp = 0;
if(ionizationModeComboBox->currentIndex() == 0) temp = 1;
else if(ionizationModeComboBox->currentIndex() == 1) temp = -1;
else if(ionizationModeComboBox->currentIndex() == 2) temp = 0;
mavenParameters->ionizationMode = temp;
mavenParameters->charge = ionChargeBox->value();
totalCharge = temp * ionChargeBox->value();
totalCharge = mavenParameters->ionizationMode * ionChargeBox->value();

ligandWidget->updateTable();

Expand Down Expand Up @@ -2677,12 +2667,11 @@ void MainWindow::createToolBars() {
SLOT(setDatabase(QString)));
layout->addSpacing(10);

ionizationModeComboBox = new QComboBox(hBox);
ionizationModeComboBox->addItem("Positive (+)");
ionizationModeComboBox->addItem("Negative (-)");
ionizationModeComboBox->addItem("Neutral (0)");
ionizationModeComboBox->setToolTip("Select Ionization Mode");
connect(ionizationModeComboBox, SIGNAL(currentIndexChanged(QString)), settingsForm, SLOT(setSettingsIonizationMode(QString)));
ionizationModeLabel = new QLabel(hBox);
ionizationModeLabel->setToolTip("Ionization Mode");
ionizationModeLabel->setFrameShape(QFrame::Panel);
ionizationModeLabel->setFrameShadow(QFrame::Raised);


ionChargeBox = new QSpinBox(hBox);
ionChargeBox->setValue(settings->value("ionChargeBox").toInt());
Expand All @@ -2704,7 +2693,7 @@ void MainWindow::createToolBars() {
Q_FOREACH(QString key, keys)suggestPopup->addToHistory(key, settings->value(key).toInt());
settings->endGroup();

layout->addWidget(ionizationModeComboBox, 0);
layout->addWidget(ionizationModeLabel, 0);
layout->addWidget(new QLabel("Charge", hBox), 0);
layout->addWidget(ionChargeBox, 0);
layout->addWidget(quantType, 0);
Expand Down Expand Up @@ -2825,8 +2814,8 @@ void MainWindow::addToHistory(const mzSlice& slice) {
bool MainWindow::addSample(mzSample* sample) {
if (sample && sample->scans.size() > 0) {
samples.push_back(sample);
if (sample->getPolarity())
setIonizationMode(sample->getPolarity());
mavenParameters->samples.push_back(sample);
settingsForm->setSettingsIonizationMode("Auto Detect");
return true;
} else {
delete (sample);
Expand Down
9 changes: 3 additions & 6 deletions src/gui/mzroll/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Q_OBJECT
QDoubleSpinBox *massCutoffWindowBox;
QComboBox *massCutoffComboBox;
QLineEdit *searchText;
QComboBox *ionizationModeComboBox;
QLabel *ionizationModeLabel;
QSpinBox *ionChargeBox;
QComboBox *quantType;
QLabel *statusText;
Expand Down Expand Up @@ -312,7 +312,7 @@ public Q_SLOTS:
void plotAlignmentVizAllGroupGraph(QList<PeakGroup> allgroups);
void createPeakTable(QString);

void setQComboBox();
void setIonizationModeLabel();
void setFilterLine();
void setInjectionOrderFromTimeStamp();

Expand Down Expand Up @@ -363,10 +363,8 @@ public Q_SLOTS:
void markGroup(PeakGroup* group, char label);
//Added when merged with Maven776 - Kiran
void startEmbededHttpServer();

void setIonizationMode(int x);
int getIonizationMode() {
return _ionizationMode;
return mavenParameters->ionizationMode;
}
void setTotalCharge();

Expand Down Expand Up @@ -430,7 +428,6 @@ private Q_SLOTS:
EicWidget *eicWidget; //plot of extractred EIC
History history;

int _ionizationMode;
MassCutoff *_massCutoffWindow;

QToolBar* sideBar;
Expand Down
11 changes: 5 additions & 6 deletions src/gui/mzroll/settingsform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ SettingsForm::SettingsForm(QSettings* s, MainWindow *w): QDialog(w) {
connect(isotopicMinSignalBaselineDifference, SIGNAL(valueChanged(double)), SLOT(recomputeEIC()));

connect(ionizationMode, SIGNAL(currentIndexChanged(int)), SLOT(getFormValues()));
connect(ionizationMode, SIGNAL(currentIndexChanged(QString)), mainwindow, SLOT(setQComboBox()));
connect(ionizationMode, SIGNAL(currentIndexChanged(QString)), mainwindow, SLOT(setIonizationModeLabel()));
connect(isotopeC13Correction, SIGNAL(toggled(bool)), SLOT(getFormValues()));
connect(amuQ1, SIGNAL(valueChanged(double)), SLOT(getFormValues()));
connect(amuQ3, SIGNAL(valueChanged(double)), SLOT(getFormValues()));
Expand Down Expand Up @@ -450,11 +450,10 @@ void SettingsForm::getFormValues() {


//change ionization mode
int mode=0;
if (ionizationMode->currentText().contains("+1") ) mode=1;
else if ( ionizationMode->currentText().contains("-1") ) mode=-1;
else if (ionizationMode->currentText().contains("Auto Detect") && !mainwindow->samples.empty()) mode=mainwindow->samples[0]->getPolarity();
if(mainwindow) mainwindow->setIonizationMode(mode);
if (ionizationMode->currentText().contains("+1") ) settings->setValue("ionizationMode", 1);
else if ( ionizationMode->currentText().contains("-1") ) settings->setValue("ionizationMode", -1);
else if (ionizationMode->currentText().contains("Auto Detect") && !mainwindow->samples.empty())
settings->setValue("ionizationMode", mainwindow->samples[0]->getPolarity());

//change ionization type

Expand Down
4 changes: 2 additions & 2 deletions tests/MavenTests/testCLI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void TestCLI::testReduceGroups() {
peakdetectorCLI->loadCompoundsFile();
peakdetectorCLI->loadSamples(peakdetectorCLI->filenames);
peakdetectorCLI->mavenParameters->setAverageScanTime();
peakdetectorCLI->mavenParameters->setIonizationMode();
peakdetectorCLI->mavenParameters->setIonizationMode(MavenParameters::AutoDetect);

if (peakdetectorCLI->mavenParameters->compounds.size()) {
vector<mzSlice*> slices = peakdetectorCLI->peakDetector->processCompounds(
Expand Down Expand Up @@ -166,7 +166,7 @@ void TestCLI::testWriteReport() {
peakdetectorCLI->loadCompoundsFile();
peakdetectorCLI->loadSamples(peakdetectorCLI->filenames);
peakdetectorCLI->mavenParameters->setAverageScanTime();
peakdetectorCLI->mavenParameters->setIonizationMode();
peakdetectorCLI->mavenParameters->setIonizationMode(MavenParameters::AutoDetect);

if (peakdetectorCLI->mavenParameters->compounds.size()) {
vector<mzSlice*> slices = peakdetectorCLI->peakDetector->processCompounds(
Expand Down

0 comments on commit f89d7f6

Please sign in to comment.