Skip to content

Commit

Permalink
Multi blast 3 (#47)
Browse files Browse the repository at this point in the history
* revert to mblast v3

* add proxy for multi-blast
  • Loading branch information
dmfalke authored Apr 10, 2023
1 parent 7105682 commit abce757
Show file tree
Hide file tree
Showing 47 changed files with 1,692 additions and 2,668 deletions.
31 changes: 17 additions & 14 deletions packages/libs/multi-blast/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import React, { Suspense } from 'react';
import { Redirect, RouteComponentProps } from 'react-router';
import { RecoilRoot } from 'recoil';
import { initialize } from '@veupathdb/web-common/lib/bootstrap';
import { ResultTableSummaryViewPlugin } from '@veupathdb/wdk-client/lib/Plugins';
import {
BlastSummaryViewPlugin,
GenomeSummaryViewPlugin,
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 @@ -13,9 +17,6 @@ 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 @@ -69,11 +70,12 @@ 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 @@ -91,21 +93,22 @@ initialize({
name: '_default',
component: ResultTableSummaryViewPlugin,
},
{
type: 'summaryView',
name: 'genomic-view',
component: GenomeSummaryViewPlugin,
},
{
type: 'summaryView',
name: 'blast-view',
component: BlastSummaryViewController,
component: BlastSummaryViewPlugin,
},
{
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
101 changes: 53 additions & 48 deletions packages/libs/multi-blast/src/lib/components/BlastForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,14 @@ import {
import { InputErrors } from '../utils/ServiceTypes';
import {
ADVANCED_PARAMS_GROUP_NAME,
ParamNames,
BLAST_ALGORITHM_PARAM_NAME,
BLAST_DATABASE_ORGANISM_PARAM_NAME,
BLAST_DATABASE_TYPE_PARAM_NAME,
BLAST_QUERY_SEQUENCE_PARAM_NAME,
JOB_DESCRIPTION_PARAM_NAME,
isOmittedParam,
organismParamValueToFilenames,
paramValuesToBlastConfig,
transformOrganismParameter,
} from '../utils/params';
import { fetchOrganismToFilenameMaps } from '../utils/organisms';
Expand All @@ -69,7 +74,6 @@ 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 @@ -83,7 +87,7 @@ export interface Props extends DefaultQuestionFormProps {
}

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

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

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

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

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

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

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

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

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

const renderBlastParamGroup = useCallback(
Expand Down Expand Up @@ -340,7 +345,7 @@ function BlastFormWithTransformedQuestion(props: Props) {
errors: {
general: [],
byKey: {
[ParamNames.BlastQuerySequence]: [validationError],
[BLAST_QUERY_SEQUENCE_PARAM_NAME]: [validationError],
},
},
},
Expand Down Expand Up @@ -383,9 +388,8 @@ function NewJobForm(props: NewJobFormProps) {
const containerRef = useRef<HTMLDivElement>(null);

const [submitting, setSubmitting] = useState(false);
const [inputErrors, setInputErrors] = useState<InputErrors | undefined>(
undefined
);
const [inputErrors, setInputErrors] =
useState<InputErrors | undefined>(undefined);
const dependentParamsAreUpdating = useDependentParamsAreUpdating(
props.state.question,
props.state.paramsUpdatingDependencies
Expand Down Expand Up @@ -425,7 +429,8 @@ function NewJobForm(props: NewJobFormProps) {

setSubmitting(true);

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

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

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

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

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]
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
);

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

setSubmitting(false);

Expand Down Expand Up @@ -520,21 +526,20 @@ function transformFormQuestion(
): Props {
const transformedParameters = formProps.state.question.parameters.reduce(
(memo, parameter) => {
if (parameter.name === ParamNames.JobDescription && !isMultiBlast) {
if (parameter.name === JOB_DESCRIPTION_PARAM_NAME && !isMultiBlast) {
return memo;
} else if (
parameter.name === ParamNames.BlastQuerySequence &&
parameter.name === BLAST_QUERY_SEQUENCE_PARAM_NAME &&
isMultiBlast
) {
memo.push({
...parameter,
displayName: 'Input Sequence(s)',
help:
'Paste your Input Sequence(s) in the text box, or upload a FASTA file.',
help: 'Paste your Input Sequence(s) in the text box, or upload a FASTA file.',
});

return memo;
} else if (parameter.name === ParamNames.BlastDatabaseOrganism) {
} else if (parameter.name === BLAST_DATABASE_ORGANISM_PARAM_NAME) {
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;
summary: string | null;
description: string | null;
created: string;
status: 'queued' | 'running' | 'finished' | 'expired' | 'errored';
}

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

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

0 comments on commit abce757

Please sign in to comment.