Skip to content

Commit

Permalink
translocation
Browse files Browse the repository at this point in the history
  • Loading branch information
pnrobinson committed May 12, 2024
1 parent 62c83fa commit 56514b6
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/pyphetools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from . import visualization
from . import validation

__version__ = "0.9.84"
__version__ = "0.9.85"

__all__ = [
"creation",
Expand Down
5 changes: 5 additions & 0 deletions src/pyphetools/creation/import_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ def import_phenopackets_from_template(self,
deletions:typing.Set[str]=set(),
duplications:typing.Set[str]=set(),
inversions:typing.Set[str]=set(),
translocations:typing.Set[str]=set(),
hemizygous:bool=False,
leniant_MOI:bool=False):
"""Import the data from an Excel template and create a collection of Phenopackets
Expand All @@ -134,6 +135,8 @@ def import_phenopackets_from_template(self,
:type duplications: (typing.Set[str], optional
:param inversions: Strings (identical to entries in the templates) that represent inversions.
:type inversions: (typing.Set[str], optional
:param translocations: Strings (identical to entries in the templates) that represent translocations.
:type translocations: (typing.Set[str], optional
:param hemizygous: Set this to true for X-chromosomal recessive conditions in which the genotype of affected males is hemizygous
:type hemizygous: bool
:param leniant_MOI: Do not check allelic requirements. Use this if the disease being curated has more than one MOI. This may require manually adding the "second" MOI in PhenoteFX
Expand Down Expand Up @@ -166,6 +169,8 @@ def import_phenopackets_from_template(self,
vman.code_as_chromosomal_duplication(duplications)
if len(inversions) > 0:
vman.code_as_chromosomal_inversion(inversions)
if len(translocations) > 0:
vman.code_as_chromosomal_translocation(translocations)
if vman.has_unmapped_alleles():
mapped = vman.get_mapped_allele_count()
print(f"We were able to map {mapped} alleles.")
Expand Down
27 changes: 27 additions & 0 deletions src/pyphetools/creation/structural_variant.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,3 +183,30 @@ def chromosomal_inversion(cell_contents,
sequence_ontology_id="SO:1000030",
sequence_ontology_label="chromosomal_inversion",
variant_id=variant_id)

@staticmethod
def chromosomal_translocation(cell_contents,
gene_symbol,
gene_id,
genotype,
variant_id=None):
"""
create a StructuralVariant object for a chromosomal translocation
:param cell_contents: the string from the original table that we want to map as a structural variant
:type cell_contents: str
:param gene_symbol: the gene affected by the structural variant, e.g., GLI3
:type gene_symbol: str
:param gene_id: the identifier (using HGNC) of the gene, e.g., GLI3 is HGNC:4319
:type gene_id: str
:param genotype: Genotype (heterozygous, homozygous, hemizygous) of this variant call
:type genotype: str
:param variant_id: an identifier for the variant
:type variant_id: str, optional
"""
return StructuralVariant(cell_contents=cell_contents,
gene_symbol=gene_symbol,
gene_id=gene_id,
sequence_ontology_id="SO:1000044",
sequence_ontology_label="chromosomal_translocation",
variant_id=variant_id)
15 changes: 15 additions & 0 deletions src/pyphetools/creation/variant_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ def code_as_chromosomal_inversion(self, allele_set) -> None:
self._unmapped_alleles.remove(allele)
self._var_d[allele] = var

def code_as_chromosomal_translocation(self, allele_set) -> None:
"""
Code as Structural variants - chromosomal translocation (to be added to self._var_d)
:param allele_set: Set of alleles (strings) for coding as Structural variants (chromosomal inversion)
"""
# first check that all of the alleles are in self._unmapped_alleles
if not allele_set.issubset(self._unmapped_alleles):
raise ValueError("[ERROR] We can only map alleles that were passed to the constructor - are you trying to map \"new\" alleles?")
if self._gene_id is None or self._gene_symbol is None:
raise ValueError("[ERROR] We cannot use this method unless the gene ID (HGNC) and symbol were passed to the constructor")
for allele in allele_set:
var = StructuralVariant.chromosomal_translocation(cell_contents=allele, gene_symbol=self._gene_symbol, gene_id=self._gene_id)
self._unmapped_alleles.remove(allele)
self._var_d[allele] = var


def to_summary(self) -> pd.DataFrame:
"""
Expand Down

0 comments on commit 56514b6

Please sign in to comment.