diff --git a/src/pyphetools/__init__.py b/src/pyphetools/__init__.py index 39c0ab67..23fe80e2 100644 --- a/src/pyphetools/__init__.py +++ b/src/pyphetools/__init__.py @@ -4,7 +4,7 @@ from . import visualization from . import validation -__version__ = "0.9.84" +__version__ = "0.9.85" __all__ = [ "creation", diff --git a/src/pyphetools/creation/import_template.py b/src/pyphetools/creation/import_template.py index afcbd309..f9dbf185 100644 --- a/src/pyphetools/creation/import_template.py +++ b/src/pyphetools/creation/import_template.py @@ -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 @@ -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 @@ -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.") diff --git a/src/pyphetools/creation/structural_variant.py b/src/pyphetools/creation/structural_variant.py index cedff6ec..4c0164c3 100644 --- a/src/pyphetools/creation/structural_variant.py +++ b/src/pyphetools/creation/structural_variant.py @@ -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) diff --git a/src/pyphetools/creation/variant_manager.py b/src/pyphetools/creation/variant_manager.py index 0f05b906..32085c32 100644 --- a/src/pyphetools/creation/variant_manager.py +++ b/src/pyphetools/creation/variant_manager.py @@ -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: """