From 958f7e41e1c6f87e67d7836ec8025d07bda819c2 Mon Sep 17 00:00:00 2001
From: "kathleen.moriarty" <kathleen.moriarty@unibas.ch>
Date: Mon, 3 Jan 2022 12:20:19 +0100
Subject: [PATCH] replace readline() to use file handle as iterator

---
 src/read_sequencing.py | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/src/read_sequencing.py b/src/read_sequencing.py
index d6dfc47..a008f19 100644
--- a/src/read_sequencing.py
+++ b/src/read_sequencing.py
@@ -37,27 +37,27 @@ def read_sequencing(
     frag_desc = []  # type: List[str]
 
     with open(frag_file_name, 'r') as f:
-        frag_line = f.readline()
-        # Store all fragments as a list to parse later
-        frag_list = []  # type: List[str]
-        # Store combined fragment lines
-        frag_str = ""
-        while frag_line != "":
-            # To stop when the end of file is reached
-            if frag_line.startswith('>'):
-                # Determine if this is the first fragment in the file
-                # Ignore the description line (starting with >) of the first fragment
-                if not (len(frag_list) == 0 and frag_str == ""):
-                    # Not the first fragment. Append to list.
-                    frag_list.append(frag_str)
-                frag_str = ""
-                # Store description line for output file
-                frag_desc.append(frag_line)
-            else:
-                frag_str = frag_str + frag_line.rstrip("\n")
-            # Read next line
-            frag_line = f.readline()
-        frag_list.append(frag_str)
+        for frag_line in f:
+            # Store all fragments as a list to parse later
+            frag_list = []  # type: List[str]
+            # Store combined fragment lines
+            frag_str = ""
+            while frag_line != "":
+                # To stop when the end of file is reached
+                if frag_line.startswith('>'):
+                    # Determine if this is the first fragment in the file
+                    # Ignore the description line (starting with >) of the first fragment
+                    if not (len(frag_list) == 0 and frag_str == ""):
+                        # Not the first fragment. Append to list.
+                        frag_list.append(frag_str)
+                    frag_str = ""
+                    # Store description line for output file
+                    frag_desc.append(frag_line)
+                else:
+                    frag_str = frag_str + frag_line.rstrip("\n")
+                # Read next line
+                frag_line = f.readline()
+            frag_list.append(frag_str)
 
     # Store list of random nucleotides from which to sample when read length is too short
     nucleotides = ['A', 'C', 'G', 'T']
-- 
GitLab