Skip to content

Commit

Permalink
Merge pull request #115 from unipept/fix/search-settings-transaction
Browse files Browse the repository at this point in the history
Fix incorrect search settings sync when unexpected close of application
  • Loading branch information
pverscha authored Jan 11, 2021
2 parents c97fada + d2dd334 commit 4f79c88
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 52 deletions.
37 changes: 4 additions & 33 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"node-abi": "^2.19.3",
"regenerator-runtime": "^0.13.3",
"shared-memory-datastructures": "0.1.8",
"unipept-web-components": "1.3.0",
"unipept-web-components": "^1.3.1",
"uuid": "^7.0.3",
"vue": "^2.6.12",
"vue-class-component": "^7.1.0",
Expand Down
3 changes: 1 addition & 2 deletions src/components/analysis/AnalysisSummary.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ export default class AnalysisSummary extends Vue {
private update() {
const config = new SearchConfiguration(this.equateIl, this.filterDuplicates, this.missedCleavage);
this.assay.setSearchConfiguration(config);
this.$store.dispatch("processAssay", [this.assay, true]);
this.$store.dispatch("processAssay", [this.assay, true, config]);
}
private getHumanReadableAssayDate(): string {
Expand Down
2 changes: 1 addition & 1 deletion src/components/navigation-drawers/AssayItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export default class AssayItem extends Vue {
}
private reanalyse() {
this.$store.dispatch("processAssay", [this.assay, true]);
this.$store.dispatch("processAssay", [this.assay, true, this.assay.getSearchConfiguration()]);
}
private selectAssay() {
Expand Down
6 changes: 5 additions & 1 deletion src/components/pages/analysis/AnalysisPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ export default class AnalysisPage extends Vue {
private reanalyse() {
if (this.activeAssay) {
this.$store.dispatch("processAssay", [this.activeAssay, true]);
this.$store.dispatch("processAssay", [
this.activeAssay,
true,
this.activeAssay.getSearchConfiguration()
]);
}
}
Expand Down
22 changes: 15 additions & 7 deletions src/logic/communication/DesktopAssayProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AssayProcessor,
PeptideData,
NetworkConfiguration,
SearchConfiguration
} from "unipept-web-components";

import CachedCommunicationSource from "@/logic/communication/source/CachedCommunicationSource";
Expand All @@ -29,9 +30,14 @@ export default class DesktopAssayProcessor implements AssayProcessor {

public async processAssay(
countTable: CountTable<Peptide>,
forceUpdate: boolean = false
forceUpdate: boolean = false,
searchSettings: SearchConfiguration
): Promise<CommunicationSource> {
const [pept2DataResponses, peptideTrust] = await this.getPept2Data(countTable, forceUpdate);
const [pept2DataResponses, peptideTrust] = await this.getPept2Data(
countTable,
forceUpdate,
searchSettings
);
this.setProgress(1);

if (this.isCancelled()) {
Expand All @@ -58,7 +64,8 @@ export default class DesktopAssayProcessor implements AssayProcessor {

private async getPept2Data(
peptideCountTable: CountTable<Peptide>,
forceUpdate: boolean
forceUpdate: boolean,
searchSettings: SearchConfiguration
): Promise<[ShareableMap<Peptide, PeptideData>, PeptideTrust]> {
const processedAssayManager = new ProcessedAssayManager(this.dbManager);
const processingResult = await processedAssayManager.readProcessingResults(this.assay);
Expand All @@ -81,26 +88,27 @@ export default class DesktopAssayProcessor implements AssayProcessor {

await this.pept2DataCommunicator.process(
peptideCountTable,
this.assay.getSearchConfiguration(),
searchSettings,
pept2DataProgressNotifier
);

if (!this.cancelled) {
// @ts-ignore
const pept2ResponseMap: ShareableMap<string, PeptideData> = this.pept2DataCommunicator.getPeptideResponseMap(
this.assay.getSearchConfiguration()
searchSettings
);
const trust = await this.pept2DataCommunicator.getPeptideTrust(
peptideCountTable,
this.assay.getSearchConfiguration()
searchSettings
);

this.assay.setEndpoint(currentEndpoint);
this.assay.setDatabaseVersion(currentDbVersion);
this.assay.setDate(new Date());
this.assay.setSearchConfiguration(searchSettings);

// Store results and update metadata...
await processedAssayManager.storeProcessingResults(this.assay, pept2ResponseMap, trust);
await processedAssayManager.storeProcessingResults(this.assay, pept2ResponseMap, trust, searchSettings);

return [
pept2ResponseMap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class FileSystemAssayChangeListener implements ChangeListener<Pro
await assay.accept(writer);

// noinspection ES6MissingAwait
store.dispatch("processAssay", [assay, false]);
store.dispatch("processAssay", [assay, false, assay.getSearchConfiguration()]);
}

private getAssayDirectory(): string {
Expand Down
5 changes: 3 additions & 2 deletions src/logic/filesystem/assay/processed/ProcessedAssayManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ export default class ProcessedAssayManager {
public async storeProcessingResults(
assay: ProteomicsAssay,
pept2Data: ShareableMap<string, PeptideData>,
trust: PeptideTrust
trust: PeptideTrust,
searchSettings: SearchConfiguration
) {
// Delete the metadata that's associated with this assay
await this.dbManager.performQuery<void>((db: Database) => {
Expand Down Expand Up @@ -127,7 +128,7 @@ export default class ProcessedAssayManager {
});

// Now write the metadata to the database again.
const existingConfig = assay.getSearchConfiguration();
const existingConfig = searchSettings;
const searchConfiguration = new SearchConfiguration(
existingConfig.equateIl,
existingConfig.filterDuplicates,
Expand Down
7 changes: 5 additions & 2 deletions src/logic/filesystem/project/FileSystemWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export default class FileSystemWatcher {
// it is added to the study.
study.addAssay(assay);
await store.dispatch("addAssay", assay);
store.dispatch("processAssay", [assay, false]);
store.dispatch("processAssay", [assay, false, assay.getSearchConfiguration()]);
}
} catch (err) {
this.reportError(err);
Expand Down Expand Up @@ -153,7 +153,10 @@ export default class FileSystemWatcher {
for (const assay of study.getAssays()) {
await store.dispatch("addAssay", assay);
// noinspection ES6MissingAwait
store.dispatch("processAssay", [assay, false]);
store.dispatch(
"processAssay",
[assay, false, (assay as ProteomicsAssay).getSearchConfiguration()]
);
}

study.addChangeListener(new FileSystemStudyChangeListener());
Expand Down
6 changes: 4 additions & 2 deletions src/state/ProjectStore.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Study } from "unipept-web-components";
import { ProteomicsAssay, Study } from "unipept-web-components";
import { ActionContext, ActionTree, GetterTree, MutationTree } from "vuex";
import FileSystemWatcher from "@/logic/filesystem/project/FileSystemWatcher";
import path from "path";
Expand Down Expand Up @@ -102,7 +102,9 @@ const projectActions: ActionTree<ProjectState, any> = {
for (const study of studies) {
for (const assay of study.getAssays()) {
await store.dispatch("addAssay", assay);
store.dispatch("processAssay", [assay, false]);
store.dispatch(
"processAssay",
[assay, false, (assay as ProteomicsAssay).getSearchConfiguration()]);
}
}

Expand Down

0 comments on commit 4f79c88

Please sign in to comment.