Skip to content

Commit

Permalink
Merge pull request #164 from unipept/fix/demo-project-unreadable
Browse files Browse the repository at this point in the history
Fix for unreadable demo projects
  • Loading branch information
pverscha authored Mar 30, 2022
2 parents 40b2b73 + c248a14 commit 97ef36a
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 19 deletions.
9 changes: 0 additions & 9 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
'left': isMini ? '55px' : (toolbarWidth + 55) + 'px'
}"
class="main-container">
<v-alert type="warning" class="ma-2" v-if="isDemoProjectActive">
You are currently browsing the demo project. Changes made to this project will not be saved.
</v-alert>
<router-view style="min-height: 100%;"></router-view>
<v-dialog v-model="errorDialog" persistent max-width="600">
<v-card>
Expand Down Expand Up @@ -130,12 +127,6 @@ export default class App extends Vue implements ErrorListener {
private showHomePageDialog: boolean = true;
private errorDialog: boolean = false;
get isDemoProjectActive(): boolean {
const projectLocation: string = this.$store.getters.projectLocation;
const tempPath: string = app.getPath("temp");
return projectLocation && projectLocation.includes(tempPath);
}
async mounted() {
// Connect with the electron-renderer thread and listen to navigation events that take place. All navigation
// should pass through the Vue app.
Expand Down
13 changes: 13 additions & 0 deletions src/components/pages/analysis/AnalysisPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,16 @@
'float': 'right'
}">

<v-alert type="warning" class="ma-2" v-if="isDemoProjectActive">
You are currently browsing the demo project. Changes made to this project will not be saved.
</v-alert>

<!-- Show analysis results for the currently selected assay if it's ready with processing -->
<v-container
v-if="!errorStatus && activeAssay && activeAssay.analysisReady"
fluid
class="pt-0">

<router-view></router-view>
</v-container>

Expand Down Expand Up @@ -142,6 +147,8 @@ import CreateAssayDialog from "@/components/assay/CreateAssayDialog.vue";
import ProgressReportSummary from "@/components/analysis/ProgressReportSummary.vue";
import { Watch } from "vue-property-decorator";
const { app } = require("electron").remote;
@Component({
components: {
ProgressReportSummary,
Expand Down Expand Up @@ -194,6 +201,12 @@ export default class AnalysisPage extends Vue {
return this.activeAssay?.originalProgress;
}
get isDemoProjectActive(): boolean {
const projectLocation: string = this.$store.getters.projectLocation;
const tempPath: string = app.getPath("temp");
return projectLocation && projectLocation.includes(tempPath);
}
private reanalyse() {
if (this.activeAssay) {
this.$store.dispatch("analyseAssay", this.activeAssay.assay);
Expand Down
23 changes: 19 additions & 4 deletions src/logic/filesystem/assay/AssayFileSystemDataReader.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import FileSystemAssayVisitor from "@/logic/filesystem/assay/FileSystemAssayVisitor";
import { ProteomicsAssay, IOException, QueueManager, Assay, Study, SearchConfiguration } from "unipept-web-components";
import {
ProteomicsAssay,
IOException,
QueueManager,
Assay,
Study,
SearchConfiguration,
NetworkConfiguration
} from "unipept-web-components";
import { promises as fs } from "fs";
import Worker from "worker-loader?inline=fallback!./AssayFileSystemDataReader.worker";
import { Database } from "better-sqlite3";
Expand All @@ -10,6 +18,7 @@ import DatabaseManager from "@/logic/filesystem/database/DatabaseManager";
import AnalysisSourceSerializer from "@/logic/filesystem/analysis/AnalysisSourceSerializer";
import SearchConfigManager from "@/logic/filesystem/configuration/SearchConfigManager";
import StorageMetadataManager from "@/logic/filesystem/metadata/StorageMetadataManager";
import CachedOnlineAnalysisSource from "@/logic/communication/analysis/CachedOnlineAnalysisSource";

export default class AssayFileSystemDataReader extends FileSystemAssayVisitor {
private static inProgress: Promise<string[]>;
Expand Down Expand Up @@ -67,7 +76,6 @@ export default class AssayFileSystemDataReader extends FileSystemAssayVisitor {

const searchConfigMng = new SearchConfigManager(this.dbManager);

mpAssay.setName(assayRow.name);
mpAssay.setSearchConfiguration(await searchConfigMng.readSearchConfig(assayRow.configuration_id));
mpAssay.setAnalysisSource(
await AnalysisSourceSerializer.deserializeAnalysisSource(
Expand All @@ -82,8 +90,15 @@ export default class AssayFileSystemDataReader extends FileSystemAssayVisitor {
mpAssay.setDate(metadata.analysisDate);
}
} else {
// Throw an exception, the assay was not found in the database
throw new IOException("Requested assay was not found in the database!");
mpAssay.setSearchConfiguration(new SearchConfiguration());
mpAssay.setAnalysisSource(
new CachedOnlineAnalysisSource(
NetworkConfiguration.BASE_URL,
mpAssay,
this.dbManager,
this.projectLocation
)
);
}
}
}
2 changes: 0 additions & 2 deletions src/logic/filesystem/assay/AssayFileSystemDataWriter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export default class AssayFileSystemDataWriter extends FileSystemAssayVisitor {
}

public async visitProteomicsAssay(mpAssay: ProteomicsAssay): Promise<void> {
console.log("Visit from writer...");

// Write search configuration to database
const config = mpAssay.getSearchConfiguration();

Expand Down
12 changes: 8 additions & 4 deletions src/logic/filesystem/study/StudyFileSystemDataReader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import FileSystemStudyVisitor from "./FileSystemStudyVisitor";
import * as fs from "fs";
import path from "path";
import AssayFileSystemDataReader from "@/logic/filesystem/assay/AssayFileSystemDataReader";
import { Study, Assay, ProteomicsAssay, AssayVisitor, IOException } from "unipept-web-components";
import { Study, Assay, ProteomicsAssay, AssayVisitor, IOException, NetworkConfiguration } from "unipept-web-components";
import { Database } from "better-sqlite3";
import DatabaseManager from "@/logic/filesystem/database/DatabaseManager";
import AssayFileSystemDataWriter from "@/logic/filesystem/assay/AssayFileSystemDataWriter";
import CachedOnlineAnalysisSource from "@/logic/communication/analysis/CachedOnlineAnalysisSource";


/**
Expand Down Expand Up @@ -34,7 +35,7 @@ export default class StudyFileSystemDataReader extends FileSystemStudyVisitor {
for (const file of files.filter(name => name.endsWith(".pep"))) {
const assayName: string = path.basename(file).replace(".pep", "");

let assay: Assay;
let assay: ProteomicsAssay;

const row = await this.dbManager.performQuery<any>((db: Database) => {
return db.prepare(
Expand All @@ -54,12 +55,15 @@ export default class StudyFileSystemDataReader extends FileSystemStudyVisitor {
assay = new ProteomicsAssay();
assay.setName(assayName);

const assayVisitor: AssayVisitor = new AssayFileSystemDataWriter(
const assayReader = new AssayFileSystemDataReader(this.studyPath, this.dbManager, this.projectLocation);
await assay.accept(assayReader);

const assayWriter: AssayVisitor = new AssayFileSystemDataWriter(
this.studyPath,
this.dbManager,
study
);
await assay.accept(assayVisitor);
await assay.accept(assayWriter);
}

study.addAssay(assay);
Expand Down

0 comments on commit 97ef36a

Please sign in to comment.