Skip to content

Commit

Permalink
Merge branch 'main' into update-pkg-deps
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcmichael committed Jan 16, 2025
2 parents fc5dbfb + f7beda9 commit 88fe802
Show file tree
Hide file tree
Showing 17 changed files with 174 additions and 68 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
env:
CI_BUILD: true
RAILS_ENV: test
CIVIC_API_HMAC_KEY: fakeKeyForTests
run: bundle exec rails test
working-directory: ./server

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ function formFieldConfig(
{
key: 'referenceBuild',
type: 'reference-build-select',
props: {
required: true,
expressions: {
'props.required': (field) =>
Boolean(field.model.fivePrimeTranscript) ||
Boolean(field.model.threePrimeTranscript),
},
},
{
Expand All @@ -107,7 +109,11 @@ function formFieldConfig(
label: 'Ensembl Version',
description:
'Enter a valid Ensembl database version (e.g. 75)',
required: true,
},
expressions: {
'props.required': (field) =>
Boolean(field.model.fivePrimeTranscript) ||
Boolean(field.model.threePrimeTranscript),
},
},
],
Expand All @@ -125,11 +131,14 @@ function formFieldConfig(
type: 'base-input',
props: {
label: "5' Transcript",
required: !fivePrimeDisabled,
disabled: fivePrimeDisabled,
tooltip:
"Specify a transcript ID, including version number (e.g. ENST00000348159.4) for the 5' exon you have selected",
},
expressions: {
'props.required': (field) =>
Boolean(field.model.fivePrimeExonEnd),
},
validators: {
isTranscriptId: {
expression: isEnsemblTranscript,
Expand All @@ -149,11 +158,14 @@ function formFieldConfig(
},
props: {
label: "5' End Exon",
required: !fivePrimeDisabled,
disabled: fivePrimeDisabled,
tooltip:
'The exon number counted from the 5’ end of the transcript.',
},
expressions: {
'props.required': (field) =>
Boolean(field.model.fivePrimeTranscript),
},
},
{
key: 'fivePrimeOffset',
Expand Down Expand Up @@ -205,7 +217,6 @@ function formFieldConfig(
key: 'threePrimeTranscript',
type: 'base-input',
props: {
required: !threePrimeDisabled,
disabled: threePrimeDisabled,
label: "3' Transcript",
tooltip:
Expand All @@ -218,6 +229,10 @@ function formFieldConfig(
"3' Transcript must be a valid, human, versioned, Ensembl transcript ID",
},
},
expressions: {
'props.required': (field) =>
Boolean(field.model.threePrimeExonStart),
},
},
{
key: 'threePrimeExonStart',
Expand All @@ -232,9 +247,12 @@ function formFieldConfig(
label: "3' Start Exon",
tooltip:
'The exon number counted from the 3’ end of the transcript.',
required: !threePrimeDisabled,
disabled: threePrimeDisabled,
},
expressions: {
'props.required': (field) =>
Boolean(field.model.threePrimeTranscript),
},
},
{
key: 'threePrimeOffset',
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/generated/civic.apollo-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,13 +735,13 @@ export type CreateVariantPayloadFieldPolicy = {
new?: FieldPolicy<any> | FieldReadFunction<any>,
variant?: FieldPolicy<any> | FieldReadFunction<any>
};
export type DataReleaseKeySpecifier = ('acceptedAndSubmittedVariantsVcf' | 'acceptedVariantsVcf' | 'assertionTsv' | 'evidenceTsv' | 'geneTsv' | 'molecularProfileTsv' | 'name' | 'variantGroupTsv' | 'variantTsv' | DataReleaseKeySpecifier)[];
export type DataReleaseKeySpecifier = ('acceptedAndSubmittedVariantsVcf' | 'acceptedVariantsVcf' | 'assertionTsv' | 'evidenceTsv' | 'featureTsv' | 'molecularProfileTsv' | 'name' | 'variantGroupTsv' | 'variantTsv' | DataReleaseKeySpecifier)[];
export type DataReleaseFieldPolicy = {
acceptedAndSubmittedVariantsVcf?: FieldPolicy<any> | FieldReadFunction<any>,
acceptedVariantsVcf?: FieldPolicy<any> | FieldReadFunction<any>,
assertionTsv?: FieldPolicy<any> | FieldReadFunction<any>,
evidenceTsv?: FieldPolicy<any> | FieldReadFunction<any>,
geneTsv?: FieldPolicy<any> | FieldReadFunction<any>,
featureTsv?: FieldPolicy<any> | FieldReadFunction<any>,
molecularProfileTsv?: FieldPolicy<any> | FieldReadFunction<any>,
name?: FieldPolicy<any> | FieldReadFunction<any>,
variantGroupTsv?: FieldPolicy<any> | FieldReadFunction<any>,
Expand Down
8 changes: 4 additions & 4 deletions client/src/app/generated/civic.apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1550,7 +1550,7 @@ export type DataRelease = {
acceptedVariantsVcf?: Maybe<DownloadableFile>;
assertionTsv?: Maybe<DownloadableFile>;
evidenceTsv?: Maybe<DownloadableFile>;
geneTsv?: Maybe<DownloadableFile>;
featureTsv?: Maybe<DownloadableFile>;
molecularProfileTsv?: Maybe<DownloadableFile>;
name: Scalars['String']['output'];
variantGroupTsv?: Maybe<DownloadableFile>;
Expand Down Expand Up @@ -9726,9 +9726,9 @@ export type PhenotypeDetailQuery = { __typename: 'Query', phenotype?: { __typena
export type DataReleasesQueryVariables = Exact<{ [key: string]: never; }>;


export type DataReleasesQuery = { __typename: 'Query', dataReleases: Array<{ __typename: 'DataRelease', name: string, geneTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantGroupTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, evidenceTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, molecularProfileTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, assertionTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedAndSubmittedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined }> };
export type DataReleasesQuery = { __typename: 'Query', dataReleases: Array<{ __typename: 'DataRelease', name: string, featureTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantGroupTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, evidenceTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, molecularProfileTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, assertionTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedAndSubmittedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined }> };

export type ReleaseFragment = { __typename: 'DataRelease', name: string, geneTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantGroupTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, evidenceTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, molecularProfileTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, assertionTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedAndSubmittedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined };
export type ReleaseFragment = { __typename: 'DataRelease', name: string, featureTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, variantGroupTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, evidenceTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, molecularProfileTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, assertionTsv?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined, acceptedAndSubmittedVariantsVcf?: { __typename: 'DownloadableFile', filename: string, path: string } | undefined };

export type SourceDetailQueryVariables = Exact<{
sourceId: Scalars['Int']['input'];
Expand Down Expand Up @@ -13263,7 +13263,7 @@ export const OrganizationMembersFieldsFragmentDoc = gql`
export const ReleaseFragmentDoc = gql`
fragment Release on DataRelease {
name
geneTsv {
featureTsv {
filename
path
}
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/generated/server.model.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2436,7 +2436,7 @@ type DataRelease {
acceptedVariantsVcf: DownloadableFile
assertionTsv: DownloadableFile
evidenceTsv: DownloadableFile
geneTsv: DownloadableFile
featureTsv: DownloadableFile
molecularProfileTsv: DownloadableFile
name: String!
variantGroupTsv: DownloadableFile
Expand Down
2 changes: 1 addition & 1 deletion client/src/app/generated/server.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12394,7 +12394,7 @@
"deprecationReason": null
},
{
"name": "geneTsv",
"name": "featureTsv",
"description": null,
"args": [],
"type": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ query DataReleases {

fragment Release on DataRelease {
name
geneTsv {
featureTsv {
filename
path
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h2>Data Releases</h2>
<nz-row *nzSpaceItem>
<p nz-typography>
The CIViC server produces nightly and monthly releases that include a
subset of all primary entity records (Genes, Variants, Molecular
subset of all primary entity records (Features, Variants, Molecular
Profiles, Evidence, Variant Groups, and Assertions). Both TSV and VCF
versions are provided below - just locate the specific entity type and
data format you wish to obtain, then click on the relevant button to
Expand Down Expand Up @@ -128,7 +128,7 @@ <h2>Data Releases</h2>
<thead>
<tr>
<th>Date</th>
<th>Genes</th>
<th>Features</th>
<th>Variants</th>
<th>Molecular Profiles</th>
<th>Evidence</th>
Expand All @@ -141,11 +141,11 @@ <h2>Data Releases</h2>
<tbody>
<tr *ngFor="let release of releasesTable.data">
<td>{{ release.name }}</td>
<td *ngIf="release.geneTsv; else noData">
<td *ngIf="release.featureTsv; else noData">
<cvc-link-tag
[href]="release.geneTsv.path"
[href]="release.featureTsv.path"
iconName="download">
Genes TSV
Features TSV
</cvc-link-tag>
</td>
<td *ngIf="release.variantTsv; else noData">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ def resolve(fields:, id:, organization_id: nil, comment: nil)
updated_variant.single_variant_molecular_profile_id = variant.single_variant_molecular_profile_id
updated_variant.feature = variant.feature
updated_variant.fusion = variant.feature.feature_instance
updated_variant.name = updated_variant.generate_name
if variant.name == 'Fusion'
updated_variant.name = 'Fusion'
else
updated_variant.name = updated_variant.generate_name
end
updated_variant.vicc_compliant_name = updated_variant.generate_vicc_name

variant_revisions_obj = Activities::RevisedObjectPair.new(existing_obj: variant, updated_obj: updated_variant)
Expand Down
2 changes: 1 addition & 1 deletion server/app/graphql/types/data_release_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def filename

class DataReleaseType < Types::BaseObject
field :name, String, null: false
field :gene_tsv, DownloadableFile, null: true
field :feature_tsv, DownloadableFile, null: true
field :variant_tsv, DownloadableFile, null: true
field :variant_group_tsv, DownloadableFile, null: true
field :evidence_tsv, DownloadableFile, null: true
Expand Down
4 changes: 2 additions & 2 deletions server/app/graphql/types/queries/data_release_query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def data_releases
release_name = File.basename(release)
{
name: release_name,
gene_tsv: file_or_nil(release, release_name, 'GeneSummaries.tsv'),
feature_tsv: file_or_nil(release, release_name, 'FeatureSummaries.tsv'),
variant_tsv: file_or_nil(release, release_name, 'VariantSummaries.tsv'),
variant_group_tsv: file_or_nil(release, release_name, 'VariantGroupSummaries.tsv'),
evidence_tsv: file_or_nil(release, release_name, 'ClinicalEvidenceSummaries.tsv'),
Expand All @@ -34,7 +34,7 @@ def data_releases

end
end

def file_or_nil(path, release, filename)
full_path = File.join(path, "#{release}-#{filename}")
if File.exist?(full_path)
Expand Down
11 changes: 10 additions & 1 deletion server/app/jobs/generate_tsvs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ def perform
public_path = public_file_path(e.file_name)
FileUtils.cp(tmp_file.path, public_path)
File.chmod(0644, public_path)

#symlink in legacy TSV names for backwards compatibility
if e.respond_to?(:file_aliases)
e.file_aliases.each do |fa|
link_path = public_file_path(fa)
FileUtils.ln_s(public_path, link_path, force: true)
File.chmod(0644, link_path)
end
end
ensure
tmp_file.unlink
end
Expand All @@ -22,7 +31,7 @@ def perform

def tsvs_to_generate
[
GeneTsvFormatter,
FeatureTsvFormatter,
VariantTsvFormatter,
EvidenceItemTsvFormatter,
VariantGroupTsvFormatter,
Expand Down
4 changes: 2 additions & 2 deletions server/app/jobs/upload_tsvs_to_aws.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def perform
def absolute_local_path(file)
File.join(TsvRelease.downloads_path, file)
end

def bucket_name
'civic-aws-opendata'
end
Expand Down Expand Up @@ -61,7 +61,7 @@ def expected_files
{
"AssertionSummaries/date=#{date_string}/AssertionSummaries.tsv" => "#{date_string}/#{date_string}-AssertionSummaries.tsv",
"ClinicalEvidenceSummaries/date=#{date_string}/ClinicalEvidenceSummaries.tsv" => "#{date_string}/#{date_string}-ClinicalEvidenceSummaries.tsv",
"GeneSummaries/date=#{date_string}/GeneSummaries.tsv" => "#{date_string}/#{date_string}-GeneSummaries.tsv",
"FeatureSummaries/date=#{date_string}/FeatureSummaries.tsv" => "#{date_string}/#{date_string}-FeatureSummaries.tsv",
"VariantGroupSummaries/date=#{date_string}/VariantGroupSummaries.tsv"=> "#{date_string}/#{date_string}-VariantGroupSummaries.tsv",
"VariantSummaries/date=#{date_string}/VariantSummaries.tsv" => "#{date_string}/#{date_string}-VariantSummaries.tsv",
"MolecularProfileSummaries/date=#{date_string}/MolecularProfileSummaries.tsv" => "#{date_string}/#{date_string}-MolecularProfileSummaries.tsv",
Expand Down
111 changes: 111 additions & 0 deletions server/app/tsv_formatters/feature_tsv_formatter.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
class FeatureTsvFormatter
def self.objects
Feature.joins(variants: { molecular_profiles: [:evidence_items]})
.includes(:feature_instance)
.distinct
end

def self.headers
shared_headers = [
'feature_id',
'feature_civic_url',
'feature_type',
'name',
'feature_aliases',
'description',
'last_review_date',
'is_flagged'
]
shared_headers + gene_headers + factor_headers + fusion_headers
end

def self.gene_headers
['entrez_id']
end

def self.factor_headers
['ncit_id']
end

def self.fusion_headers
[
'five_prime_partner_status',
'three_prime_partner_status',
'five_prime_gene_id',
'five_prime_gene_name',
'five_prime_gene_entrez_id',
'three_prime_gene_id',
'three_prime_gene_name',
'three_prime_gene_entrez_id',
]
end

def self.create_gene_row(feature)
row = [
feature.feature_instance.entrez_id
]
row += Array.new(factor_headers.size)
row += Array.new(fusion_headers.size)
return row
end

def self.create_factor_row(feature)
row = Array.new(gene_headers.size)
row += [
feature.feature_instance.ncit_id
]
row += Array.new(fusion_headers.size)
end

def self.create_fusion_row(feature)
feature_instance = feature.feature_instance
row = Array.new(gene_headers.size)
row += Array.new(factor_headers.size)
row += [
feature_instance.five_prime_partner_status,
feature_instance.three_prime_partner_status,
feature_instance.five_prime_gene_id,
feature_instance.five_prime_gene&.name,
feature_instance.five_prime_gene&.entrez_id,
feature_instance.three_prime_gene_id,
feature_instance.three_prime_gene&.name,
feature_instance.three_prime_gene&.entrez_id,
]
end

def self.row_from_object(feature)
shared_cols = [
feature.id,
LinkAdaptors::Feature.new(feature).permalink_path(include_domain: true),
feature.feature_instance_type.demodulize,
feature.name,
feature.feature_aliases.map(&:name).join(","),
feature.description&.squish,
feature.updated_at,
feature.flagged
]

feature_cols = case feature.feature_instance
when Features::Gene
create_gene_row(feature)
when Features::Factor
create_factor_row(feature)
when Features::Fusion
create_fusion_row(feature)
else
raise StandardError.new("Unknown feature type for TSV export: #{feature.feature_instance_type}")
end
shared_cols + feature_cols
end

def self.file_name
'FeatureSummaries.tsv'
end

def self.file_aliases
[
'GeneSummaries.tsv'
]
end
end

Loading

0 comments on commit 88fe802

Please sign in to comment.