Skip to content

Commit

Permalink
Merge pull request #1130 from griffithlab/civicpy_features
Browse files Browse the repository at this point in the history
Updates needed for CIViCpy to support fusions and factors
  • Loading branch information
acoffman authored Oct 16, 2024
2 parents 1545037 + 0ad002e commit 0aab45e
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 3 deletions.
4 changes: 3 additions & 1 deletion client/src/app/generated/civic.apollo-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1825,7 +1825,7 @@ export type PhenotypePopoverFieldPolicy = {
name?: FieldPolicy<any> | FieldReadFunction<any>,
url?: FieldPolicy<any> | FieldReadFunction<any>
};
export type QueryKeySpecifier = ('acmgCode' | 'acmgCodesTypeahead' | 'activities' | 'activity' | 'assertion' | 'assertions' | 'browseDiseases' | 'browseFeatures' | 'browseMolecularProfiles' | 'browseSources' | 'browseVariantGroups' | 'browseVariants' | 'clingenCode' | 'clingenCodesTypeahead' | 'clinicalTrial' | 'clinicalTrials' | 'comment' | 'comments' | 'contributors' | 'countries' | 'dataReleases' | 'disease' | 'diseasePopover' | 'diseaseTypeahead' | 'entityTypeahead' | 'events' | 'evidenceItem' | 'evidenceItems' | 'factors' | 'feature' | 'featureTypeahead' | 'flag' | 'flags' | 'fusions' | 'gene' | 'genes' | 'molecularProfile' | 'molecularProfiles' | 'nccnGuideline' | 'nccnGuidelinesTypeahead' | 'notifications' | 'organization' | 'organizationLeaderboards' | 'organizations' | 'phenotype' | 'phenotypePopover' | 'phenotypeTypeahead' | 'phenotypes' | 'previewCommentText' | 'previewMolecularProfileName' | 'remoteCitation' | 'revision' | 'revisions' | 'search' | 'searchByPermalink' | 'searchGenes' | 'source' | 'sourcePopover' | 'sourceSuggestionValues' | 'sourceSuggestions' | 'sourceTypeahead' | 'subscriptionForEntity' | 'therapies' | 'therapy' | 'therapyPopover' | 'therapyTypeahead' | 'timepointStats' | 'user' | 'userLeaderboards' | 'userTypeahead' | 'users' | 'validateRevisionsForAcceptance' | 'variant' | 'variantGroup' | 'variantGroups' | 'variantType' | 'variantTypePopover' | 'variantTypeTypeahead' | 'variantTypes' | 'variants' | 'variantsTypeahead' | 'viewer' | QueryKeySpecifier)[];
export type QueryKeySpecifier = ('acmgCode' | 'acmgCodesTypeahead' | 'activities' | 'activity' | 'assertion' | 'assertions' | 'browseDiseases' | 'browseFeatures' | 'browseMolecularProfiles' | 'browseSources' | 'browseVariantGroups' | 'browseVariants' | 'clingenCode' | 'clingenCodesTypeahead' | 'clinicalTrial' | 'clinicalTrials' | 'comment' | 'comments' | 'contributors' | 'countries' | 'dataReleases' | 'disease' | 'diseasePopover' | 'diseaseTypeahead' | 'entityTypeahead' | 'events' | 'evidenceItem' | 'evidenceItems' | 'factor' | 'factors' | 'feature' | 'featureTypeahead' | 'flag' | 'flags' | 'fusion' | 'fusions' | 'gene' | 'genes' | 'molecularProfile' | 'molecularProfiles' | 'nccnGuideline' | 'nccnGuidelinesTypeahead' | 'notifications' | 'organization' | 'organizationLeaderboards' | 'organizations' | 'phenotype' | 'phenotypePopover' | 'phenotypeTypeahead' | 'phenotypes' | 'previewCommentText' | 'previewMolecularProfileName' | 'remoteCitation' | 'revision' | 'revisions' | 'search' | 'searchByPermalink' | 'searchGenes' | 'source' | 'sourcePopover' | 'sourceSuggestionValues' | 'sourceSuggestions' | 'sourceTypeahead' | 'subscriptionForEntity' | 'therapies' | 'therapy' | 'therapyPopover' | 'therapyTypeahead' | 'timepointStats' | 'user' | 'userLeaderboards' | 'userTypeahead' | 'users' | 'validateRevisionsForAcceptance' | 'variant' | 'variantGroup' | 'variantGroups' | 'variantType' | 'variantTypePopover' | 'variantTypeTypeahead' | 'variantTypes' | 'variants' | 'variantsTypeahead' | 'viewer' | QueryKeySpecifier)[];
export type QueryFieldPolicy = {
acmgCode?: FieldPolicy<any> | FieldReadFunction<any>,
acmgCodesTypeahead?: FieldPolicy<any> | FieldReadFunction<any>,
Expand Down Expand Up @@ -1855,11 +1855,13 @@ export type QueryFieldPolicy = {
events?: FieldPolicy<any> | FieldReadFunction<any>,
evidenceItem?: FieldPolicy<any> | FieldReadFunction<any>,
evidenceItems?: FieldPolicy<any> | FieldReadFunction<any>,
factor?: FieldPolicy<any> | FieldReadFunction<any>,
factors?: FieldPolicy<any> | FieldReadFunction<any>,
feature?: FieldPolicy<any> | FieldReadFunction<any>,
featureTypeahead?: FieldPolicy<any> | FieldReadFunction<any>,
flag?: FieldPolicy<any> | FieldReadFunction<any>,
flags?: FieldPolicy<any> | FieldReadFunction<any>,
fusion?: FieldPolicy<any> | FieldReadFunction<any>,
fusions?: FieldPolicy<any> | FieldReadFunction<any>,
gene?: FieldPolicy<any> | FieldReadFunction<any>,
genes?: FieldPolicy<any> | FieldReadFunction<any>,
Expand Down
15 changes: 15 additions & 0 deletions client/src/app/generated/civic.apollo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4794,6 +4794,8 @@ export type Query = {
evidenceItem?: Maybe<EvidenceItem>;
/** List and filter evidence items. */
evidenceItems: EvidenceItemConnection;
/** Find a single gene by CIViC ID or NCIt ID */
factor?: Maybe<Factor>;
/** List and filter factors. */
factors: FactorConnection;
/** Find a single feature by CIViC ID */
Expand All @@ -4804,6 +4806,8 @@ export type Query = {
flag?: Maybe<Flag>;
/** List and filter flags. */
flags: FlagConnection;
/** Find a single gene by CIViC ID */
fusion?: Maybe<Fusion>;
/** List and filter fusions. */
fusions: FusionConnection;
/** Find a single gene by CIViC ID or Entrez symbol */
Expand Down Expand Up @@ -5174,6 +5178,12 @@ export type QueryEvidenceItemsArgs = {
};


export type QueryFactorArgs = {
id?: InputMaybe<Scalars['Int']['input']>;
ncitId?: InputMaybe<Scalars['String']['input']>;
};


export type QueryFactorsArgs = {
after?: InputMaybe<Scalars['String']['input']>;
before?: InputMaybe<Scalars['String']['input']>;
Expand Down Expand Up @@ -5213,6 +5223,11 @@ export type QueryFlagsArgs = {
};


export type QueryFusionArgs = {
id?: InputMaybe<Scalars['Int']['input']>;
};


export type QueryFusionsArgs = {
after?: InputMaybe<Scalars['String']['input']>;
before?: InputMaybe<Scalars['String']['input']>;
Expand Down
10 changes: 10 additions & 0 deletions client/src/app/generated/server.model.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8722,6 +8722,11 @@ type Query {
variantOrigin: VariantOrigin
): EvidenceItemConnection!

"""
Find a single gene by CIViC ID or NCIt ID
"""
factor(id: Int, ncitId: String): Factor

"""
List and filter factors.
"""
Expand Down Expand Up @@ -8818,6 +8823,11 @@ type Query {
state: FlagState
): FlagConnection!

"""
Find a single gene by CIViC ID
"""
fusion(id: Int): Fusion

"""
List and filter fusions.
"""
Expand Down
8 changes: 8 additions & 0 deletions server/app/graphql/types/entities/feature_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class FeatureType < Types::BaseObject
field :deprecation_reason, Types::FeatureDeprecationReasonType, null: true
field :creation_activity, Types::Activities::CreateFeatureActivityType, null: true

def id
if object.class.name == 'Feature'
object.id
else
object.feature.id
end
end

def feature_aliases
if object.class.name == 'Feature'
to_load = object
Expand Down
30 changes: 28 additions & 2 deletions server/app/graphql/types/query_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,17 @@ def authorized?(object, args, context)
argument :entrez_symbol, String, required: false
end

field :factor, Types::Entities::FactorType, null: true do
description "Find a single gene by CIViC ID or NCIt ID"
argument :id, Int, required: false
argument :ncit_id, String, required: false
end

field :fusion, Types::Entities::FusionType, null: true do
description "Find a single gene by CIViC ID"
argument :id, Int, required: false
end

field :feature, Types::Entities::FeatureType, null: true do
description "Find a single feature by CIViC ID"
argument :id, Int, required: false
Expand Down Expand Up @@ -211,13 +222,28 @@ def gene(id: :unspecified, entrez_symbol: :unspecified)
if (id == :unspecified && entrez_symbol == :unspecified) || (id != :unspecified && entrez_symbol != :unspecified)
raise GraphQL::ExecutionError.new('Must specify exactly one of id or entrezSymbol')
end
if (id != :unspecified)
Features::Gene.find_by(id: id)
if (id != :unspecified)
Feature.find_by(feature_instance_type: 'Features::Gene', id: id)&.feature_instance
else
Features::Gene.find_by(name: entrez_symbol)
end
end

def factor(id: :unspecified, ncit_id: :unspecified)
if (id == :unspecified && ncit_id == :unspecified) || (id != :unspecified && ncit_id != :unspecified)
raise GraphQL::ExecutionError.new('Must specify exactly one of id or ncitId')
end
if (id != :unspecified)
Feature.find_by(feature_instance_type: 'Features::Factor', id: id)&.feature_instance
else
Features::Factor.find_by(ncit_id: ncit_id)
end
end

def fusion(id: )
Feature.find_by(feature_instance_type: 'Features::Fusion', id: id)&.feature_instance
end

def feature(id: )
Feature.find_by(id: id)
end
Expand Down

0 comments on commit 0aab45e

Please sign in to comment.