Skip to content

Develop#20

Merged
VarenyaJ merged 21 commits intomainfrom
develop
Sep 15, 2025
Merged

Develop#20
VarenyaJ merged 21 commits intomainfrom
develop

Conversation

@VarenyaJ
Copy link
Copy Markdown
Owner

Pull latest changes into main

VarenyaJ and others added 21 commits August 15, 2025 15:12
…nheritance

- Added mapping of HGNC gene symbols into VariationDescriptor.gene_context
- Added zygosity → GA4GH GENO allelicState mapping
- Added inheritance parsing (stored in Genotype dataclass, reserved for future use)
- Updated DefaultMapper._add_genotype_interpretations to use new
  Genotype.to_variation_descriptor(), ensuring expressions + VRS JSON
  description + allelicState + geneContext are emitted in phenopackets
- Preserved previous behavior for phenotype/disease/measurement/biosample
…or construction

- Replaced `except Exception:` with explicit attribute checks (`hasattr`, `getattr`)
  to comply with Ruff BLE001 and avoid masking unrelated runtime errors.
- In `to_variation_descriptor`:
  - Guarded `molecule_context` assignment with `hasattr` instead of try/except.
  - Guarded stable ID assignment with `if g_expr` check.
- In `_add_hgvs_expression`:
  - Use `getattr(type(expr), "HGVS", None)` instead of try/except.
- In `_attempt_pyphetools_normalize`:
  - Removed redundant try/except; explicitly return `None` until a stable
    pyphetools API exists.
… for VariationDescriptor construction

- Replaced `except Exception:` blocks with explicit `hasattr` / `getattr` checks to comply with Ruff BLE001 and avoid masking unrelated errors.
- In `Genotype.to_variation_descriptor`:
  - Guarded `gene_context` and `allelic_state` assignments with explicit checks.
  - Rewrote allele JSON description building without try/except.
  - Added molecule_context assignment only when supported.
  - Generated stable IDs using an explicit guard instead of catching failures.
- In `_add_hgvs_expression`, probed for `HGVS` enum explicitly instead of relying on try/except.
- In `_attempt_pyphetools_normalize`, removed no-op try/except; return `None` until a stable API emerges.
- In `__main__.py`, replaced CopyFrom fallback try/except with feature detection (`getattr` + callable check).
- Introduced `vv_lookup.py` module to query VariantValidator’s REST API for
  transcript and gene cross-references.
- Provides `get_gene_xrefs_vv()` helper to return HGNC ID, Ensembl gene ID,
  and RefSeq transcripts for a given HGNC gene symbol.
- Handles API rate limits (1 request/sec) and provides robust error handling
  via custom `VVLookupError`.
- Designed to integrate with Genotype → VariationDescriptor pipeline as an
  optional enrichment step when P6_ENRICH_GENE_XREFS is enabled.
… retries

- New module `vv_lookup.py` to enrich gene_context with HGNC/Ensembl IDs and
  canonical transcript accessions using VariantValidator.
- Prefer v2 `gene2transcripts_v2` endpoint; fallback to v1 when needed.
- Normalize variable VV payloads into a compact dict:
  {hgnc_id, ensembl_gene_id, refseq_transcripts, ensembl_transcripts}.
- Add small retry/backoff and a custom VVLookupError for clean failure handling.
- Thorough docstrings and comments explaining the high-level P6 flow.
… enrichment

- Clear sectioned comments/docstrings describing P6’s high-level flow.
- Narrow overly broad exception handlers to satisfy linting and improve safety.
- Optional enrichment via `vv_lookup.get_gene_xrefs_vv` behind P6_ENRICH_GENE_XREFS.
- Keep P6_SKIP_VV escape hatch; maintain robust local fallback descriptor path.
- Ensure normalized g. expression and allelic_state are always present.
… satisfy C901

- Extract _should_skip_vv, _try_build_descriptor_via_vv, _enrich_descriptor_common,
  and _maybe_enrich_gene_xrefs helpers.
- Try to keep exact behavior and error handling; just reduce branching in the main method.
Add the Variant field using VariationDescriptor, implement the VariantValidator lookup from PyPheTools, and lint/refactor some code
Latest transformation of Tony's Excel genotype/phenotype records into Phenopackets
@VarenyaJ VarenyaJ marked this pull request as ready for review September 11, 2025 10:59
@VarenyaJ VarenyaJ merged commit 9d81bd0 into main Sep 15, 2025
2 checks passed
@VarenyaJ VarenyaJ mentioned this pull request Sep 22, 2025
5 tasks
@VarenyaJ VarenyaJ linked an issue Sep 22, 2025 that may be closed by this pull request
5 tasks
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.

Develop branch merge into Main

1 participant