Skip to content

Commit

Permalink
Issue 641: Explicitly save sampleToUpdatedRts map when loading an old…
Browse files Browse the repository at this point in the history
… project, default to re-saving this old map, unless it is overwritten.
  • Loading branch information
PMSeitzer committed Jul 11, 2023
1 parent 2c2786a commit 1a4dba7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
14 changes: 11 additions & 3 deletions src/maven/projectDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1465,19 +1465,27 @@ void ProjectDB::doAlignment() {
int segCount=0;
while (query.next()) {
string sampleName = query.value("name").toString().toStdString();
//mzUtils::replace(sampleName,".mzXML",""); //bug fix.. alignment.rt files do not strore extensions.
//mzUtils::replace(sampleName,".mzXML",""); //bug fix.. alignment.rt files do not store extensions.

int sampleId = query.value("sampleId").toString().toInt();
mzSample* sample = this->getSampleById(sampleId);
if (!sample) continue;
segCount++;

float rt = query.value("rt").toString().toFloat();
float rtUpdate = query.value("rt_update").toString().toFloat();

if (sampleToUpdatedRts.find(sample) == sampleToUpdatedRts.end()) {
sampleToUpdatedRts.insert(make_pair(sample, vector<pair<float, float>>{}));
}
sampleToUpdatedRts.at(sample).push_back(make_pair(rt, rtUpdate));

AlignmentSegment* seg = new AlignmentSegment();
seg->sampleName = sampleName;
seg->seg_start = 0;
seg->seg_end = query.value("rt").toString().toFloat();
seg->seg_end = rt;
seg->new_start = 0;
seg->new_end = query.value("rt_update").toString().toFloat();
seg->new_end = rtUpdate;

if (lastSegment and lastSegment->sampleName == seg->sampleName) {
seg->seg_start = lastSegment->seg_end;
Expand Down
3 changes: 3 additions & 0 deletions src/maven/projectDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class ProjectDB {
map<string, shared_ptr<DirectInfusionSearchParameters>> diSearchParameters = {};
map<string, shared_ptr<PeaksSearchParameters>> peaksSearchParameters = {};

//Issue 641: explicitly save anchor points, when they are available.
map<mzSample*, vector<pair<float, float>>> sampleToUpdatedRts{};

//UI adjustments
unordered_map<string, string> quantTypeMap{}; //<original, renamed>
unordered_map<string, string> quantTypeInverseMap{}; //<renamed, original>
Expand Down
5 changes: 4 additions & 1 deletion src/maven/projectdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,9 @@ void ProjectDockWidget::saveProjectSQLITE(QString filename) {
//ui options
project->quantTypeMap = currentProject->quantTypeMap;
project->quantTypeInverseMap = currentProject->quantTypeInverseMap;

//RT alignment information
project->sampleToUpdatedRts = currentProject->sampleToUpdatedRts;
}
}

Expand All @@ -759,7 +762,7 @@ void ProjectDockWidget::saveProjectSQLITE(QString filename) {
project->deleteAll(); //extreme, but ensures that re-saving always saves data using most recent code
project->setSamples(sampleSet);
project->saveSamples(sampleSet);
project->saveAlignment();
project->saveAlignment(project->sampleToUpdatedRts);

unsigned int groupCount=0;

Expand Down

0 comments on commit 1a4dba7

Please sign in to comment.