From 70c8c0f8603f771cc43a9f27e862fd24c40f426c Mon Sep 17 00:00:00 2001
From: Fontrodona Nicolas <nicolas.fontrodona@ens-lyon.fr>
Date: Fri, 6 Nov 2020 15:14:54 +0100
Subject: [PATCH] src/gc_content/gc_content.py: fix tests

---
 src/gc_content/gc_content.py | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/gc_content/gc_content.py b/src/gc_content/gc_content.py
index 0ffe299..b34e871 100644
--- a/src/gc_content/gc_content.py
+++ b/src/gc_content/gc_content.py
@@ -29,24 +29,26 @@ def get_gc_content(bed_line: List[Any], dic_seq: Fasta) -> float:
     :param dic_seq: A dictionary containing chromosomal sequences
     :return: The gc content
 
+    >>> dic_seq = Fasta(str(TestConfig.test_fasta))
     >>> get_gc_content(["chr1", 0, 10, "s1", ".", "+"],
-    ... Fasta(str(TestConfig.test_fasta)))
+    ... dic_seq)
     100.0
     >>> get_gc_content(["chr1", 10, 20, "s1", ".", "+"],
-    ... Fasta(str(TestConfig.test_fasta)))
+    ... dic_seq)
     50.0
     >>> get_gc_content(["chr1", 20, 30, "s1", ".", "+"],
-    ... Fasta(str(TestConfig.test_fasta)))
+    ... dic_seq)
     0.0
     >>> get_gc_content(["chr1", 0, 10, "s1", ".", "-"],
-    ... Fasta(str(TestConfig.test_fasta)))
+    ... dic_seq)
     100.0
     >>> get_gc_content(["chr1", 10, 20, "s1", ".", "-"],
-    ... Fasta(str(TestConfig.test_fasta)))
+    ... dic_seq)
     50.0
     >>> get_gc_content(["chr1", 20, 30, "s1", ".", "-"],
-    ... Fasta(str(TestConfig.test_fasta)))
+    ... dic_seq)
     0.0
+    >>> dic_seq.close()
     """
     seq = str(dic_seq[bed_line[0]][bed_line[1]:bed_line[2]]).upper()
     if "N" in seq:
@@ -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 \
     we want to get and around it.
 
+    >>> dic_seq = Fasta(str(TestConfig.test_fasta))
     >>> get_many_gc_content(["chr1", 10, 20, "s1", ".", "+"],
-    ... Fasta(str(TestConfig.test_fasta)), 0)
+    ... dic_seq, 0)
     {'interval': 50.0}
     >>> 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}
     >>> 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}
+    >>> dic_seq.close()
     """
     gc_interval = get_gc_content(bed_line, dic_seq)
     if environment == 0:
-- 
GitLab