Skip to content
Snippets Groups Projects
Commit 70c8c0f8 authored by nfontrod's avatar nfontrod
Browse files

src/gc_content/gc_content.py: fix tests

parent 66da01e0
Branches
No related tags found
No related merge requests found
Pipeline #121 failed
...@@ -29,24 +29,26 @@ def get_gc_content(bed_line: List[Any], dic_seq: Fasta) -> float: ...@@ -29,24 +29,26 @@ def get_gc_content(bed_line: List[Any], dic_seq: Fasta) -> float:
:param dic_seq: A dictionary containing chromosomal sequences :param dic_seq: A dictionary containing chromosomal sequences
:return: The gc content :return: The gc content
>>> dic_seq = Fasta(str(TestConfig.test_fasta))
>>> get_gc_content(["chr1", 0, 10, "s1", ".", "+"], >>> get_gc_content(["chr1", 0, 10, "s1", ".", "+"],
... Fasta(str(TestConfig.test_fasta))) ... dic_seq)
100.0 100.0
>>> get_gc_content(["chr1", 10, 20, "s1", ".", "+"], >>> get_gc_content(["chr1", 10, 20, "s1", ".", "+"],
... Fasta(str(TestConfig.test_fasta))) ... dic_seq)
50.0 50.0
>>> get_gc_content(["chr1", 20, 30, "s1", ".", "+"], >>> get_gc_content(["chr1", 20, 30, "s1", ".", "+"],
... Fasta(str(TestConfig.test_fasta))) ... dic_seq)
0.0 0.0
>>> get_gc_content(["chr1", 0, 10, "s1", ".", "-"], >>> get_gc_content(["chr1", 0, 10, "s1", ".", "-"],
... Fasta(str(TestConfig.test_fasta))) ... dic_seq)
100.0 100.0
>>> get_gc_content(["chr1", 10, 20, "s1", ".", "-"], >>> get_gc_content(["chr1", 10, 20, "s1", ".", "-"],
... Fasta(str(TestConfig.test_fasta))) ... dic_seq)
50.0 50.0
>>> get_gc_content(["chr1", 20, 30, "s1", ".", "-"], >>> get_gc_content(["chr1", 20, 30, "s1", ".", "-"],
... Fasta(str(TestConfig.test_fasta))) ... dic_seq)
0.0 0.0
>>> dic_seq.close()
""" """
seq = str(dic_seq[bed_line[0]][bed_line[1]:bed_line[2]]).upper() seq = str(dic_seq[bed_line[0]][bed_line[1]:bed_line[2]]).upper()
if "N" in seq: if "N" in seq:
...@@ -69,15 +71,17 @@ def get_many_gc_content(bed_line: List[Any], dic_seq: Fasta, ...@@ -69,15 +71,17 @@ def get_many_gc_content(bed_line: List[Any], dic_seq: Fasta,
:return: A dictionary containing the GC content inside the interval \ :return: A dictionary containing the GC content inside the interval \
we want to get and around it. we want to get and around it.
>>> dic_seq = Fasta(str(TestConfig.test_fasta))
>>> get_many_gc_content(["chr1", 10, 20, "s1", ".", "+"], >>> get_many_gc_content(["chr1", 10, 20, "s1", ".", "+"],
... Fasta(str(TestConfig.test_fasta)), 0) ... dic_seq, 0)
{'interval': 50.0} {'interval': 50.0}
>>> get_many_gc_content(["chr1", 10, 20, "s1", ".", "+"], >>> get_many_gc_content(["chr1", 10, 20, "s1", ".", "+"],
... Fasta(str(TestConfig.test_fasta)), 10) ... dic_seq, 10)
{'before': 100.0, 'interval': 50.0, 'after': 0.0} {'before': 100.0, 'interval': 50.0, 'after': 0.0}
>>> get_many_gc_content(["chr1", 10, 20, "s1", ".", "-"], >>> get_many_gc_content(["chr1", 10, 20, "s1", ".", "-"],
... Fasta(str(TestConfig.test_fasta)), 10) ... dic_seq, 10)
{'before': 0.0, 'interval': 50.0, 'after': 100.0} {'before': 0.0, 'interval': 50.0, 'after': 100.0}
>>> dic_seq.close()
""" """
gc_interval = get_gc_content(bed_line, dic_seq) gc_interval = get_gc_content(bed_line, dic_seq)
if environment == 0: if environment == 0:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment