Skip to content

Commit

Permalink
refactor: prepare getWorkflowLandingUrl for alternative genome keys (
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterckx committed Oct 22, 2024
1 parent 9c93df7 commit 02d4565
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
7 changes: 3 additions & 4 deletions app/apis/catalog/brc-analytics-catalog/common/constants.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { ANALYSIS_METHOD } from "./entities";
import { ANALYSIS_METHOD, WORKFLOW_ID } from "./entities";

export const WORKFLOW_IDS_BY_ANALYSIS_METHOD: Partial<
Record<ANALYSIS_METHOD, string>
Record<ANALYSIS_METHOD, WORKFLOW_ID>
> = {
[ANALYSIS_METHOD.REGULATION]:
"https://dockstore.org/api/ga4gh/trs/v2/tools/#workflow/github.com/iwc-workflows/chipseq-pe/main/versions/v0.12",
[ANALYSIS_METHOD.REGULATION]: WORKFLOW_ID.REGULATION,
};
4 changes: 4 additions & 0 deletions app/apis/catalog/brc-analytics-catalog/common/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ export interface EntitiesResponsePagination {
size: number;
total: number;
}

export enum WORKFLOW_ID {
REGULATION = "https://dockstore.org/api/ga4gh/trs/v2/tools/#workflow/github.com/iwc-workflows/chipseq-pe/main/versions/v0.12",
}
24 changes: 19 additions & 5 deletions app/utils/galaxy-api.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import ky from "ky";
import { WORKFLOW_ID } from "../apis/catalog/brc-analytics-catalog/common/entities";

interface WorkflowLandingsBody {
request_state: { reference_genome: string };
request_state: WorkflowLandingsBodyRequestState;
workflow_id: string;
workflow_target_type: "trs_url";
}

type WorkflowLandingsBodyRequestState = { reference_genome: string };

interface WorkflowLanding {
uuid: string;
}
Expand All @@ -23,13 +26,11 @@ const WORKFLOW_LANDING_URL_PREFIX =
* @returns workflow landing URL.
*/
export async function getWorkflowLandingUrl(
workflowId: string,
workflowId: WORKFLOW_ID,
referenceGenome: string
): Promise<string> {
const body: WorkflowLandingsBody = {
request_state: {
reference_genome: referenceGenome,
},
request_state: getWorkflowLandingsRequestState(workflowId, referenceGenome),
workflow_id: workflowId,
workflow_target_type: "trs_url",
};
Expand All @@ -42,3 +43,16 @@ export async function getWorkflowLandingUrl(
const id = (await res.json()).uuid;
return WORKFLOW_LANDING_URL_PREFIX + encodeURIComponent(id);
}

/**
* Get the appropriate `request_state` object for the given workflow ID and reference genome.
* @param workflowId - Workflow ID.
* @param referenceGenome - Reference genome.
* @returns `request_state` value for the workflow landings request body.
*/
function getWorkflowLandingsRequestState(
workflowId: WORKFLOW_ID,
referenceGenome: string
): WorkflowLandingsBodyRequestState {
return { reference_genome: referenceGenome };
}

0 comments on commit 02d4565

Please sign in to comment.