Skip to content

Commit

Permalink
Merge pull request #1125 from griffithlab/fusion_bugfixes
Browse files Browse the repository at this point in the history
Various fusion bugfixes and improvements
  • Loading branch information
acoffman authored Oct 17, 2024
2 parents 957418b + 52cee12 commit 18e4430
Show file tree
Hide file tree
Showing 12 changed files with 63 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@
<nz-row [nzGutter]="[8, 16]">
<nz-col [nzSpan]="24">
<nz-row [nzGutter]="[8, 8]">
<!-- gene attributes block -->
<!-- fusion variant attributes block -->
<nz-col nzSpan="24">
<nz-descriptions
nzLayout="horizontal"
nzSize="small"
[nzColumn]="4"
nzBordered="true">
<nz-descriptions-item
[nzSpan]="4"
[nzSpan]="2"
nzTitle="Fusion Variant">
<cvc-feature-variant-tag
[variant]="variant"></cvc-feature-variant-tag>
</nz-descriptions-item>
<!-- VICC compliant name -->
<nz-descriptions-item
[nzSpan]="2"
nzTitle="VICC Compliant Name">
{{ variant.viccCompliantName }}
</nz-descriptions-item>
<!-- aliases -->
<nz-descriptions-item
[nzSpan]="2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
nzLayout="vertical"
nzSize="small"
[nzColumn]="{ xxl: 2, xl: 2, lg: 1, md: 1, sm: 1, xs: 1 }"
nzBordered="true">
nzBordered="true"
*ngIf="variant.creationActivity || variant.deprecationActivity">
<!-- creation/deprecation curation events -->
<ng-container *ngIf="variant.creationActivity">
<nz-descriptions-item [nzTitle]="createdTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@
nzLayout="vertical"
nzSize="small"
[nzColumn]="{ xxl: 2, xl: 2, lg: 1, md: 1, sm: 1, xs: 1 }"
nzBordered="true">
nzBordered="true"
*ngIf="variant.creationActivity || variant.deprecationActivity">
<!-- creation/deprecation curation events -->
<ng-container *ngIf="variant.creationActivity">
<nz-descriptions-item [nzTitle]="createdTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@
nzLayout="vertical"
nzSize="small"
[nzColumn]="{ xxl: 2, xl: 2, lg: 1, md: 1, sm: 1, xs: 1 }"
nzBordered="true">
nzBordered="true"
*ngIf="variant.creationActivity || variant.deprecationActivity">
<!-- creation/deprecation curation events -->
<ng-container *ngIf="variant.creationActivity">
<nz-descriptions-item [nzTitle]="createdTitle">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@
nzSize="small"
[nzColumn]="2"
nzBordered="true">
<!-- VICC compliant name -->
<nz-descriptions-item
nzTitle="VICC compliant name"
nzSpan="2"
*ngIf="variant.__typename == 'FusionVariant'">
{{ variant.viccCompliantName }}
</nz-descriptions-item>
<!-- aliases -->
<nz-descriptions-item
nzTitle="Aliases"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ fragment variantPopoverFields on VariantInterface {
... on GeneVariant {
alleleRegistryId
}
... on FusionVariant {
viccCompliantName
}
feature {
id
name
Expand Down
7 changes: 5 additions & 2 deletions client/src/app/generated/civic.apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8433,11 +8433,11 @@ export type VariantPopoverQueryVariables = Exact<{
}>;


export type VariantPopoverQuery = { __typename: 'Query', variant?: { __typename: 'FactorVariant', id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | { __typename: 'FusionVariant', id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | { __typename: 'GeneVariant', alleleRegistryId?: string | undefined, id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | { __typename: 'Variant', id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | undefined };
export type VariantPopoverQuery = { __typename: 'Query', variant?: { __typename: 'FactorVariant', id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | { __typename: 'FusionVariant', viccCompliantName: string, id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | { __typename: 'GeneVariant', alleleRegistryId?: string | undefined, id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | { __typename: 'Variant', id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } } | undefined };

type VariantPopoverFields_FactorVariant_Fragment = { __typename: 'FactorVariant', id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } };

type VariantPopoverFields_FusionVariant_Fragment = { __typename: 'FusionVariant', id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } };
type VariantPopoverFields_FusionVariant_Fragment = { __typename: 'FusionVariant', viccCompliantName: string, id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } };

type VariantPopoverFields_GeneVariant_Fragment = { __typename: 'GeneVariant', alleleRegistryId?: string | undefined, id: number, name: string, variantAliases: Array<string>, feature: { __typename: 'Feature', id: number, name: string, link: string, deprecated: boolean, flagged: boolean }, molecularProfiles: { __typename: 'MolecularProfileConnection', totalCount: number }, revisions: { __typename: 'RevisionConnection', totalCount: number }, comments: { __typename: 'CommentConnection', totalCount: number }, flags: { __typename: 'FlagConnection', totalCount: number } };

Expand Down Expand Up @@ -11034,6 +11034,9 @@ export const VariantPopoverFieldsFragmentDoc = gql`
... on GeneVariant {
alleleRegistryId
}
... on FusionVariant {
viccCompliantName
}
feature {
id
name
Expand Down
17 changes: 13 additions & 4 deletions server/app/jobs/populate_fusion_coordinates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ def perform(variant)
end

def populate_coords(coords, secondary_coordinates)
#For representative fusions, these fields are empty when the representative exons coords are first curated/revisions accepted
#For all fusions, these require updating when a revision on the primary set of coords edits these fields
secondary_coordinates.representative_transcript = coords.representative_transcript
secondary_coordinates.reference_build = coords.reference_build
secondary_coordinates.ensembl_version = coords.ensembl_version
secondary_coordinates.save!

if coords.present? && coords.representative_transcript.present?
(exon, highest_exon) = get_exon_for_transcript(coords.representative_transcript, coords.exon)
populate_exon_coordinates(coords, exon)
populate_exon_coordinates(coords, exon, coords.exon)

if coords.coordinate_type =~ /Five Prime/
(secondary_exon, _) = get_exon_for_transcript(secondary_coordinates.representative_transcript, 1)
populate_exon_coordinates(secondary_coordinates, secondary_exon)
populate_exon_coordinates(secondary_coordinates, secondary_exon, 1)
else
(secondary_exon, _) = get_exon_for_transcript(secondary_coordinates.representative_transcript, highest_exon)
populate_exon_coordinates(secondary_coordinates, secondary_exon)
populate_exon_coordinates(secondary_coordinates, secondary_exon, highest_exon)
end
end
end
Expand Down Expand Up @@ -58,7 +65,9 @@ def get_exon_for_transcript(transcript, exon_number)
[exon.first, max_exon_on_transcript]
end

def populate_exon_coordinates(coordinates, exon)
def populate_exon_coordinates(coordinates, exon, exon_number)
coordinates.exon = exon_number

strand = if exon['strand'] == -1
'negative'
else
Expand Down
5 changes: 4 additions & 1 deletion server/app/lib/scrapers/ensembl_api_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ def self.get_exons_for_ensembl_id(ensembl_id, warning = nil)
elsif error_message == "ID '#{ensembl_id}' not found"
return EnsemblResult.new(nil, "Transcript doesn't exist in GRCh37 at any version: #{ensembl_id}", warning)
else
return EnsemblResult.new(nil, nil, warning)
return EnsemblResult.new(nil, error_message, warning)
end
end
if data.nil?
return EnsemblResult.new(nil, "No data returned for transcript: #{ensembl_id}", warning)
end
EnsemblResult.new(data.sort_by { |exon| exon['start'] }, nil, warning)
end

Expand Down
14 changes: 12 additions & 2 deletions server/app/models/activities/create_fusion_variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,21 @@ def call_actions

def stub_remaining_coordinates
if variant.fusion.five_prime_partner_status == 'known'
variant.five_prime_start_exon_coordinates = ExonCoordinate.generate_stub(variant, 'Five Prime Start Exon Coordinate')
e = ExonCoordinate.generate_stub(variant, 'Five Prime Start Exon Coordinate')
e.representative_transcript = five_prime_end_exon_coords.representative_transcript
e.reference_build = five_prime_end_exon_coords.reference_build
e.ensembl_version = five_prime_end_exon_coords.ensembl_version
e.save!
variant.five_prime_start_exon_coordinates = e
variant.five_prime_coordinates = VariantCoordinate.generate_stub(variant, 'Five Prime Fusion Coordinate')
end
if variant.fusion.three_prime_partner_status == 'known'
variant.three_prime_end_exon_coordinates = ExonCoordinate.generate_stub(variant, 'Three Prime End Exon Coordinate')
e = ExonCoordinate.generate_stub(variant, 'Three Prime End Exon Coordinate')
e.representative_transcript = three_prime_start_exon_coords.representative_transcript
e.reference_build = three_prime_start_exon_coords.reference_build
e.ensembl_version = three_prime_start_exon_coords.ensembl_version
e.save!
variant.three_prime_end_exon_coordinates = e
variant.three_prime_coordinates = VariantCoordinate.generate_stub(variant, 'Three Prime Fusion Coordinate')
end
end
Expand Down
5 changes: 0 additions & 5 deletions server/app/models/features/fusion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ class Fusion < ActiveRecord::Base
validate :partner_status_valid_for_gene_ids
validate :at_least_one_gene_id

#When displayed as part of an MP, the Variant Name specifies the feature
def mp_name
nil
end

def partner_status_valid_for_gene_ids
if !self.in_revision_validation_context
[self.five_prime_gene, self.three_prime_gene].zip([self.five_prime_partner_status, self.three_prime_partner_status], [:five_prime_gene, :three_prime_gene]).each do |gene, status, fk|
Expand Down
28 changes: 5 additions & 23 deletions server/app/models/variants/fusion_variant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ module Variants
class FusionVariant < Variant
has_one :fusion, through: :feature, source: :feature_instance, source_type: 'Features::Fusion'

#TODO - make this
#validates_with FusionVariantValidator
#check feature partner status and corresponding stubbed coords

has_one :five_prime_coordinates,
->() { where(coordinate_type: 'Five Prime Fusion Coordinate') },
foreign_key: 'variant_id',
Expand Down Expand Up @@ -67,18 +63,6 @@ def required_fields
]
end

def mp_name
if name == Constants::REPRESENTATIVE_FUSION_VARIANT_NAME
"#{feature.name} #{Constants::REPRESENTATIVE_FUSION_VARIANT_NAME}"
else
[
construct_five_prime_name(name_type: :molecular_profile),
construct_three_prime_name(name_type: :molecular_profile)
].join("::")
end

end

def generate_vicc_name
if name == Constants::REPRESENTATIVE_FUSION_VARIANT_NAME
"#{construct_five_prime_name(name_type: :representative)}::#{construct_three_prime_name(name_type: :representative)}"
Expand All @@ -100,10 +84,10 @@ def generate_name

def forbidden_fields
[
# :ncit_id,
# :hgvs_description_ids,
# :clinvar_entry_ids,
# :allele_registry_id,
:ncit_id,
:hgvs_description_ids,
:clinvar_entry_ids,
:allele_registry_id,
]
end

Expand Down Expand Up @@ -132,11 +116,9 @@ def construct_partner_name(name_type:, partner_status:, gene:, exon_coords:)
when :representative
"#{gene.name}(entrez:#{gene.entrez_id})"
when :civic
"e.#{exon_coords.exon}#{exon_coords.formatted_offset}#{exon_coords.exon_offset}"
"e#{exon_coords.exon}#{exon_coords.formatted_offset}#{exon_coords.exon_offset}"
when :vicc
"#{exon_coords.representative_transcript}(#{gene.name}):e.#{exon_coords.exon}#{exon_coords.formatted_offset}#{exon_coords.exon_offset}"
when :molecular_profile
"#{gene.name}:e.#{exon_coords.exon}#{exon_coords.formatted_offset}#{exon_coords.exon_offset}"
end
elsif partner_status == 'unknown'
'?'
Expand Down

0 comments on commit 18e4430

Please sign in to comment.