Skip to content

Handle SV in hypsipyle - #65

Merged
likhitha-surapaneni merged 61 commits into
Ensembl:dev-v2.0from
likhitha-surapaneni:feature/handle-sv
Nov 10, 2026
Merged

likhitha-surapaneni merged 61 commits into
Ensembl:dev-v2.0from
likhitha-surapaneni:feature/handle-sv

Conversation

@likhitha-surapaneni

@likhitha-surapaneni likhitha-surapaneni commented Feb 17, 2026 •

Copy link
Copy Markdown
Contributor

Test data: NW-52
HGSVC3 data: NW-136
Plants data: NW-148
Accessioned human data: NW-102

Example query:

examples/structural_variation/query.graphql

Testing:

Setup hypsipyle following README.md
Test with new data structure with the example query and check if the response matches example response

Ensembl VDM docs

@likhitha-surapaneni
likhitha-surapaneni marked this pull request as ready for review June 10, 2026 09:26

@richysix richysix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me know if any of the comments aren't clear.

Rich

Comment thread common/file_client.py Resolved
Comment thread common/base_file_client.py Resolved
Comment thread common/file_model/base_variant.py Resolved
Comment thread common/file_model/structural_variant.py Resolved
"""
return structural_variant.get_alleles()


Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't find resolver functions for @STRUCTURAL_VARIANT_ALLELE_TYPE length and copy_number
For copy number it returns null, but for length it causes an error because the schema says length can't be null

query structural_variant_allele_type {
  structural_variant(
    by_id: {
        genome_id: "a7335667-93e7-11ec-a39d-005056b38ce3",
        variant_id: "1:46000:nsv4514092"
    }
  ) {
    name
    alleles {
      name
      copy_number
      length
    }
  }
}
{
  "data": {
    "structural_variant": {
      "name": "nsv4514092",
      "alleles": [
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null,
        null
      ]
    }
  },
  "errors": [
    {
      "message": "Cannot return null for non-nullable field StructuralVariantAllele.length.",
      "locations": [
        {
          "line": 12,
          "column": 7
        }
      ],
      "path": [
        "structural_variant",
        "alleles",
        0,
        "length"
      ]
    },
...
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @richysix , made a fix to add these resolvers, please let me know if it works as expected

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Looks good

@likhitha-surapaneni

Copy link
Copy Markdown
Contributor Author

There's a few other attributes that are in the schema as being NOT NULL, but return null with some of the data files Test data

structural_variant.primary_source: "Cannot return null for non-nullable field StructuralVariant.primary_source.",
structural_variant.slice.region.length: "Cannot return null for non-nullable field Region.length."
structural_variant.slice.region.assembly: "Cannot return null for non-nullable field Region.assembly."

HGSVC3 data

structural_variant.primary_source: "Cannot return null for non-nullable field StructuralVariant.primary_source.",
structural_variant.slice.region.length: "Cannot return null for non-nullable field Region.length."
structural_variant.slice.region.assembly: "Cannot return null for non-nullable field Region.assembly."

structural_variant.alleles.slice.region.length: "Cannot return null for non-nullable field Region.length."
structural_variant.alleles.slice.region.sequence: "Cannot return null for non-nullable field Region.sequence."
structural_variant.alleles.slice.region.assembly: "Cannot return null for non-nullable field Region.assembly."
structural_variant.alleles.slice.region.metadata: "Cannot return null for non-nullable field Region.metadata."

Plants data & Accessioned human data

structural_variant.primary_source.accession_id: "Cannot return null for non-nullable field ExternalReference.accession_id."
structural_variant.primary_source.assignment_method: "Cannot return null for non-nullable field ExternalReference.assignment_method."
structural_variant.primary_source.source: "Cannot return null for non-nullable field ExternalReference.source."

structural_variant.alleles.slice.region.length: "Cannot return null for non-nullable field Region.length."
structural_variant.alleles.slice.region.sequence: "Cannot return null for non-nullable field Region.sequence."
structural_variant.alleles.slice.region.assembly: "Cannot return null for non-nullable field Region.assembly."
structural_variant.alleles.slice.region.metadata: "Cannot return null for non-nullable field Region.metadata."
  • Primary source should now work with HGSVC3 and plants data
  • For human accessioned, source is not In the header. This seems like a data issue
  • For slice.region attributes, out of scope for this PR and will be handled in https://embl.atlassian.net/browse/ENSVAR-6987

@richysix richysix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments are mostly typos and whitespace, but there's one about allele_type for the reference allele in common/file_model/structural_variant.py.

Comment on lines +14516 to +14522
},
{
"allele_name": "deletion",
"stable_id": "ENST00000831254"
},
{
"allele_name": "deletion"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the reference allele?
For SNVs, the reference allele has type biological_region. Should that be the same for structural variants? See my comment in structural_variant.py

Comment thread common/file_model/structural_variant.py Resolved
Comment thread common/file_model/structural_variant.py Resolved
Comment thread common/file_model/structural_variant.py Resolved
Comment thread common/file_model/structural_variant.py Resolved
Comment thread common/file_model/structural_variant.py Outdated
Comment on lines +212 to +214
if allele == self.ref:
allele_type = "biological_region"
so_term = "SO:0001411"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the reference allele, svtype gets set to None, so the if svtype: block doesn't run and the ref allele ends up with a type based on the ALT alleles
For SNVs and small indels, the REF allele type is "biological_region", so I'm assuming that should also happen here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @richysix , this should now be fixed. I separated the logic for get_allele_type for structural_variant and structural_variant_allele as it is getting a bit complex. Similar behaviour for short variants

likhitha-surapaneni and others added 15 commits September 21, 2026 10:17
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>
Co-authored-by: Richard White <richysix@users.noreply.github.com>

@richysix richysix left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All looks good now.

@likhitha-surapaneni

Copy link
Copy Markdown
Contributor Author

Confirm the folder structure with downstream pipeline before merging

@likhitha-surapaneni
likhitha-surapaneni merged commit eee15ad into Ensembl:dev-v2.0 Nov 10, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants