Skip to content

Commit 7e558a1

Browse files
committed
refactor: prepare getWorkflowLandingUrl for alternative genome keys (#137)
1 parent 2e84f96 commit 7e558a1

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import { ANALYSIS_METHOD } from "./entities";
1+
import { ANALYSIS_METHOD, WORKFLOW_ID } from "./entities";
22

33
export const WORKFLOW_IDS_BY_ANALYSIS_METHOD: Partial<
4-
Record<ANALYSIS_METHOD, string>
4+
Record<ANALYSIS_METHOD, WORKFLOW_ID>
55
> = {
6-
[ANALYSIS_METHOD.REGULATION]:
7-
"https://dockstore.org/api/ga4gh/trs/v2/tools/#workflow/github.com/iwc-workflows/chipseq-pe/main/versions/v0.12",
6+
[ANALYSIS_METHOD.REGULATION]: WORKFLOW_ID.REGULATION,
87
};

app/apis/catalog/brc-analytics-catalog/common/entities.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ export interface EntitiesResponsePagination {
3434
size: number;
3535
total: number;
3636
}
37+
38+
export enum WORKFLOW_ID {
39+
REGULATION = "https://dockstore.org/api/ga4gh/trs/v2/tools/#workflow/github.com/iwc-workflows/chipseq-pe/main/versions/v0.12",
40+
}

app/utils/galaxy-api.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import ky from "ky";
2+
import { WORKFLOW_ID } from "../apis/catalog/brc-analytics-catalog/common/entities";
23

34
interface WorkflowLandingsBody {
4-
request_state: { reference_genome: string };
5+
request_state: WorkflowLandingsBodyRequestState;
56
workflow_id: string;
67
workflow_target_type: "trs_url";
78
}
89

10+
type WorkflowLandingsBodyRequestState = { reference_genome: string };
11+
912
interface WorkflowLanding {
1013
uuid: string;
1114
}
@@ -23,13 +26,11 @@ const WORKFLOW_LANDING_URL_PREFIX =
2326
* @returns workflow landing URL.
2427
*/
2528
export async function getWorkflowLandingUrl(
26-
workflowId: string,
29+
workflowId: WORKFLOW_ID,
2730
referenceGenome: string
2831
): Promise<string> {
2932
const body: WorkflowLandingsBody = {
30-
request_state: {
31-
reference_genome: referenceGenome,
32-
},
33+
request_state: getWorkflowLandingsRequestState(workflowId, referenceGenome),
3334
workflow_id: workflowId,
3435
workflow_target_type: "trs_url",
3536
};
@@ -42,3 +43,16 @@ export async function getWorkflowLandingUrl(
4243
const id = (await res.json()).uuid;
4344
return WORKFLOW_LANDING_URL_PREFIX + encodeURIComponent(id);
4445
}
46+
47+
/**
48+
* Get the appropriate `request_state` object for the given workflow ID and reference genome.
49+
* @param workflowId - Workflow ID.
50+
* @param referenceGenome - Reference genome.
51+
* @returns `request_state` value for the workflow landings request body.
52+
*/
53+
function getWorkflowLandingsRequestState(
54+
workflowId: WORKFLOW_ID,
55+
referenceGenome: string
56+
): WorkflowLandingsBodyRequestState {
57+
return { reference_genome: referenceGenome };
58+
}

0 commit comments

Comments
 (0)