Skip to content

Commit

Permalink
Merge pull request #901 from griffithlab/allele-registry-filtering
Browse files Browse the repository at this point in the history
add ability to fetch Variants and MPs using ClinGen Allele Registry ids
  • Loading branch information
acoffman authored Oct 3, 2023
2 parents 4b24df1 + d2bb5a3 commit 2ceae64
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 1 deletion.
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 @@ -5681,6 +5681,11 @@ type Query {
"""
after: String

"""
Find Molecular Profiles based on the ClinGen Allele Registry ID of one of its involed Variants
"""
alleleRegistryId: String

"""
Returns the elements in the list that come before the specified cursor.
"""
Expand Down Expand Up @@ -6250,6 +6255,11 @@ type Query {
"""
after: String

"""
Find a CIViC Variant based on its ClinGen Allele Registry ID
"""
alleleRegistryId: String

"""
Returns the elements in the list that come before the specified cursor.
"""
Expand Down
24 changes: 24 additions & 0 deletions client/src/app/generated/server.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -25568,6 +25568,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "alleleRegistryId",
"description": "Find Molecular Profiles based on the ClinGen Allele Registry ID of one of its involed Variants",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "after",
"description": "Returns the elements in the list that come after the specified cursor.",
Expand Down Expand Up @@ -27931,6 +27943,18 @@
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "alleleRegistryId",
"description": "Find a CIViC Variant based on its ClinGen Allele Registry ID",
"type": {
"kind": "SCALAR",
"name": "String",
"ofType": null
},
"defaultValue": null,
"isDeprecated": false,
"deprecationReason": null
},
{
"name": "hasNoVariantType",
"description": "Return Variants lacking an assigned VariantType",
Expand Down
7 changes: 6 additions & 1 deletion server/app/graphql/mutations/create_molecular_profile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ def ready?(structure: )

if variants.size != variant_ids.size
missing = variant_ids - variants.map(&:id)
raise GraphQL::ExecutionError, "Variants with ID [#{missing.join(', ')}] were not found."
raise GraphQL::ExecutionError, "Variants with ID [#{missing.join(', ')}] were not found."
end

deprecated_variants = variants.select { |v| v.deprecated? }
if deprecated_variants.any?
raise GraphQL::ExecutionError, "Variants [#{deprecated_variants.map(&:name).join(', ')}] are Deprecated and should not be used."
end

return true
Expand Down
3 changes: 3 additions & 0 deletions server/app/graphql/resolvers/top_level_molecular_profiles.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ class Resolvers::TopLevelMolecularProfiles < GraphQL::Schema::Resolver
scope.joins(:variants).where('variants.id = ?', value)
end

option(:allele_registry_id, type: GraphQL::Types::String, description: 'Find Molecular Profiles based on the ClinGen Allele Registry ID of one of its involed Variants') do |scope, value|
scope.joins(:variants).where('variants.allele_registry_id = ?', value)
end
end
4 changes: 4 additions & 0 deletions server/app/graphql/resolvers/top_level_variants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class Resolvers::TopLevelVariants < GraphQL::Schema::Resolver
end
end

option(:allele_registry_id, type: GraphQL::Types::String, description: 'Find a CIViC Variant based on its ClinGen Allele Registry ID') do |scope, value|
scope.where(allele_registry_id: value)
end

option(:has_no_variant_type, type: GraphQL::Types::Boolean, description: "Return Variants lacking an assigned VariantType") do |scope, value|
if(value)
scope.left_joins(:variant_types).where(variant_types: { id: nil })
Expand Down

0 comments on commit 2ceae64

Please sign in to comment.