Skip to content

Commit

Permalink
fixup! implemented ortholog/paralog mapping functions
Browse files Browse the repository at this point in the history
  • Loading branch information
GuyTeichman committed Oct 8, 2023
1 parent f538ddb commit e52415c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions rnalysis/utils/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1511,10 +1511,9 @@ def get_paralogs(self, ids: Tuple[str, ...], filter_percent_identity: bool = Tru

return OrthologDict(mapping_one2many)


def get_orthologs(self, ids: Tuple[str, ...], non_unique_mode: str, filter_percent_identity: bool = True) -> \
Tuple[OrthologDict, OrthologDict]:
ids, translated_ids = self.translate_ids(ids)
def get_orthologs(self, ids: Tuple[str, ...], non_unique_mode: str, filter_percent_identity: bool = True) -> \
Tuple[OrthologDict, OrthologDict]:
ids, translated_ids = self.translate_ids(ids)
client = EnsemblRestClient()
mapping_one2one = {}
mapping_one2many = {}
Expand Down Expand Up @@ -1561,13 +1560,13 @@ def get_orthologs(self, ids: Tuple[str, ...], non_unique_mode: str, filter_perce
mapping_one2one[this_id] = req_output['homologies'][0]['target']['id']
pbar.update()

mapping_one2one, mapping_one2many = translate_mappings(ids, translated_ids, mapping_one2one, mapping_one2many)
mapping_one2one, mapping_one2many = translate_mappings(ids, translated_ids, mapping_one2one, mapping_one2many)

n_mapped = len(mapping_one2many)
if n_mapped < len(translated_ids):
warnings.warn(f"Ortholog mapping found for only {n_mapped} out of {len(translated_ids)} gene IDs.")
n_mapped = len(mapping_one2many)
if n_mapped < len(translated_ids):
warnings.warn(f"Ortholog mapping found for only {n_mapped} out of {len(translated_ids)} gene IDs.")

return OrthologDict(mapping_one2one), OrthologDict({k: v[0] for k, v in mapping_one2many.items()})
return OrthologDict(mapping_one2one), OrthologDict({k: v[0] for k, v in mapping_one2many.items()})


class PantherOrthologMapper:
Expand Down

0 comments on commit e52415c

Please sign in to comment.