Skip to content

Commit

Permalink
add description to PromoterVariant
Browse files Browse the repository at this point in the history
  • Loading branch information
pnrobinson committed Oct 1, 2024
1 parent b8a208d commit aa889b0
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/pyphetools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from . import validation


__version__ = "0.9.106"
__version__ = "0.9.107"


__all__ = [
Expand Down
1 change: 1 addition & 0 deletions src/pyphetools/creation/promoter_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def to_variant_interpretation(self, acmg=None) -> VariantInterpretation202:
gene_descriptor = GeneDescriptor202(value_id=self._hgnc_id, symbol=self._gene_symbol)
vdescriptor = VariationDescriptor202(id=self._variant_id,
molecule_context=MoleculeContext202.genomic,
description=self._description,
gene_context=gene_descriptor,
label=self._description,
structural_type=self._sequence_ontology_term)
Expand Down
48 changes: 45 additions & 3 deletions src/pyphetools/visualization/detailed_suppl_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,44 @@
from .hpo_category import HpoCategorySet
from hpotk.model import TermId
from collections import defaultdict
import hpotk
from enum import Enum


ALL_ROOT = TermId.from_curie("HP:0000001")
PHENOTYPIC_ABNORMALITY_ROOT = TermId.from_curie("HP:0000118")

class HpoStatus(Enum):
OBSERVED = 1, "observed"
EXCLUDED = 2, "excluded"
NOT_AVAILABLE = 3, "na"


class HpoTableCell:
"""
Represents one cell of the detailed table
"""
def __init__(self,
hpo_term_id:hpotk.TermId,
status: HpoStatus
) -> None:
self._hpo_id = hpo_term_id
self._status = status

def to_cell(self):
return self._status.value

def to_cell_pm(self):
"""
Alternative plus-minus (pm) notation
"""
if self._status == HpoStatus.OBSERVED:
return "+"
elif self._status == HpoStatus.EXCLUDED:
return "-"
else:
return "na"



class DetailedSupplTable:
Expand All @@ -19,7 +53,9 @@ class DetailedSupplTable:
are shown as columns.
"""

def __init__(self, patient_list: typing.List[PPKt.Phenopacket], hp_json:str=None) -> None:
def __init__(self,
patient_list: typing.List[PPKt.Phenopacket],
hp_json:str=None) -> None:
"""
:param patient_d: dictionary of patients to display
:type patient_d: map with key string and value SimplePatient
Expand Down Expand Up @@ -47,6 +83,8 @@ def __init__(self, patient_list: typing.List[PPKt.Phenopacket], hp_json:str=None
# key is a string such as HP:0001234, value is an HpTerm object
# we need to convert it to an object from hpo-toolkit because get_ancestors returns HpTerm objects
hp_termid = TermId.from_curie(hp_id)
if not self._hp_ontology.graph.is_descendant_of(hp_termid, PHENOTYPIC_ABNORMALITY_ROOT):
continue # do not count terms that are not phenotypes
ancs = self._hp_ontology.graph.get_ancestors(hp_termid)
anc_set.add(hp_termid)
anc_set.update(ancs)
Expand All @@ -59,10 +97,14 @@ def __init__(self, patient_list: typing.List[PPKt.Phenopacket], hp_json:str=None
variants = pat.get_variant_list()
for var in variants:
var_d[var] += 1

# TODO figure out what to do with biallelic
self._hpo_category_set = HpoCategorySet(ontology=hp_ontology)

def _calculate_table(self, patient_list: typing.List[PPKt.Phenopacket], ) -> typing.List[typing.List[str]]:
for pat in self._simple_patient_list:
hpo_terms = pat.get_observed_hpo_d()
anc_set = set() # graph with ancestors induced by all terms of the patient



def _get_table(self, counts_d):
"""
Expand Down

0 comments on commit aa889b0

Please sign in to comment.