Skip to content

Commit

Permalink
when saving project in maven scans table is preserved
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenemel committed Feb 6, 2018
1 parent 4f9e23f commit b9b8c8e
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/maven/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ void Database::loadCompoundsSQL(QString databaseName) {
}

sort(compoundsDB.begin(),compoundsDB.end(), Compound::compMass);
qDebug() << "loadCompoundSQL : " << compoundsDB.size();
qDebug() << "loadCompoundSQL : " << databaseName << compoundsDB.size();
if(loadcount > 0 and databaseName != "ALL") loadedDatabase[databaseName] = 1;
}

Expand Down
29 changes: 22 additions & 7 deletions src/maven/projectDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ void ProjectDB::saveGroups(vector<PeakGroup>& allgroups, QString setName) {

void ProjectDB::deleteAll() {
QSqlQuery query(sqlDB);
query.exec("drop table peakgroups");
query.exec("drop table samples");
query.exec("drop table peakgroups");
query.exec("drop table peaks");
query.exec("drop table scans");
query.exec("drop table rt_update_key");
}

Expand All @@ -24,6 +23,18 @@ void ProjectDB::deleteGroups() {
query.exec("drop table peaks");
}


void ProjectDB::deleteSearchResults(QString searchTable) {
QSqlQuery query(sqlDB);
query.prepare("delete from peaks where groupId in (select groupId from peakgroups where searchTableName = ?");
query.addBindValue(searchTable);
query.exec();

query.prepare("delete from peakgroups where searchTableName = ?");
query.addBindValue(searchTable);
query.exec();
}

void ProjectDB::assignSampleIds() {
int maxSampleId = -1;
for(mzSample* s: samples) if (s->getSampleId()>maxSampleId) maxSampleId=s->getSampleId();
Expand Down Expand Up @@ -59,7 +70,9 @@ void ProjectDB::saveScans(vector<mzSample *> &sampleSet) {
QSqlQuery query0(sqlDB);

query0.exec("begin transaction");
if(!query0.exec("CREATE TABLE IF NOT EXISTS scans(\
query0.exec("drop table scans");

if(!query0.exec("CREATE TABLE IF NOT EXISTS scans(\
id INTEGER PRIMARY KEY AUTOINCREMENT,\
sampleId int NOT NULL,\
scan int NOT NULL,\
Expand Down Expand Up @@ -532,7 +545,7 @@ void ProjectDB::loadGroupPeaks(PeakGroup* parent) {
QSqlQuery query(sqlDB);
query.prepare("select P.*, S.name as sampleName from peaks P, samples S where P.sampleId = S.sampleId and P.groupId = ?");
query.bindValue(0,parent->groupId);
qDebug() << "loadin peaks for group " << parent->groupId;
//qDebug() << "loadin peaks for group " << parent->groupId;
query.exec();

while (query.next()) {
Expand Down Expand Up @@ -641,13 +654,15 @@ void ProjectDB::loadSamples() {
foreach(mzSample* loadedFile, samples) {
if (loadedFile->sampleName == sname.toStdString()) checkLoaded=true;
if (QString(loadedFile->fileName.c_str()) == fname) checkLoaded=true;
}
if(checkLoaded == true) continue; // skip files that have been loaded already
}

if(checkLoaded == true) continue; // skip files that have been loaded already


mzSample* s = new mzSample();
s->loadSample(fname.toLatin1());
s->fileName = fname.toStdString();
s->sampleId = sampleId;
s->setSampleId(sampleId);
s->setSampleOrder(sampleOrder);
s->isSelected = isSelected;
s->color[0] = color_red;
Expand Down
1 change: 1 addition & 0 deletions src/maven/projectDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class ProjectDB {
void loadGroupPeaks(PeakGroup* group);
void deleteAll();
void deleteGroups();
void deleteSearchResults(QString searchTable);
void deletePeakGroup(PeakGroup* g, QString tableName);
void assignSampleIds();
void saveAlignment();
Expand Down
5 changes: 0 additions & 5 deletions src/maven/projectdockwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,6 @@ void ProjectDockWidget::loadProjectSQLITE(QString fileName) {
QString filepath = query.value("filename").toString();
QString sname = query.value("name").toString();

qDebug() << "loadProjectSQLITE: " << sname << filepath;

//skip files that have been loaded already
bool checkLoaded=false;
foreach(mzSample* loadedFile, _mainwindow->getSamples()) {
Expand All @@ -519,8 +517,6 @@ void ProjectDockWidget::loadProjectSQLITE(QString fileName) {

if(checkLoaded == true) continue; // skip files that have been loaded already

qDebug() << "Looking for sample: " << sname ;

//locate file
QString locatedpath = locateSample(filepath, pathlist);
QFileInfo sampleFile(locatedpath);
Expand Down Expand Up @@ -624,7 +620,6 @@ void ProjectDockWidget::loadAllPeakTables() {
for(int i=0; i < currentProject->allgroups.size(); i++ ) {
PeakGroup* g = &(currentProject->allgroups[i]);
currentProject->allgroups[i].groupStatistics();
qDebug() << "Loading peakgroup" << i;

//put them in right place
if(g->searchTableName.empty()) g->searchTableName="Bookmarks";
Expand Down

0 comments on commit b9b8c8e

Please sign in to comment.