Skip to content

Commit

Permalink
Merge pull request #159 from unipept/fix/export-results-not-available
Browse files Browse the repository at this point in the history
Fix/export results not available
  • Loading branch information
pverscha authored Mar 15, 2022
2 parents 51412ed + 55edb43 commit dd67317
Show file tree
Hide file tree
Showing 10 changed files with 453 additions and 33 deletions.
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unipept-desktop",
"version": "1.2.2",
"version": "1.2.3",
"private": true,
"author": "Unipept Team (Ghent University)",
"description": "A desktop equivalent of unipept.ugent.be. This app aims at high-throughput analysis of metaproteomics samples.",
Expand Down Expand Up @@ -53,7 +53,7 @@
"node-abi": "^2.19.3",
"regenerator-runtime": "^0.13.3",
"shared-memory-datastructures": "0.1.9",
"unipept-web-components": "^1.5.0",
"unipept-web-components": "^1.5.1",
"uuid": "^7.0.3",
"vue": "^2.6.12",
"vue-class-component": "^7.1.0",
Expand Down
4 changes: 4 additions & 0 deletions src/db/migrations/v3_to_v4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/*
NOOP since nothing has changed to the database structure itself between these versions, only a change to the
encoding of data in the database has been performed.
*/
58 changes: 58 additions & 0 deletions src/db/schemas/schema_v4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
CREATE TABLE studies (
id TEXT PRIMARY KEY,
name TEXT NOT NULL
);

CREATE TABLE assays (
id TEXT PRIMARY KEY,
name TEXT NOT NULL,
study_id TEXT NOT NULL,
configuration_id INT NOT NULL,
/*
Endpoint that was last selected for this assay. This endpoint does not necessarily need to be the same as the one
selected for the storage_metadata table. This endpoint is only used to detect whether the assay needs to be
recomputed or not.
*/
endpoint TEXT,
FOREIGN KEY(study_id) REFERENCES studies(id),
FOREIGN KEY(configuration_id) REFERENCES search_configuration(id)
);

CREATE TABLE search_configuration (
id INTEGER PRIMARY KEY,
equate_il INT NOT NULL,
filter_duplicates INT NOT NULL,
missing_cleavage_handling INT NOT NULL
);

CREATE TABLE peptide_trust (
assay_id TEXT NOT NULL,
missed_peptides TEXT NOT NULL,
matched_peptides INT NOT NULL,
searched_peptides INT NOT NULL,
PRIMARY KEY(assay_id)
);

CREATE TABLE storage_metadata (
assay_id TEXT NOT NULL,
configuration_id INT NOT NULL,
endpoint TEXT,
/*
Unique fingerprint hash for the data that has been stored on the hard drive for this specific combination of
assay configuration properties.
*/
fingerprint TEXT,
/*
Hash of the files that are stored on the local filesystem. This hash can be used to verify the integrity of the
files containing the offline result data on the filesystem. Value for this column is the concatenation of
the hash for both the data buffer and index buffer files.
*/
data_hash TEXT,
analysis_date TEXT,
PRIMARY KEY(assay_id),
FOREIGN KEY(configuration_id) REFERENCES search_configuration(id)
);

CREATE TABLE database_metadata (
application_version TEXT NOT NULL
);
14 changes: 14 additions & 0 deletions src/logic/filesystem/BufferUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export default class BufferUtils {
public static bufferToSharedArrayBuffer(buf: Buffer): SharedArrayBuffer {
const ab = new SharedArrayBuffer(buf.length);
const view = new Uint8Array(ab);
for (let i = 0; i < buf.length; ++i) {
view[i] = buf[i];
}
return ab;
}

public static arrayBufferToBuffer(buffer: ArrayBuffer): Buffer {
return Buffer.from(buffer);
}
}
18 changes: 3 additions & 15 deletions src/logic/filesystem/assay/processed/CachedResultsManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import SearchConfigManager from "@/logic/filesystem/configuration/SearchConfigMa
import StorageMetadataManager from "@/logic/filesystem/metadata/StorageMetadataManager";
import StorageMetadata from "@/logic/filesystem/metadata/StorageMetadata";
import PeptideTrustManager from "@/logic/filesystem/trust/PeptideTrustManager";
import BufferUtils from "@/logic/filesystem/BufferUtils";

export default class CachedResultsManager {
constructor(
Expand Down Expand Up @@ -188,19 +189,6 @@ export default class CachedResultsManager {
}
}

private arrayBufferToBuffer(buffer: ArrayBuffer): Buffer {
return Buffer.from(buffer);
}

private bufferToSharedArrayBuffer(buf: Buffer): SharedArrayBuffer {
const ab = new SharedArrayBuffer(buf.length);
const view = new Uint8Array(ab);
for (let i = 0; i < buf.length; ++i) {
view[i] = buf[i];
}
return ab;
}

/**
* Write the given assay and the corresponding data to the filesystem.
*
Expand Down Expand Up @@ -239,8 +227,8 @@ export default class CachedResultsManager {
const dataBufferPath = this.getDataBufferPath(assay);

try {
const indexBuffer = this.bufferToSharedArrayBuffer(await fs.readFile(indexBufferPath));
const dataBuffer = this.bufferToSharedArrayBuffer(await fs.readFile(dataBufferPath));
const indexBuffer = BufferUtils.bufferToSharedArrayBuffer(await fs.readFile(indexBufferPath));
const dataBuffer = BufferUtils.bufferToSharedArrayBuffer(await fs.readFile(dataBufferPath));

const output = new ShareableMap<Peptide, PeptideData>(0, 0, new PeptideDataSerializer());
output.setBuffers(indexBuffer, dataBuffer);
Expand Down
5 changes: 3 additions & 2 deletions src/logic/filesystem/database/DatabaseManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const app = electron.remote.app;

import path from "path";
import DatabaseMigratorV2ToV3 from "@/logic/filesystem/database/DatabaseMigratorV2ToV3";
import DatabaseMigratorV3ToV4 from "@/logic/filesystem/database/DatabaseMigratorV3ToV4";

export default class DatabaseManager {
// Reading and writing large assays to and from the database can easily take longer than 5 seconds, causing
Expand All @@ -29,7 +30,8 @@ export default class DatabaseManager {
private readonly migrations: (() => DatabaseMigrator)[] = [
() => new DatabaseMigratorV0ToV1(),
() => new DatabaseMigratorV1ToV2(path.dirname(this.dbLocation)),
() => new DatabaseMigratorV2ToV3(path.dirname(this.dbLocation))
() => new DatabaseMigratorV2ToV3(path.dirname(this.dbLocation)),
() => new DatabaseMigratorV3ToV4(path.dirname(this.dbLocation))
];

constructor(
Expand Down Expand Up @@ -88,7 +90,6 @@ export default class DatabaseManager {
*/
private checkAndUpgradeSchema(): void {
for (let currentSchema: number = this.schemaVersion; currentSchema < Schema.LATEST_VERSION; currentSchema++) {
console.log(currentSchema);
this.migrations[currentSchema]().upgrade(this.db);
this.db.pragma("user_version = " + (currentSchema + 1));
}
Expand Down
2 changes: 0 additions & 2 deletions src/logic/filesystem/database/DatabaseMigratorV2ToV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export default class DatabaseMigratorV2ToV3 implements DatabaseMigrator {
});
}

console.log(JSON.stringify(assays));

const studyData = database.prepare(
"SELECT * FROM studies"
).all();
Expand Down
Loading

0 comments on commit dd67317

Please sign in to comment.