Skip to content
Snippets Groups Projects
Commit 958f7e41 authored by Kathleen Moriarty's avatar Kathleen Moriarty
Browse files

replace readline() to use file handle as iterator

parent 68d3e622
Branches
No related tags found
1 merge request!17Issue 7
......@@ -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']
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment