Skip to content

Commit

Permalink
Support for the Crate generated by onlly Sapporo
Browse files Browse the repository at this point in the history
  • Loading branch information
suecharo committed Sep 18, 2022
1 parent 4a98750 commit 6a9dc11
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 53 deletions.
95 changes: 44 additions & 51 deletions src/crate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface CrateSummary {
startTime: Date;
endTime: Date;
duration: ReturnType<typeof datetime.difference>;
exitCode: number;
exitCode: string;
state: string;
wfAttachments: string[];
intermediateFiles: string[];
Expand Down Expand Up @@ -93,48 +93,45 @@ export class Crate {
}

summarize(): void {
const unknownToStr = (val: unknown) => {
return val == undefined ? "" : `${val}`;
};

try {
// General Metadata
const wfName = `${this.getValRecursively(this.mainWf, ["name"])}`;
const wfVersion = `${this.getValRecursively(this.mainWf, ["version"])}`;
const wfId = `${this.getValRecursively(this.mainWf, ["yevisId"])}`;
const wfType = `${
this.getValRecursively(this.mainWf, [
"programmingLanguage",
"name",
])
}`;
const wfTypeVersion = `${
this.getValRecursively(this.mainWf, [
"programmingLanguage",
"version",
])
}`;
const exitCode = this.getValRecursively(this.testResult, [
"exitCode",
]);
if (typeof exitCode !== "number") {
throw new Error(`Invalid exit code ${exitCode}`);
}
const state = `${this.getValRecursively(this.testResult, ["state"])}`;
const testId = `${
this.getValRecursively(this.testDefinition, ["yevisTestId"])
}`;
const sapporoVersion = `${
this.getValRecursively(this.testInstance, ["version"])
}`;
const wfEngineName = `${
this.getValRecursively(this.testDefinition, [
"conformsTo",
"name",
])
}`;
const wfEngineVersion = `${
this.getValRecursively(this.testDefinition, [
"conformsTo",
"version",
])
}`;
const wfName = unknownToStr(
this.getValRecursively(this.mainWf, ["name"]),
);
const wfVersion = unknownToStr(
this.getValRecursively(this.mainWf, ["version"]),
);
const wfId = unknownToStr(
this.getValRecursively(this.mainWf, ["yevisId"]),
);
const wfType = unknownToStr(
this.getValRecursively(this.mainWf, ["programmingLanguage", "name"]),
);
const wfTypeVersion = unknownToStr(
this.getValRecursively(this.mainWf, ["programmingLanguage", "version"]),
);
const exitCode = unknownToStr(
this.getValRecursively(this.testResult, ["exitCode"]),
);
const state = unknownToStr(
this.getValRecursively(this.testResult, ["state"]),
);
const testId = unknownToStr(
this.getValRecursively(this.testDefinition, ["yevisTestId"]),
);
const sapporoVersion = unknownToStr(
this.getValRecursively(this.testInstance, ["runsOn", "version"]),
);
const wfEngineName = unknownToStr(
this.getValRecursively(this.testDefinition, ["conformsTo", "name"]),
);
const wfEngineVersion = unknownToStr(
this.getValRecursively(this.testDefinition, ["conformsTo", "version"]),
);

// File IDs
let wfAttachments: string[] = [];
Expand All @@ -158,22 +155,18 @@ export class Crate {
const outputsWithEdam = this.filterHasEdam(outputs);

// Time
const startTimeStr = `${
this.getValRecursively(this.testResult, [
"startTime",
])
}`;
const startTimeStr = unknownToStr(
this.getValRecursively(this.testResult, ["startTime"]),
);
let startTime: Date;
try {
startTime = utils.parseDatetime(startTimeStr);
} catch (_) {
throw new Error(`Invalid start time ${startTimeStr}`);
}
const endTimeStr = `${
this.getValRecursively(this.testResult, [
"endTime",
])
}`;
const endTimeStr = unknownToStr(
this.getValRecursively(this.testResult, ["endTime"]),
);
let endTime: Date;
try {
endTime = utils.parseDatetime(endTimeStr);
Expand Down
12 changes: 10 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ $ deno test -A ./tests/rnaseq_v3.6_test.ts
# RNA-seq (Linux, 1st) <-> RNA-seq (Linux, small)
$ deno test -A ./tests/rnaseq_small_test.ts

# RNA-seq (Linux, with yevis) <-> RNA-seq (Linux, only sapporo)
$ deno test -A ./tests/rnaseq_only_sapporo_test.ts

# Trimming (Linux) <-> Trimming (Mac)
$ deno test -A ./tests/trimming_mac_test.ts
```
Expand All @@ -54,6 +57,7 @@ example_crate/
├── rnaseq_1st.json
├── rnaseq_2nd.json
├── rnaseq_mac.json
├── rnaseq_only_sapporo.json
├── rnaseq_small.json
├── rnaseq_v3.6.json
├── trimming.json
Expand All @@ -72,8 +76,8 @@ About the environment in which the crate was generated.
| CPU Architecture | `x86_64` | `arm64` |
| Memory | `24.0 GiB` | `64.0 GiB` |
| Docker version | `20.10.8` | `20.10.16` |
| Sapporo-service version | `1.4.6` | `1.4.6` |
| Yevis-cli version | `0.5.3` | `0.5.3` |
| Sapporo-service version | `1.4.8` | `1.4.8` |
| Yevis-cli version | `0.5.4` | `0.5.4` |

### GATK

Expand Down Expand Up @@ -107,6 +111,10 @@ $ yevis test --fetch-ro-crate https://raw.githubusercontent.com/sapporo-wes/test
- [`rnaseq_v3.6.json`](./example_crate/rnaseq_v3.6.json)
- Crate generated on `Linux` environment.
- Using `nf-core/rnaseq` version is `3.6`. (Normal one is `3.7`)
- [`rnaseq_only_sapporo.json`](./example_crate/rnaseq_only_sapporo.json)
- Crate generated on `Linux` environment.
- Using `nf-core/rnaseq` version is `3.7`.
- Using `Sapporo` only. (Not using `Yevis`)

See https://github.com/sapporo-wes/test-workflow#nf-corernaseq for more details about the executed workflow.

Expand Down
15 changes: 15 additions & 0 deletions tests/rnaseq_only_sapporo_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { args, compare, crate } from "../src/mod.ts";

const CRATE_DIR = `${new URL(".", import.meta.url).pathname}example_crate`;

Deno.test("RNA-seq using only Sapporo test", async () => {
const loc1 = `${CRATE_DIR}/rnaseq_1st.json`;
const loc2 = `${CRATE_DIR}/rnaseq_only_sapporo.json`;

const parsedArgs = await args.parseArgs([loc1, loc2]);
const crate1 = new crate.Crate(parsedArgs.loc1);
await crate1.initialize();
const crate2 = new crate.Crate(parsedArgs.loc2);
await crate2.initialize();
compare.compare(crate1, crate2, parsedArgs.all, parsedArgs.threshold);
});

0 comments on commit 6a9dc11

Please sign in to comment.