diff --git a/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.component.ts b/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.component.ts index 6517b5ac2..33276afdf 100644 --- a/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.component.ts +++ b/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.component.ts @@ -7,7 +7,7 @@ import { MolecularProfileConnection, MolecularProfileMenuQueryVariables, MolecularProfileMenuGQL, - MolecularProfileDisplayFilter, + AssociatedEvidenceStatusFilter, } from '@app/generated/civic.apollo' import { map, debounceTime, filter, startWith } from 'rxjs/operators' import { Observable, Subject } from 'rxjs' @@ -32,8 +32,8 @@ export class CvcMolecularProfilesMenuComponent implements OnInit { loading$?: Observable; mpNameFilter: Maybe - statusFilter: MolecularProfileDisplayFilter = - MolecularProfileDisplayFilter.All + statusFilter: AssociatedEvidenceStatusFilter = + AssociatedEvidenceStatusFilter.All private debouncedQuery = new Subject() private result$!: Observable> @@ -91,7 +91,7 @@ export class CvcMolecularProfilesMenuComponent implements OnInit { this.debouncedQuery.next() } - onMolecularProfileStatusFilterChanged(filter: MolecularProfileDisplayFilter) { + onMolecularProfileStatusFilterChanged(filter: AssociatedEvidenceStatusFilter) { this.queryRef$.refetch({ first: this.pageSize, evidenceStatusFilter: filter diff --git a/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.gql b/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.gql index 9d4075285..4722120af 100644 --- a/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.gql +++ b/client/src/app/components/molecular-profiles/molecular-profiles-menu/molecular-profiles-menu.gql @@ -6,7 +6,7 @@ query MolecularProfileMenu( $last: Int $before: String $after: String - $evidenceStatusFilter: MolecularProfileDisplayFilter + $evidenceStatusFilter: AssociatedEvidenceStatusFilter ) { molecularProfiles( geneId: $geneId diff --git a/client/src/app/generated/civic.apollo.ts b/client/src/app/generated/civic.apollo.ts index e81d5dc3e..255fe12d6 100644 --- a/client/src/app/generated/civic.apollo.ts +++ b/client/src/app/generated/civic.apollo.ts @@ -490,6 +490,17 @@ export enum AssertionType { Prognostic = 'PROGNOSTIC' } +export enum AssociatedEvidenceStatusFilter { + /** Apply no status filter to an entity in order to display all entities regardless of attached evidence status. */ + All = 'ALL', + /** Apply filter to an entity to display only those which have at least one accepted associated evidence item. */ + WithAccepted = 'WITH_ACCEPTED', + /** Apply filter to an entity to display only those which have at least one accepted or submitted associated evidence item. */ + WithAcceptedOrSubmitted = 'WITH_ACCEPTED_OR_SUBMITTED', + /** Apply filter to an entity to display only those which have at least one submitted associated evidence item. */ + WithSubmitted = 'WITH_SUBMITTED' +} + export enum BooleanOperator { And = 'AND', Or = 'OR' @@ -3965,17 +3976,6 @@ export enum MolecularProfileDeprecationReasonMutationInput { Other = 'OTHER' } -export enum MolecularProfileDisplayFilter { - /** Display all molecular profiles regardless of attached evidence status. */ - All = 'ALL', - /** Display only molecular profiles which have at least one accepted evidence item. */ - WithAccepted = 'WITH_ACCEPTED', - /** Display only molecular profiles which have evidence in either an accepted or submitted state. */ - WithAcceptedOrSubmitted = 'WITH_ACCEPTED_OR_SUBMITTED', - /** Display molecular profiles which have at least one submitted evidence item. */ - WithSubmitted = 'WITH_SUBMITTED' -} - /** An edge in a connection. */ export type MolecularProfileEdge = { __typename: 'MolecularProfileEdge'; @@ -5280,6 +5280,7 @@ export type QueryFactorArgs = { export type QueryFactorsArgs = { after?: InputMaybe; before?: InputMaybe; + evidenceStatusFilter?: InputMaybe; first?: InputMaybe; last?: InputMaybe; name?: InputMaybe>; @@ -5324,8 +5325,7 @@ export type QueryFusionArgs = { export type QueryFusionsArgs = { after?: InputMaybe; before?: InputMaybe; - entrezIds?: InputMaybe>; - entrezSymbols?: InputMaybe>; + evidenceStatusFilter?: InputMaybe; first?: InputMaybe; genePartnerId?: InputMaybe; last?: InputMaybe; @@ -5343,6 +5343,7 @@ export type QueryGenesArgs = { before?: InputMaybe; entrezIds?: InputMaybe>; entrezSymbols?: InputMaybe>; + evidenceStatusFilter?: InputMaybe; first?: InputMaybe; last?: InputMaybe; }; @@ -5357,7 +5358,7 @@ export type QueryMolecularProfilesArgs = { after?: InputMaybe; alleleRegistryId?: InputMaybe; before?: InputMaybe; - evidenceStatusFilter?: InputMaybe; + evidenceStatusFilter?: InputMaybe; featureId?: InputMaybe; first?: InputMaybe; geneId?: InputMaybe; @@ -8287,7 +8288,7 @@ export type MolecularProfileMenuQueryVariables = Exact<{ last?: InputMaybe; before?: InputMaybe; after?: InputMaybe; - evidenceStatusFilter?: InputMaybe; + evidenceStatusFilter?: InputMaybe; }>; @@ -14472,7 +14473,7 @@ export const BrowseMolecularProfilesDocument = gql` } } export const MolecularProfileMenuDocument = gql` - query MolecularProfileMenu($geneId: Int, $featureId: Int, $mpName: String, $first: Int, $last: Int, $before: String, $after: String, $evidenceStatusFilter: MolecularProfileDisplayFilter) { + query MolecularProfileMenu($geneId: Int, $featureId: Int, $mpName: String, $first: Int, $last: Int, $before: String, $after: String, $evidenceStatusFilter: AssociatedEvidenceStatusFilter) { molecularProfiles( geneId: $geneId featureId: $featureId diff --git a/client/src/app/generated/server.model.graphql b/client/src/app/generated/server.model.graphql index 523f5e7b4..46613e4e1 100644 --- a/client/src/app/generated/server.model.graphql +++ b/client/src/app/generated/server.model.graphql @@ -796,6 +796,28 @@ enum AssertionType { PROGNOSTIC } +enum AssociatedEvidenceStatusFilter { + """ + Apply no status filter to an entity in order to display all entities regardless of attached evidence status. + """ + ALL + + """ + Apply filter to an entity to display only those which have at least one accepted associated evidence item. + """ + WITH_ACCEPTED + + """ + Apply filter to an entity to display only those which have at least one accepted or submitted associated evidence item. + """ + WITH_ACCEPTED_OR_SUBMITTED + + """ + Apply filter to an entity to display only those which have at least one submitted associated evidence item. + """ + WITH_SUBMITTED +} + enum BooleanOperator { AND OR @@ -6978,28 +7000,6 @@ enum MolecularProfileDeprecationReasonMutationInput { OTHER } -enum MolecularProfileDisplayFilter { - """ - Display all molecular profiles regardless of attached evidence status. - """ - ALL - - """ - Display only molecular profiles which have at least one accepted evidence item. - """ - WITH_ACCEPTED - - """ - Display only molecular profiles which have evidence in either an accepted or submitted state. - """ - WITH_ACCEPTED_OR_SUBMITTED - - """ - Display molecular profiles which have at least one submitted evidence item. - """ - WITH_SUBMITTED -} - """ An edge in a connection. """ @@ -8946,6 +8946,11 @@ type Query { """ before: String + """ + Limit factors by the status of attached evidence. + """ + evidenceStatusFilter: AssociatedEvidenceStatusFilter + """ Returns the first _n_ elements from the list. """ @@ -9048,14 +9053,9 @@ type Query { before: String """ - List of Entrez Gene IDs to return results for + Limit fusions by the status of attached evidence. """ - entrezIds: [Int!] - - """ - List of Entrez Gene symbols to return results for - """ - entrezSymbols: [String!] + evidenceStatusFilter: AssociatedEvidenceStatusFilter """ Returns the first _n_ elements from the list. @@ -9102,6 +9102,11 @@ type Query { """ entrezSymbols: [String!] + """ + Limit genes by the status of attached evidence. + """ + evidenceStatusFilter: AssociatedEvidenceStatusFilter + """ Returns the first _n_ elements from the list. """ @@ -9140,7 +9145,7 @@ type Query { """ Limit molecular profiles by the status of attached evidence. """ - evidenceStatusFilter: MolecularProfileDisplayFilter + evidenceStatusFilter: AssociatedEvidenceStatusFilter """ Filter molecular profiles to the CIViC ID of the feature(s) involved. diff --git a/client/src/app/generated/server.schema.json b/client/src/app/generated/server.schema.json index 6ef82b2e8..c901fe208 100644 --- a/client/src/app/generated/server.schema.json +++ b/client/src/app/generated/server.schema.json @@ -3606,6 +3606,41 @@ ], "possibleTypes": null }, + { + "kind": "ENUM", + "name": "AssociatedEvidenceStatusFilter", + "description": null, + "fields": null, + "inputFields": null, + "interfaces": null, + "enumValues": [ + { + "name": "WITH_ACCEPTED", + "description": "Apply filter to an entity to display only those which have at least one accepted associated evidence item.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "WITH_ACCEPTED_OR_SUBMITTED", + "description": "Apply filter to an entity to display only those which have at least one accepted or submitted associated evidence item.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "WITH_SUBMITTED", + "description": "Apply filter to an entity to display only those which have at least one submitted associated evidence item.", + "isDeprecated": false, + "deprecationReason": null + }, + { + "name": "ALL", + "description": "Apply no status filter to an entity in order to display all entities regardless of attached evidence status.", + "isDeprecated": false, + "deprecationReason": null + } + ], + "possibleTypes": null + }, { "kind": "SCALAR", "name": "Boolean", @@ -32553,41 +32588,6 @@ ], "possibleTypes": null }, - { - "kind": "ENUM", - "name": "MolecularProfileDisplayFilter", - "description": null, - "fields": null, - "inputFields": null, - "interfaces": null, - "enumValues": [ - { - "name": "WITH_ACCEPTED", - "description": "Display only molecular profiles which have at least one accepted evidence item.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "WITH_ACCEPTED_OR_SUBMITTED", - "description": "Display only molecular profiles which have evidence in either an accepted or submitted state.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "WITH_SUBMITTED", - "description": "Display molecular profiles which have at least one submitted evidence item.", - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "ALL", - "description": "Display all molecular profiles regardless of attached evidence status.", - "isDeprecated": false, - "deprecationReason": null - } - ], - "possibleTypes": null - }, { "kind": "OBJECT", "name": "MolecularProfileEdge", @@ -41074,6 +41074,18 @@ "name": "factors", "description": "List and filter factors.", "args": [ + { + "name": "evidenceStatusFilter", + "description": "Limit factors by the status of attached evidence.", + "type": { + "kind": "ENUM", + "name": "AssociatedEvidenceStatusFilter", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "ncitIt", "description": "List of NCIt Codes to return Factors for", @@ -41437,11 +41449,11 @@ "description": "List and filter fusions.", "args": [ { - "name": "genePartnerId", - "description": "CIViC ID of one of the Gene partners", + "name": "evidenceStatusFilter", + "description": "Limit fusions by the status of attached evidence.", "type": { - "kind": "SCALAR", - "name": "Int", + "kind": "ENUM", + "name": "AssociatedEvidenceStatusFilter", "ofType": null }, "defaultValue": null, @@ -41449,40 +41461,12 @@ "deprecationReason": null }, { - "name": "entrezSymbols", - "description": "List of Entrez Gene symbols to return results for", - "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "String", - "ofType": null - } - } - }, - "defaultValue": null, - "isDeprecated": false, - "deprecationReason": null - }, - { - "name": "entrezIds", - "description": "List of Entrez Gene IDs to return results for", + "name": "genePartnerId", + "description": "CIViC ID of one of the Gene partners", "type": { - "kind": "LIST", - "name": null, - "ofType": { - "kind": "NON_NULL", - "name": null, - "ofType": { - "kind": "SCALAR", - "name": "Int", - "ofType": null - } - } + "kind": "SCALAR", + "name": "Int", + "ofType": null }, "defaultValue": null, "isDeprecated": false, @@ -41590,6 +41574,18 @@ "name": "genes", "description": "List and filter genes.", "args": [ + { + "name": "evidenceStatusFilter", + "description": "Limit genes by the status of attached evidence.", + "type": { + "kind": "ENUM", + "name": "AssociatedEvidenceStatusFilter", + "ofType": null + }, + "defaultValue": null, + "isDeprecated": false, + "deprecationReason": null + }, { "name": "entrezSymbols", "description": "List of Entrez Gene symbols to return results for", @@ -41729,7 +41725,7 @@ "description": "Limit molecular profiles by the status of attached evidence.", "type": { "kind": "ENUM", - "name": "MolecularProfileDisplayFilter", + "name": "AssociatedEvidenceStatusFilter", "ofType": null }, "defaultValue": null, diff --git a/server/app/graphql/resolvers/top_level_factors.rb b/server/app/graphql/resolvers/top_level_factors.rb index 670156507..e5fc53636 100644 --- a/server/app/graphql/resolvers/top_level_factors.rb +++ b/server/app/graphql/resolvers/top_level_factors.rb @@ -8,10 +8,27 @@ class Resolvers::TopLevelFactors < GraphQL::Schema::Resolver description 'List and filter factors.' scope do - Features::Factor - .eager_load(:feature) - .joins(feature: {variants: [molecular_profiles: [:evidence_items]]}) - .order('features.name ASC').where("evidence_items.status != 'rejected'").distinct + Features::Factor.joins(feature: { variants: [:molecular_profiles]}) + .where("variants.deprecated = 'f'") + .order('features.name ASC') + .select("factors.*, features.name") + .distinct + end + + option(:evidence_status_filter, default_value: 'WITH_ACCEPTED_OR_SUBMITTED', type: Types::AssociatedEvidenceStatusFilterType , description: 'Limit factors by the status of attached evidence.') do |scope, value| + case value + when 'WITH_ACCEPTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.accepted_count >= 1') + when 'WITH_ACCEPTED_OR_SUBMITTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.accepted_count >= 1 OR evidence_items_by_statuses.submitted_count >= 1') + when 'WITH_SUBMITTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.submitted_count >= 1') + when 'ALL' + scope + end end option(:ncit_it, type: [GraphQL::Types::String], description: 'List of NCIt Codes to return Factors for') do |scope, value| diff --git a/server/app/graphql/resolvers/top_level_fusions.rb b/server/app/graphql/resolvers/top_level_fusions.rb index 407a745a3..f6fce847e 100644 --- a/server/app/graphql/resolvers/top_level_fusions.rb +++ b/server/app/graphql/resolvers/top_level_fusions.rb @@ -10,20 +10,30 @@ class Resolvers::TopLevelFusions < GraphQL::Schema::Resolver @@cols = Features::Fusion.column_names.map { |col| "fusions.#{col}" }.join(",") scope do - Features::Fusion.joins(feature: { variants: [:molecular_profiles ]}) + Features::Fusion.joins(feature: { variants: [:molecular_profiles]}) .where("variants.deprecated = 'f'") + .order('features.name ASC') + .select("fusions.*, features.name") .distinct end - option(:gene_partner_id, type: Int, description: 'CIViC ID of one of the Gene partners') do |scope, value| - scope.where('fusions.five_prime_gene_id = ? OR fusions.three_prime_gene_id = ?', value, value) - end - - option(:entrez_symbols, type: [GraphQL::Types::String], description: 'List of Entrez Gene symbols to return results for') do |scope, value| - scope.where('genes.name IN (?)', value.map(&:upcase)) + option(:evidence_status_filter, default_value: 'WITH_ACCEPTED_OR_SUBMITTED', type: Types::AssociatedEvidenceStatusFilterType , description: 'Limit fusions by the status of attached evidence.') do |scope, value| + case value + when 'WITH_ACCEPTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.accepted_count >= 1') + when 'WITH_ACCEPTED_OR_SUBMITTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.accepted_count >= 1 OR evidence_items_by_statuses.submitted_count >= 1') + when 'WITH_SUBMITTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.submitted_count >= 1') + when 'ALL' + scope + end end - option(:entrez_ids, type: [GraphQL::Types::Int], description: 'List of Entrez Gene IDs to return results for') do |scope, value| - scope.where('genes.entrez_id IN (?)', value) + option(:gene_partner_id, type: Int, description: 'CIViC ID of one of the Gene partners') do |scope, value| + scope.where('fusions.five_prime_gene_id = ? OR fusions.three_prime_gene_id = ?', value, value) end end diff --git a/server/app/graphql/resolvers/top_level_genes.rb b/server/app/graphql/resolvers/top_level_genes.rb index 6a202b4bf..38ba9ffc1 100644 --- a/server/app/graphql/resolvers/top_level_genes.rb +++ b/server/app/graphql/resolvers/top_level_genes.rb @@ -8,13 +8,29 @@ class Resolvers::TopLevelGenes < GraphQL::Schema::Resolver description 'List and filter genes.' scope do - Features::Gene.joins(feature: { variants: [molecular_profiles: [:evidence_items]]}) + Features::Gene.joins(feature: { variants: [:molecular_profiles]}) + .where("variants.deprecated = 'f'") .order('features.name ASC') - .where("evidence_items.status != 'rejected'") .select("genes.*, features.name") .distinct end + option(:evidence_status_filter, default_value: 'WITH_ACCEPTED_OR_SUBMITTED', type: Types::AssociatedEvidenceStatusFilterType , description: 'Limit genes by the status of attached evidence.') do |scope, value| + case value + when 'WITH_ACCEPTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.accepted_count >= 1') + when 'WITH_ACCEPTED_OR_SUBMITTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.accepted_count >= 1 OR evidence_items_by_statuses.submitted_count >= 1') + when 'WITH_SUBMITTED' + scope.joins(feature: { variants: { molecular_profiles: [:evidence_items_by_status] } }) + .where('evidence_items_by_statuses.submitted_count >= 1') + when 'ALL' + scope + end + end + option(:entrez_symbols, type: [GraphQL::Types::String], description: 'List of Entrez Gene symbols to return results for') do |scope, value| scope.where('features.name IN (?)', value.map(&:upcase)) end diff --git a/server/app/graphql/resolvers/top_level_molecular_profiles.rb b/server/app/graphql/resolvers/top_level_molecular_profiles.rb index 315e064c3..6fbab8f30 100644 --- a/server/app/graphql/resolvers/top_level_molecular_profiles.rb +++ b/server/app/graphql/resolvers/top_level_molecular_profiles.rb @@ -9,7 +9,7 @@ class Resolvers::TopLevelMolecularProfiles < GraphQL::Schema::Resolver scope { MolecularProfile.where(deprecated: false).order('molecular_profiles.evidence_score DESC').distinct } - option(:evidence_status_filter, default_value: 'WITH_ACCEPTED_OR_SUBMITTED', type: Types::MolecularProfileDisplayFilterType , description: 'Limit molecular profiles by the status of attached evidence.') do |scope, value| + option(:evidence_status_filter, default_value: 'WITH_ACCEPTED_OR_SUBMITTED', type: Types::AssociatedEvidenceStatusFilterType , description: 'Limit molecular profiles by the status of attached evidence.') do |scope, value| case value when 'WITH_ACCEPTED' scope.joins(:evidence_items_by_status) diff --git a/server/app/graphql/types/associated_evidence_status_filter_type.rb b/server/app/graphql/types/associated_evidence_status_filter_type.rb new file mode 100644 index 000000000..c3261ba48 --- /dev/null +++ b/server/app/graphql/types/associated_evidence_status_filter_type.rb @@ -0,0 +1,12 @@ +module Types + class AssociatedEvidenceStatusFilterType < Types::BaseEnum + value 'WITH_ACCEPTED', + description: 'Apply filter to an entity to display only those which have at least one accepted associated evidence item.' + value 'WITH_ACCEPTED_OR_SUBMITTED', + description: 'Apply filter to an entity to display only those which have at least one accepted or submitted associated evidence item.' + value 'WITH_SUBMITTED', + description: 'Apply filter to an entity to display only those which have at least one submitted associated evidence item.' + value 'ALL', + description: 'Apply no status filter to an entity in order to display all entities regardless of attached evidence status.' + end +end diff --git a/server/app/graphql/types/molecular_profile_display_filter_type.rb b/server/app/graphql/types/molecular_profile_display_filter_type.rb deleted file mode 100644 index 1fde9f7fd..000000000 --- a/server/app/graphql/types/molecular_profile_display_filter_type.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Types - class MolecularProfileDisplayFilterType < Types::BaseEnum - value 'WITH_ACCEPTED', - description: 'Display only molecular profiles which have at least one accepted evidence item.' - value 'WITH_ACCEPTED_OR_SUBMITTED', - description: 'Display only molecular profiles which have evidence in either an accepted or submitted state.' - value 'WITH_SUBMITTED', - description: 'Display molecular profiles which have at least one submitted evidence item.' - value 'ALL', - description: 'Display all molecular profiles regardless of attached evidence status.' - end -end