-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added initial implementation for VEP options - Fetching a config with VEP options - Currently, the config is mocked - Displaying checkboxes for options to include gene symbols and transcript biotypes in the analysis - Showing the transcript set selector with data from the config - Enabled visibility rules around the form, and rules for form completeness - The options section only shows up after user's input for variants has been committed - If user's variants input has been committed, it shows up in the collapsed view of the variants section - The "Run" button that submits the form gets enabled only in presence of a selected species, user's input, and form parameters - Enabled VEP form submission - According to the agreed-upon api spec, user's plain-text input is transformed into a file at submission
- Loading branch information
Showing
21 changed files
with
821 additions
and
63 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
src/content/app/tools/vep/components/form-section/FormSection.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
src/content/app/tools/vep/components/vep-submit-button/VepSubmitButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { useAppSelector } from 'src/store'; | ||
|
||
import { | ||
getSelectedSpecies, | ||
getVepFormParameters, | ||
getVepFormInputText, | ||
getVepFormInputFile, | ||
getVepFormInputCommittedFlag | ||
} from 'src/content/app/tools/vep/state/vep-form/vepFormSelectors'; | ||
|
||
import { useVepFormSubmissionMutation } from 'src/content/app/tools/vep/state/vep-api/vepApiSlice'; | ||
|
||
import { PrimaryButton } from 'src/shared/components/button/Button'; | ||
|
||
import type { | ||
VEPSubmissionPayload, | ||
VepSelectedSpecies | ||
} from 'src/content/app/tools/vep/types/vepSubmission'; | ||
|
||
const VepSubmitButton = () => { | ||
const selectedSpecies = useAppSelector(getSelectedSpecies); | ||
const inputText = useAppSelector(getVepFormInputText); | ||
const inputFile = useAppSelector(getVepFormInputFile); | ||
const formParameters = useAppSelector(getVepFormParameters); | ||
const isInputCommitted = useAppSelector(getVepFormInputCommittedFlag); | ||
const [submitVepForm] = useVepFormSubmissionMutation(); | ||
|
||
const canSubmit = Boolean( | ||
selectedSpecies && | ||
(inputText || inputFile) && | ||
Object.keys(formParameters).length && | ||
isInputCommitted | ||
); | ||
|
||
const onSubmit = () => { | ||
const payload = preparePayload({ | ||
species: selectedSpecies as VepSelectedSpecies, | ||
inputText, | ||
inputFile, | ||
parameters: formParameters | ||
}); | ||
|
||
submitVepForm(payload); | ||
}; | ||
|
||
return ( | ||
<PrimaryButton disabled={!canSubmit} onClick={onSubmit}> | ||
Run | ||
</PrimaryButton> | ||
); | ||
}; | ||
|
||
const preparePayload = ({ | ||
species, | ||
inputText, | ||
inputFile, | ||
parameters | ||
}: { | ||
species: VepSelectedSpecies; | ||
inputText: string; | ||
inputFile: File | null; | ||
parameters: Record<string, unknown>; | ||
}): VEPSubmissionPayload => { | ||
if (inputText) { | ||
inputFile = new File([inputText], 'input.txt', { | ||
type: 'text/plain' | ||
}); | ||
} | ||
|
||
return { | ||
genome_id: species.genome_id, | ||
input_file: inputFile as File, | ||
parameters: JSON.stringify(parameters) | ||
}; | ||
}; | ||
|
||
export default VepSubmitButton; |
1 change: 0 additions & 1 deletion
1
src/content/app/tools/vep/components/vep-top-bar/VepTopBar.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
.grid { | ||
display: grid; | ||
flex-grow: 1; | ||
align-items: center; | ||
grid-template-columns: | ||
[vep-logo] max-content | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/content/app/tools/vep/state/vep-api/fixtures/mockVepFormConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import type { VepFormConfig } from 'src/content/app/tools/vep/types/vepFormConfig'; | ||
|
||
const mockVepFormConfig = { | ||
parameters: { | ||
transcript_set: { | ||
label: 'Transcript set', | ||
description: null, | ||
type: 'select', | ||
options: [ | ||
{ | ||
label: 'GENCODE', | ||
value: 'gencode_comprehensive' | ||
} | ||
], | ||
default_value: 'gencode_comprehensive' | ||
}, | ||
symbol: { | ||
label: 'Gene symbol', | ||
description: null, | ||
type: 'boolean', | ||
default_value: true | ||
}, | ||
biotype: { | ||
label: 'Transcript biotype', | ||
description: null, | ||
type: 'boolean', | ||
default_value: true | ||
} | ||
} | ||
} satisfies VepFormConfig; | ||
|
||
export default mockVepFormConfig; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.