Skip to content

Commit

Permalink
improve error message in fill_annotation method
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanMainguy committed Jul 3, 2024
1 parent b25455d commit 4641fd0
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions ppanggolin/genome.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ def contig(self, contig: Contig):
raise TypeError(f'Expected type Contig, got {type(contig)}')
self._contig = contig

def fill_annotations(self, start: int, stop: int, strand: str, gene_type: str = "", name: str = "",
product: str = "", local_identifier: str = "", coordinates:List[Tuple[int]] = None):
def fill_annotations(self, start: int, stop: int, strand: str, gene_type: str = "", name: str = "",
product: str = "", local_identifier: str = "", coordinates: List[Tuple[int]] = None):
"""
Fill general annotation for child classes
Expand All @@ -162,31 +162,31 @@ def fill_annotations(self, start: int, stop: int, strand: str, gene_type: str =
coordinates = [(start, stop)]

if not isinstance(start, int):
raise TypeError("Start should be int")
raise TypeError(f"Start should be int. Got {type(start)} instead in {self} from {self.organism}.")
if not isinstance(stop, int):
raise TypeError("Stop should be int")
raise TypeError(f"Stop should be int. Got {type(stop)} instead in {self} from {self.organism}.")
if not isinstance(strand, str):
raise TypeError("Strand should be str")
raise TypeError(f"Strand should be str. Got {type(strand)} instead in {self} from {self.organism}.")
if not isinstance(gene_type, str):
raise TypeError("Gene type should be str")
raise TypeError(f"Gene type should be str. Got {type(gene_type)} instead in {self} from {self.organism}.")
if not isinstance(name, str):
raise TypeError("Name should be str")
raise TypeError(f"Name should be str. Got {type(name)} instead in {self} from {self.organism}.")
if not isinstance(product, str):
raise TypeError("Product should be str")
raise TypeError(f"Product should be str. Got {type(product)} instead in {self} from {self.organism}.")
if not isinstance(local_identifier, str):
raise TypeError("Local identifier should be str")
raise TypeError(f"Local identifier should be str. Got {type(local_identifier)} instead in {self} from {self.organism}.")
if strand not in ["+", "-"]:
raise ValueError("Strand should be + or -")
raise ValueError(f"Strand should be '+' or '-'. Got {strand} instead in {self} from {self.organism}.")
if not isinstance(coordinates, list):
raise TypeError(f"coordinates should be of type list. Type {type(coordinates)} was given instead")
raise TypeError(f"Coordinates should be of type list. Got {type(coordinates)} instead in {self} from {self.organism}.")

for start_i, stop_i in coordinates:
if not isinstance(start_i, int):
raise TypeError("Start should be int")
raise TypeError(f"Start should be int. Got {type(start_i)} instead in {self} from {self.organism}.")
if not isinstance(stop_i, int):
raise TypeError("Stop should be int")
raise TypeError(f"Stop should be int. Got {type(stop_i)} instead in {self} from {self.organism}.")
if stop_i < start_i:
raise ValueError(f"Wrong coordinates: {coordinates}. start ({start_i}) should not be greater than stop ({stop_i}).")
raise ValueError(f"Wrong coordinates: {coordinates}. Start ({start_i}) should not be greater than stop ({stop_i}) in {self} from {self.organism}.")


self.start = start
Expand Down

0 comments on commit 4641fd0

Please sign in to comment.