From 09b372046e6b25685ba8ad96bbedab442585d20e Mon Sep 17 00:00:00 2001 From: Adam Coffman Date: Tue, 26 Mar 2024 15:30:27 -0500 Subject: [PATCH] small refactoring --- .../features-table.component.html | 2 +- .../factor-variant-summary.page.html | 309 +++++------ .../factor-variant-summary.page.ts | 2 + .../gene-variant-summary.page.html | 518 +++++++++--------- .../variants-table.component.html | 4 +- .../variant-revise.form.config.ts | 366 ------------- server/app/models/variant.rb | 16 + server/app/models/variants/factor_variant.rb | 5 +- server/app/models/variants/gene_variant.rb | 6 +- 9 files changed, 441 insertions(+), 787 deletions(-) delete mode 100644 client/src/app/forms/config/factor-variant-revise/variant-revise.form.config.ts diff --git a/client/src/app/components/features/features-table/features-table.component.html b/client/src/app/components/features/features-table/features-table.component.html index 06c90fa0e..6fd6fe6d1 100644 --- a/client/src/app/components/features/features-table/features-table.component.html +++ b/client/src/app/components/features/features-table/features-table.component.html @@ -189,7 +189,7 @@ nz-typography nz nzType="secondary"> - {{ feature.featureInstanceType }} + {{ feature.featureInstanceType | titlecase }} diff --git a/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.html b/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.html index a11ff520a..b32a38641 100644 --- a/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.html +++ b/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.html @@ -1,162 +1,165 @@ -@if(variant.__typename == "FactorVariant") { - - - - - - - - - - - - - - {{ - alias - }} - - - - None specified - - +@if (variant.__typename == 'FactorVariant') { + + + + + + + + + + + + + + {{ + alias + }} + + + + None specified + + - - - - - - - - - None specified - - - - - - - + + + + + + + + + None specified + + + - - + + + + + + + + + + + + + + + + - - - - + + + + + by + + + + Created + + ({{ variant.creationActivity.createdAt | timeAgo }}) + + + + + + by + + + + Deprecated + + ({{ variant.deprecationActivity.createdAt | timeAgo }}) + + + + - - - - - - - - - - - - - - by - - - - Created - - ({{ variant.creationActivity.createdAt | timeAgo }}) - - - - - - by - + + + + + + - - Deprecated - - ({{ variant.deprecationActivity.createdAt | timeAgo }}) - - - - - - - - - - - - - - - - - NCIt: {{ variant.ncitId }} - - - - - - - - + + + + NCIt: {{ variant.ncitId }} + + + + + + + + + + + + + - - - - - - + + + + + + } diff --git a/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.ts b/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.ts index 91cf5189c..954c16483 100644 --- a/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.ts +++ b/client/src/app/components/variants/factor-variant-summary/factor-variant-summary.page.ts @@ -18,6 +18,7 @@ import { CvcUserTagModule } from '@app/components/users/user-tag/user-tag.module import { CvcFeatureTagModule } from '@app/components/features/feature-tag/feature-tag.module' import { CvcPipesModule } from '@app/core/pipes/pipes.module' import { CvcNcitDetailsComponent } from '@app/components/factors/ncit-details/ncit-details.component' +import { NzTypographyModule } from 'ng-zorro-antd/typography' @Component({ standalone: true, @@ -31,6 +32,7 @@ import { CvcNcitDetailsComponent } from '@app/components/factors/ncit-details/nc NzDescriptionsModule, NzTagModule, NzCardModule, + NzTypographyModule, CvcEmptyRevisableModule, CvcTagListModule, CvcVariantTypeTagModule, diff --git a/client/src/app/components/variants/gene-variant-summary/gene-variant-summary.page.html b/client/src/app/components/variants/gene-variant-summary/gene-variant-summary.page.html index 0a6b699fa..a37d1a06a 100644 --- a/client/src/app/components/variants/gene-variant-summary/gene-variant-summary.page.html +++ b/client/src/app/components/variants/gene-variant-summary/gene-variant-summary.page.html @@ -1,271 +1,277 @@ -@if(variant.__typename == "GeneVariant") { - - - - - - - - - - - - - - {{ - alias - }} - - - - None specified - - - - - - - - - - - - None specified - - - - - - - - {{ - desc - }} - - - - None specified - - +@if (variant.__typename == 'GeneVariant') { + + + + + + + + + + + + + + {{ + alias + }} + + + + None specified + + - - - - - {{ variant.maneSelectTranscript }} - - - - None found - - - - - - - - - - + + + + + + + + + None specified + + - - - - - - - - - - - by - + + + + + {{ + desc + }} + + + + None specified + - - Created - - ({{ variant.creationActivity.createdAt | timeAgo }}) - - - - - - by - + + + + + + {{ variant.maneSelectTranscript }} + + + + None found + - - Deprecated - - ({{ variant.deprecationActivity.createdAt | timeAgo }}) - - - - - + + + + + + + + - - - - - - - + + + + + + + + + + + by + + + + Created + + ({{ variant.creationActivity.createdAt | timeAgo }}) + + + + + + by + + + + Deprecated + + ({{ variant.deprecationActivity.createdAt | timeAgo }}) + + + + + - - - - {{ variant.alleleRegistryId }} - - - Unregistered - - + + + + + + + - - - - + + - - - {{ id }} - - - - + variant.alleleRegistryId && + variant.alleleRegistryId != 'unregistered'; + else noAlleleRegistry + " + [href]=" + 'https://reg.genome.network/allele/' + + variant.alleleRegistryId + + '.html' + " + tooltip="View on ClinGen Allele Registry"> + {{ variant.alleleRegistryId }} + + + Unregistered + + - - {{ variant.clinvarIds[0] }} - + + + + + + + {{ id }} + + + + - - None provided - - + + {{ variant.clinvarIds[0] }} + - - - Variant Report - - - - + + None provided + + - - - - - - - - - - - - + + + Variant Report + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + } diff --git a/client/src/app/components/variants/variants-table/variants-table.component.html b/client/src/app/components/variants/variants-table/variants-table.component.html index 9749c4eb6..813443f45 100644 --- a/client/src/app/components/variants/variants-table/variants-table.component.html +++ b/client/src/app/components/variants/variants-table/variants-table.component.html @@ -152,7 +152,7 @@ - {{ variant.category }} + {{ variant.category | titlecase }} @@ -167,7 +167,7 @@ diff --git a/client/src/app/forms/config/factor-variant-revise/variant-revise.form.config.ts b/client/src/app/forms/config/factor-variant-revise/variant-revise.form.config.ts deleted file mode 100644 index ff35f4cf3..000000000 --- a/client/src/app/forms/config/factor-variant-revise/variant-revise.form.config.ts +++ /dev/null @@ -1,366 +0,0 @@ -import { AbstractControl } from '@angular/forms' -import { Chromosomes } from '@app/forms/utilities/input-formatters' -import { geneVariantReviseFormInitialModel } from '@app/forms/models/gene-variant-revise.model' -import assignFieldConfigDefaultValues from '@app/forms/utilities/assign-field-default-values' -import { CvcFormCardWrapperProps } from '@app/forms/wrappers/form-card/form-card.wrapper' -import { CvcFormLayoutWrapperProps } from '@app/forms/wrappers/form-layout/form-layout.wrapper' -import { FormlyFieldConfig } from '@ngx-formly/core' -import { CvcFormRowWrapperProps } from '@app/forms/wrappers/form-row/form-row.wrapper' -import { CvcOrgSubmitButtonFieldConfig } from '@app/forms/types/org-submit-button/org-submit-button.type' - -const formFieldConfig: FormlyFieldConfig[] = [ - { - wrappers: ['form-layout'], - props: { - showDevPanel: false, - }, - fieldGroup: [ - { - key: 'clientMutationId', - props: { - hidden: true, - }, - }, - { - key: 'fields', - wrappers: ['form-card'], - props: { - formCardOptions: { title: 'Revise Variant' }, - }, - fieldGroup: [ - { - wrappers: ['form-row'], - props: { - formRowOptions: { - responsiveIndexed: [ - { xs: 24, md: 12, lg: 8 }, - { xs: 24, md: 12, lg: 8 }, - { xs: 24, lg: 8 }, - ], - }, - }, - fieldGroup: [ - { - key: 'featureId', - type: 'feature-select', - props: { - description: 'Enter an Entrez Gene for this Variant', - required: true, - }, - }, - { - key: 'name', - type: 'base-input', - props: { - placeholder: 'Enter a name for this Variant', - description: - "Enter the name of the Variant according to the Variant Curation SOP", - label: 'Name', - required: true, - rows: 1, - }, - }, - { - key: 'aliases', - type: 'tag-multi-input', - props: { - label: 'Aliases', - description: - 'List any aliases commonly used to refer to this Variant', - placeholder: 'Enter Alias and hit return', - }, - }, - ], - }, - { - wrappers: ['form-row'], - props: { - formRowOptions: { - responsiveIndexed: [ - { xs: 24, lg: 12, xl: 6, xxl: 8 }, - { xs: 24, lg: 12, xl: 6, xxl: 8 }, - { xs: 24, xl: 12, xxl: 8 }, - ], - }, - }, - fieldGroup: [ - { - key: 'hgvsDescriptions', - type: 'tag-multi-input', - props: { - label: 'HGVS Descriptions', - description: - 'Enter any HGVS nomenclature descriptions of this Variant', - tooltip: - 'Human Genome Variation Society nomenclature descriptions', - placeholder: 'Enter HGVS and hit return', - }, - }, - { - key: 'variantTypeIds', - type: 'variant-type-multi-select', - }, - { - key: 'clinvarIds', - type: 'clinvar-multi-input', - wrappers: ['form-field'], - props: { - label: 'ClinVar IDs', - }, - }, - ], - }, - { - wrappers: ['form-row'], - props: { - formRowOptions: { - span: 24, - }, - }, - fieldGroup: [ - { - wrappers: ['form-card'], - props: { - formCardOptions: { - title: `Primary (5') Coordinates`, - size: 'small', - }, - }, - fieldGroup: [ - { - wrappers: ['form-row'], - props: { - formRowOptions: { - responsive: { xs: 24, md: 12, lg: 8, xxl: 6 }, - }, - }, - fieldGroup: [ - { - key: 'referenceBuild', - type: 'reference-build-select', - }, - { - key: 'ensemblVersion', - type: 'base-input', - validators: { - nccnVersionNumber: { - expression: (c: AbstractControl) => - c.value ? /^\d{2,3}$/.test(c.value) : true, - message: (_: any, field: FormlyFieldConfig) => - `"${field.formControl?.value}" does not appear to be an Ensembl version number`, - }, - }, - props: { - label: 'Ensembl Version', - description: - 'Enter a valid Ensembl database version (e.g. 75)', - }, - }, - { - key: 'referenceBases', - type: 'base-input', - validators: { - nccnVersionNumber: { - expression: (c: AbstractControl) => - c.value ? /^[ACTG\\]+$/.test(c.value) : true, - message: (_: any, field: FormlyFieldConfig) => - `"${field.formControl?.value}" contains invalid characters.`, - }, - }, - props: { - label: 'Reference Bases', - description: - 'The nucleotide(s) of the reference genome affected by the variant. Only used for SNVs and Indels (otherwise leave blank)', - }, - }, - { - key: 'variantBases', - type: 'base-input', - validators: { - nccnVersionNumber: { - expression: (c: AbstractControl) => - c.value ? /^[ACTG\\]+$/.test(c.value) : true, - message: (_: any, field: FormlyFieldConfig) => - `"${field.formControl?.value}" contains invalid characters.`, - }, - }, - props: { - label: 'Variant Bases', - description: - 'The nucleotide(s) of the variant allele. Only used for SNVs and Indels (otherwise leave blank)', - }, - }, - { - key: 'chromosome', - type: 'base-select', - props: { - label: 'Chromosome', - options: Chromosomes, - description: - 'Specify the chromosome in which this variant occurs (e.g. 17).', - }, - }, - { - key: 'start', - type: 'base-input', - validators: { - isNumeric: { - expression: (c: AbstractControl) => - c.value ? /^\d+$/.test(c.value) : true, - message: (_: any, field: FormlyFieldConfig) => - 'Start coordinate must be numeric', - }, - }, - props: { - label: 'Start', - description: - 'Enter the left/first coordinate of this variant. Must be ≤ the Stop coordinate. Coordinate must be compatible with the selected reference build.', - }, - }, - { - key: 'stop', - type: 'base-input', - validators: { - isNumeric: { - expression: (c: AbstractControl) => - c.value ? /^\d+$/.test(c.value) : true, - message: (_: any, field: FormlyFieldConfig) => - 'Stop coordinate must be numeric', - }, - }, - props: { - label: 'Stop', - description: - 'Provide the right/second coordinate of this variant. Must be ≥ the Start coordinate. Coordinate must be compatible with the selected reference build.', - }, - }, - { - key: 'representativeTranscript', - type: 'base-input', - props: { - label: 'Representative Transcript', - description: - 'Specify a transcript ID, including version number (e.g. ENST00000348159.4, the canonical transcript defined by Ensembl).', - }, - }, - ], - }, - ], - }, - { - wrappers: ['form-card'], - props: { - formCardOptions: { - title: `Secondary (3') Coordinates`, - size: 'small', - }, - }, - fieldGroup: [ - { - wrappers: ['form-row'], - props: { - formRowOptions: { - responsive: { xs: 24, md: 12, lg: 8, xxl: 6 }, - }, - }, - fieldGroup: [ - { - key: 'chromosome2', - type: 'base-select', - props: { - label: 'Chromosome', - options: Chromosomes, - description: - 'If this variant is a fusion (e.g. BCR-ABL1), specify the chromosome name, coordinates, and representative transcript for the 3-prime partner.', - }, - }, - { - key: 'start2', - type: 'base-input', - validators: { - isNumeric: { - expression: (c: AbstractControl) => - c.value ? /^\d+$/.test(c.value) : true, - message: (_: any, field: FormlyFieldConfig) => - 'Start coordinate must be numeric', - }, - }, - props: { - label: 'Start', - description: - 'Enter the left/first coordinate of this 3-prime partner fusion variant. Must be ≤ the Stop coordinate. Coordinate must be compatible with the selected reference build.', - }, - }, - { - key: 'stop2', - type: 'base-input', - validators: { - isNumeric: { - expression: (c: AbstractControl) => - c.value ? /^\d+$/.test(c.value) : true, - message: (_: any, field: FormlyFieldConfig) => - 'Stop coordinate must be numeric', - }, - }, - props: { - label: 'Stop', - description: - 'Provide the right/second coordinate of this 3-prime partner fusion variant. Must be ≥ the Start coordinate. Coordinate must be compatible with the selected reference build.', - }, - }, - { - key: 'representativeTranscript2', - type: 'base-input', - props: { - label: 'Representative Transcript', - description: - 'Specify a transcript ID, including version number (e.g. ENST00000348159.4, the canonical transcript defined by Ensembl).', - }, - }, - ], - }, - ], - }, - ], - }, - ], - }, - { - wrappers: ['form-row'], - props: { - formRowOptions: { - spanIndexed: [24, 12, 12], - }, - }, - fieldGroup: [ - { - key: 'comment', - type: 'base-textarea', - props: { - label: 'Comment', - placeholder: 'Please enter a comment describing your revisions.', - required: true, - minLength: 10, - }, - }, - { - type: 'cvc-cancel-button', - }, - { - key: 'organizationId', - type: 'org-submit-button', - props: { - submitLabel: 'Submit Variant Revisions', - align: 'right', - }, - }, - ], - }, - ], - }, -] -export const geneVariantReviseFields: FormlyFieldConfig[] = - assignFieldConfigDefaultValues( - formFieldConfig, - geneVariantReviseFormInitialModel - ) diff --git a/server/app/models/variant.rb b/server/app/models/variant.rb index 4d7e36242..a4cc30892 100644 --- a/server/app/models/variant.rb +++ b/server/app/models/variant.rb @@ -138,10 +138,26 @@ def feature_type_matches_variant_type end def editable_fields + unique_editable_fields + shared_editable_fields + end + + def shared_editable_fields + [ + :feature_id, + :name, + :variant_type_ids, + :variant_alias_ids, + ] + end + + def unique_editable_fields raise StandardError.new("Implement in Variant subclass") end def forbidden_fields + #Grab the editable fields from each variant subclass, except the current one + #Combine their editable fields into a list, and remove the editable fields of the current type + #This produces a list of fields that should not be populated on this variant type other_editable_fields = Variant.known_subclasses .reject { |c| self.is_a?(c) } .flat_map { |c| c.new.editable_fields } diff --git a/server/app/models/variants/factor_variant.rb b/server/app/models/variants/factor_variant.rb index 6ad7761f8..7b946a8ac 100644 --- a/server/app/models/variants/factor_variant.rb +++ b/server/app/models/variants/factor_variant.rb @@ -1,11 +1,8 @@ module Variants class FactorVariant < Variant - def editable_fields + def unique_editable_fields [ - :feature_id, - :name, :ncit_id, - :variant_type_ids, ] end diff --git a/server/app/models/variants/gene_variant.rb b/server/app/models/variants/gene_variant.rb index be9271420..8d9d33f04 100644 --- a/server/app/models/variants/gene_variant.rb +++ b/server/app/models/variants/gene_variant.rb @@ -17,14 +17,10 @@ class GeneVariant < Variant message: "only allows A,C,T,G or /" }, allow_nil: true - def editable_fields + def unique_editable_fields [ - :feature_id, - :name, - :variant_alias_ids, :hgvs_description_ids, :clinvar_entry_ids, - :variant_type_ids, :reference_build, :ensembl_version, :chromosome,