Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Multi blast 3 (#47)" #49

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions packages/libs/multi-blast/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import React, { Suspense } from 'react';
import { Redirect, RouteComponentProps } from 'react-router';
import { RecoilRoot } from 'recoil';
import { initialize } from '@veupathdb/web-common/lib/bootstrap';
import {
BlastSummaryViewPlugin,
GenomeSummaryViewPlugin,
ResultTableSummaryViewPlugin,
} from '@veupathdb/wdk-client/lib/Plugins';
import { ResultTableSummaryViewPlugin } from '@veupathdb/wdk-client/lib/Plugins';
import { RouteEntry } from '@veupathdb/wdk-client/lib/Core/RouteEntry';
import { ClientPluginRegistryEntry } from '@veupathdb/wdk-client/lib/Utils/ClientPlugin';

Expand All @@ -17,6 +13,9 @@ import {
} from '@veupathdb/preferred-organisms/lib/components/OrganismParam';
import { PreferredOrganismsConfigController } from '@veupathdb/preferred-organisms/lib/controllers/PreferredOrganismsConfigController';

import BlastSummaryViewController from '@veupathdb/blast-summary-view/lib/Controllers/BlastSummaryViewController';
import * as blastSummaryViewStoreModule from '@veupathdb/blast-summary-view/lib/StoreModules/BlastSummaryViewStoreModule';

import Header from './Header';
import Home from './Home';
import { endpoint, rootElement, rootUrl } from './constants';
Expand Down Expand Up @@ -70,12 +69,11 @@ initialize({
],
componentWrappers: {
SiteHeader: () => Header,
Page: (DefaultComponent: React.ComponentType) => (props: any) =>
(
<RecoilRoot>
<DefaultComponent {...props} />
</RecoilRoot>
),
Page: (DefaultComponent: React.ComponentType) => (props: any) => (
<RecoilRoot>
<DefaultComponent {...props} />
</RecoilRoot>
),
},
pluginConfig: [
{
Expand All @@ -93,22 +91,21 @@ initialize({
name: '_default',
component: ResultTableSummaryViewPlugin,
},
{
type: 'summaryView',
name: 'genomic-view',
component: GenomeSummaryViewPlugin,
},
{
type: 'summaryView',
name: 'blast-view',
component: BlastSummaryViewPlugin,
component: BlastSummaryViewController,
},
{
type: 'questionFormParameter',
test: ({ parameter }) => parameter != null && isOrganismParam(parameter),
component: OrganismParam,
},
] as ClientPluginRegistryEntry<any>[],
wrapStoreModules: (storeModules: any) => ({
...storeModules,
[blastSummaryViewStoreModule.key]: blastSummaryViewStoreModule,
}),
wrapWdkService,
endpoint,
} as any);
Expand Down
86 changes: 40 additions & 46 deletions packages/libs/multi-blast/src/lib/components/BlastForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,9 @@ import {
import { InputErrors } from '../utils/ServiceTypes';
import {
ADVANCED_PARAMS_GROUP_NAME,
BLAST_ALGORITHM_PARAM_NAME,
BLAST_DATABASE_ORGANISM_PARAM_NAME,
BLAST_DATABASE_TYPE_PARAM_NAME,
BLAST_QUERY_SEQUENCE_PARAM_NAME,
JOB_DESCRIPTION_PARAM_NAME,
ParamNames,
isOmittedParam,
organismParamValueToFilenames,
paramValuesToBlastConfig,
transformOrganismParameter,
} from '../utils/params';
import { fetchOrganismToFilenameMaps } from '../utils/organisms';
Expand All @@ -74,6 +69,7 @@ import { AdvancedParamGroup } from './AdvancedParamGroup';
import { BlastFormValidationInfo } from './BlastFormValidationInfo';

import './BlastForm.scss';
import { paramValuesToBlastQueryConfig } from '../utils/params-to-query-config';

export const blastFormCx = makeClassNameHelper('wdk-QuestionForm');

Expand All @@ -87,7 +83,7 @@ export interface Props extends DefaultQuestionFormProps {
}

export function BlastForm(props: Props) {
const targetType = props.state.paramValues[BLAST_DATABASE_TYPE_PARAM_NAME];
const targetType = props.state.paramValues[ParamNames.BlastDatabaseType];
const targetMetadataByDataType = useContext(TargetMetadataByDataType);

const formPropsWithTransformedQuestion = transformFormQuestion(
Expand All @@ -104,10 +100,10 @@ export function BlastForm(props: Props) {
function BlastFormWithTransformedQuestion(props: Props) {
const canChangeRecordType = props.canChangeRecordType ?? false;

const targetType = props.state.paramValues[BLAST_DATABASE_TYPE_PARAM_NAME];
const targetType = props.state.paramValues[ParamNames.BlastDatabaseType];

const selectedBlastAlgorithm =
props.state.paramValues[BLAST_ALGORITHM_PARAM_NAME];
props.state.paramValues[ParamNames.BlastAlgorithm];

const restrictedAdvancedParamGroup = useMemo(() => {
const fullAdvancedParamGroup =
Expand All @@ -130,7 +126,7 @@ function BlastFormWithTransformedQuestion(props: Props) {
const enabledAlgorithms = useEnabledAlgorithms(targetType);

const updateQueryParam = useChangeParamValue(
props.state.question.parametersByName[BLAST_QUERY_SEQUENCE_PARAM_NAME],
props.state.question.parametersByName[ParamNames.BlastQuerySequence],
props.state,
props.eventHandlers.updateParamValue
);
Expand All @@ -154,7 +150,7 @@ function BlastFormWithTransformedQuestion(props: Props) {
);

const selectedBlastAlgorithmParameter =
props.state.question.parametersByName[BLAST_ALGORITHM_PARAM_NAME];
props.state.question.parametersByName[ParamNames.BlastAlgorithm];

const searchName = props.state.question.urlSegment;
const dispatchAction = props.dispatchAction;
Expand Down Expand Up @@ -211,13 +207,13 @@ function BlastFormWithTransformedQuestion(props: Props) {
const targetParamElement = (
<RadioList
{...targetParamProps}
name={`${props.state.question.urlSegment}/${BLAST_DATABASE_TYPE_PARAM_NAME}`}
name={`${props.state.question.urlSegment}/${ParamNames.BlastDatabaseType}`}
/>
);
const algorithmParamElement = (
<RadioList
{...algorithmParamProps}
name={`${props.state.question.urlSegment}/${BLAST_ALGORITHM_PARAM_NAME}`}
name={`${props.state.question.urlSegment}/${ParamNames.BlastAlgorithm}`}
/>
);
const sequenceParamElement = (
Expand All @@ -229,18 +225,18 @@ function BlastFormWithTransformedQuestion(props: Props) {
</div>
<TextArea
{...sequenceParamProps}
name={`${props.state.question.urlSegment}/${BLAST_QUERY_SEQUENCE_PARAM_NAME}`}
name={`${props.state.question.urlSegment}/${ParamNames.BlastQuerySequence}`}
/>
<input
type="file"
accept="text/*"
name={`${props.state.question.urlSegment}/${BLAST_QUERY_SEQUENCE_PARAM_NAME}__file`}
name={`${props.state.question.urlSegment}/${ParamNames.BlastQuerySequence}__file`}
onChange={onQueryFileInputChanged}
/>
</div>
);
const dynamicOrganismParam =
props.state.question.parametersByName[BLAST_DATABASE_ORGANISM_PARAM_NAME];
props.state.question.parametersByName[ParamNames.BlastDatabaseOrganism];
const organismParamElement = (
<Plugin
context={{
Expand All @@ -257,8 +253,8 @@ function BlastFormWithTransformedQuestion(props: Props) {
paramValues: props.state.paramValues,
},
parameter: dynamicOrganismParam,
value: props.state.paramValues[BLAST_DATABASE_ORGANISM_PARAM_NAME],
uiState: props.state.paramUIState[BLAST_DATABASE_ORGANISM_PARAM_NAME],
value: props.state.paramValues[ParamNames.BlastDatabaseOrganism],
uiState: props.state.paramUIState[ParamNames.BlastDatabaseOrganism],
onParamValueChange: (paramValue: string) => {
props.eventHandlers.updateParamValue({
searchName: props.state.question.urlSegment,
Expand All @@ -275,10 +271,10 @@ function BlastFormWithTransformedQuestion(props: Props) {

const parameterElements = {
...props.parameterElements,
[BLAST_DATABASE_TYPE_PARAM_NAME]: targetParamElement,
[BLAST_ALGORITHM_PARAM_NAME]: algorithmParamElement,
[BLAST_QUERY_SEQUENCE_PARAM_NAME]: sequenceParamElement,
[BLAST_DATABASE_ORGANISM_PARAM_NAME]: organismParamElement,
[ParamNames.BlastDatabaseType]: targetParamElement,
[ParamNames.BlastAlgorithm]: algorithmParamElement,
[ParamNames.BlastQuerySequence]: sequenceParamElement,
[ParamNames.BlastDatabaseOrganism]: organismParamElement,
};

const renderBlastParamGroup = useCallback(
Expand Down Expand Up @@ -345,7 +341,7 @@ function BlastFormWithTransformedQuestion(props: Props) {
errors: {
general: [],
byKey: {
[BLAST_QUERY_SEQUENCE_PARAM_NAME]: [validationError],
[ParamNames.BlastQuerySequence]: [validationError],
},
},
},
Expand Down Expand Up @@ -429,8 +425,7 @@ function NewJobForm(props: NewJobFormProps) {

setSubmitting(true);

const targetType =
props.state.paramValues[BLAST_DATABASE_TYPE_PARAM_NAME];
const targetType = props.state.paramValues[ParamNames.BlastDatabaseType];

const [projectId, { organismsToFiles }] = await Promise.all([
wdkDependencies.wdkService
Expand All @@ -446,33 +441,32 @@ function NewJobForm(props: NewJobFormProps) {
const dbTargetName = targetTypeTermToDbName(targetType);

const selectedOrganismFilenames = organismParamValueToFilenames(
props.state.paramValues[BLAST_DATABASE_ORGANISM_PARAM_NAME],
props.state.paramValues[ParamNames.BlastDatabaseOrganism],
organismsToFiles
);

const targets = selectedOrganismFilenames.map((organism) => ({
organism,
target: `${organism}${dbTargetName}`,
targetDisplayName: organism,
targetFile: `${organism}${dbTargetName}`,
}));

const query = props.state.paramValues[BLAST_QUERY_SEQUENCE_PARAM_NAME];

const config = paramValuesToBlastConfig(props.state.paramValues);

const jobDescription =
props.state.paramValues[JOB_DESCRIPTION_PARAM_NAME];

const createJobResult = await api.createJob(
projectId,
targets,
query,
config,
0,
jobDescription
const createJobResult = await api.queryAPI.createJob(
{
jobConfig: {
targets: targets,
addToUserCollection: true,
site: projectId,
},
blastConfig: paramValuesToBlastQueryConfig(props.state.paramValues),
userMeta: {
summary: props.state.paramValues[ParamNames.JobDescription],
},
},
props.state.paramValues[ParamNames.BlastQuerySequence]
);

if (createJobResult.status === 'ok') {
const jobId = createJobResult.value.jobId;
const jobId = createJobResult.value.queryJobID;

setSubmitting(false);

Expand Down Expand Up @@ -526,10 +520,10 @@ function transformFormQuestion(
): Props {
const transformedParameters = formProps.state.question.parameters.reduce(
(memo, parameter) => {
if (parameter.name === JOB_DESCRIPTION_PARAM_NAME && !isMultiBlast) {
if (parameter.name === ParamNames.JobDescription && !isMultiBlast) {
return memo;
} else if (
parameter.name === BLAST_QUERY_SEQUENCE_PARAM_NAME &&
parameter.name === ParamNames.BlastQuerySequence &&
isMultiBlast
) {
memo.push({
Expand All @@ -548,7 +542,7 @@ function transformFormQuestion(
});

return memo;
} else if (parameter.name === BLAST_DATABASE_ORGANISM_PARAM_NAME) {
} else if (parameter.name === ParamNames.BlastDatabaseOrganism) {
const organismParameter = transformOrganismParameter(
parameter,
targetRecordType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import './BlastWorkspaceAll.scss';

export interface JobRow {
jobId: string;
description: string | null;
summary: string | null;
created: string;
status: 'queued' | 'running' | 'finished' | 'expired' | 'errored';
}

export function BlastWorkspaceAll() {
const blastApi = useBlastApi();
const jobRows = useRawJobRows(blastApi);
const jobRows = useRawJobRows(blastApi.queryAPI);

return (
<div className="BlastWorkspaceAll">
Expand Down
Loading
Loading