Skip to content

Commit

Permalink
add types + small if condition refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
nayib-jose-gloria committed Sep 19, 2023
1 parent 3d8cb5c commit e0d430e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions cellxgene_schema_cli/cellxgene_schema/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def is_valid_id(self, gene_id: str) -> bool:

return gene_id in self.gene_dict

def get_symbol(self, gene_id) -> str:
def get_symbol(self, gene_id: str) -> str:
"""
Gets symbol associated to the ENSEBML id
Expand All @@ -103,12 +103,12 @@ def get_symbol(self, gene_id) -> str:
:return A gene symbol
"""

if not self.is_valid_id(gene_id):
if self.is_valid_id(gene_id):
return self.gene_dict[gene_id][0]
else:
raise ValueError(f"The id '{gene_id}' is not a valid ENSEMBL id for '{self.species}'")

return self.gene_dict[gene_id][0]

def get_length(self, gene_id) -> int:
def get_length(self, gene_id: str) -> int:
"""
Gets feature length associated to the ENSEBML id
Expand All @@ -118,11 +118,11 @@ def get_length(self, gene_id) -> int:
:return A gene length
"""

if not self.is_valid_id(gene_id):
if self.is_valid_id(gene_id):
return self.gene_dict[gene_id][1]
else:
raise ValueError(f"The id '{gene_id}' is not a valid ENSEMBL id for '{self.species}'")

return self.gene_dict[gene_id][1]


class OntologyChecker:
"""Handles checking ontology term ids, retrieves ontology labels and ancestors"""
Expand Down

0 comments on commit e0d430e

Please sign in to comment.