Skip to content

Commit

Permalink
Updated direct infusion receivers to include cluster number.
Browse files Browse the repository at this point in the history
  • Loading branch information
PMSeitzer committed Oct 1, 2019
1 parent 15efc21 commit b5f262b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 15 deletions.
48 changes: 42 additions & 6 deletions src/maven/background_directinfusion_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ BackgroundDirectInfusionUpdate::~BackgroundDirectInfusionUpdate() {

void BackgroundDirectInfusionUpdate::run(void) {

int numSteps = samples.size() + 2; //prepare search database + each sample + agglomerate across samples
int stepNum = 0;

QTime timer;
timer.start();

qDebug() << "Direct infusion analysis started.";
emit(updateProgressBar("Preparing search database...", 0, samples.size()));
emit(updateProgressBar("Preparing search database...", stepNum, numSteps));

/**
* ACTUAL WORK
Expand All @@ -28,8 +31,14 @@ void BackgroundDirectInfusionUpdate::run(void) {
false //debug
);

multimap<int, DirectInfusionAnnotation*> allDirectInfusionsAcrossSamples = {};

typedef map<int, DirectInfusionAnnotation*>::iterator diSampleIterator;

for (unsigned int i = 0; i < samples.size(); i++){

stepNum++;

mzSample* sample = samples.at(i);

string msgStart = string("Processing sample ")
Expand All @@ -40,26 +49,53 @@ void BackgroundDirectInfusionUpdate::run(void) {
.append(sample->sampleName)
.append("\"");

emit(updateProgressBar(msgStart.c_str(), (i+1), (samples.size()+1)));
emit(updateProgressBar(msgStart.c_str(), stepNum, numSteps));


/**
* ACTUAL WORK
*/
vector<DirectInfusionAnnotation*> directInfusionAnnotations =
map<int, DirectInfusionAnnotation*> directInfusionAnnotations =
DirectInfusionProcessor::processSingleSample(
sample,
searchDb,
params,
false //debug
);

//DirectInfusionAnnotation* are deleted by the receiver (TableDockWidget)
for (DirectInfusionAnnotation* directInfusionAnnotation : directInfusionAnnotations) {
emit(newDirectInfusionAnnotation(directInfusionAnnotation));
for (diSampleIterator it = directInfusionAnnotations.begin(); it != directInfusionAnnotations.end(); ++it){
allDirectInfusionsAcrossSamples.insert(make_pair(it->first, it->second));
}

}

//TODO: refactor as modular algorithm
//Organizing across samples
stepNum++;
updateProgressBar("Combining results across samples...", stepNum, numSteps);

for (auto directInfusionAnnotation : allDirectInfusionsAcrossSamples) {
emit(newDirectInfusionAnnotation(directInfusionAnnotation.second, directInfusionAnnotation.first));
}

// typedef multimap<int, DirectInfusionAnnotation*>::iterator diMultimapIterator;

// for (int mapKey : searchDb->mapKeys){

// pair<diMultimapIterator, diMultimapIterator> directInfusionAnnotations = allDirectInfusionsAcrossSamples.equal_range(mapKey);

// for (diMultimapIterator it = directInfusionAnnotations.first; it != directInfusionAnnotations.second; ++it){
// emit(newDirectInfusionAnnotation(it->second, it->first));
// }

// //for (diMultimapIterator = allDirectInfusionsAcrossSamples.equal_range(mapKey);)
// }

//DirectInfusionAnnotation* are deleted by the receiver (TableDockWidget)
// for (DirectInfusionAnnotation* directInfusionAnnotation : directInfusionAnnotations) {
// emit(newDirectInfusionAnnotation(directInfusionAnnotation));
// }

qDebug() << "Direct infusion analysis completed in" << timer.elapsed() << "msec.";
updateProgressBar("Direct infusion analysis not yet started", 0, 1);
emit(closeDialog());
Expand Down
2 changes: 1 addition & 1 deletion src/maven/background_directinfusion_update.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BackgroundDirectInfusionUpdate : public QThread {

signals:
void updateProgressBar(QString, int, int);
void newDirectInfusionAnnotation(DirectInfusionAnnotation*);
void newDirectInfusionAnnotation(DirectInfusionAnnotation*, int);
void closeDialog();

};
Expand Down
2 changes: 1 addition & 1 deletion src/maven/directinfusiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void DirectInfusionDialog::analyze() {
TableDockWidget* resultsTable = mainwindow->addPeaksTable(title.toLatin1().data());
resultsTable->setWindowTitle(title.toLatin1().data());

connect(directInfusionUpdate, SIGNAL(newDirectInfusionAnnotation(DirectInfusionAnnotation*)), resultsTable, SLOT(addDirectInfusionAnnotation(DirectInfusionAnnotation*)));
connect(directInfusionUpdate, SIGNAL(newDirectInfusionAnnotation(DirectInfusionAnnotation*, int)), resultsTable, SLOT(addDirectInfusionAnnotation(DirectInfusionAnnotation*, int)));

connect(directInfusionUpdate, SIGNAL(updateProgressBar(QString,int,int)), SLOT(setProgressBar(QString, int,int)));
connect(directInfusionUpdate, SIGNAL(closeDialog()), SLOT(hide()));
Expand Down
6 changes: 2 additions & 4 deletions src/maven/tabledockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,16 +458,14 @@ PeakGroup* TableDockWidget::addPeakGroup(PeakGroup *group, bool updateTable, boo
return g;
}

void TableDockWidget::addDirectInfusionAnnotation(DirectInfusionAnnotation* directInfusionAnnotation){

directInfusionClusterNum++;
void TableDockWidget::addDirectInfusionAnnotation(DirectInfusionAnnotation* directInfusionAnnotation, int clusterNum) {

float meanMz = 0.5f*(directInfusionAnnotation->precMzMin + directInfusionAnnotation->precMzMax);

for (auto tuple : directInfusionAnnotation->compounds){

PeakGroup pg;
pg.metaGroupId = directInfusionClusterNum;
pg.metaGroupId = clusterNum;

//TODO: much of the information needs to be stuffed into Peak, b/c
//when opening a file it all gets re-derived from PeakGroup::groupStatistics()
Expand Down
3 changes: 1 addition & 2 deletions src/maven/tabledockwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public slots:
//void showInfo(PeakGroup* group);
PeakGroup* addPeakGroup(PeakGroup* group, bool updateTable);
PeakGroup* addPeakGroup(PeakGroup* group, bool updateTable, bool isDeletePeakGroupPtr);
void addDirectInfusionAnnotation(DirectInfusionAnnotation* directInfusionAnnotation);
void addDirectInfusionAnnotation(DirectInfusionAnnotation* directInfusionAnnotation, int clusterNum);
void setupPeakTable();
PeakGroup* getSelectedGroup();
PeakGroup* getLastBookmarkedGroup();
Expand Down Expand Up @@ -120,7 +120,6 @@ protected slots:
tableViewType viewType;

PeakGroup *lastSelectedGroup;
int directInfusionClusterNum = 0;
};

#endif
2 changes: 1 addition & 1 deletion src/maven_core

0 comments on commit b5f262b

Please sign in to comment.