diff --git a/src/read_sequencing.py b/src/read_sequencing.py index d6dfc472dd6855f2f4c70537f779777ac390d28c..a008f19a04652cd1579c9dcef756be02fc12b896 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']