INNER CODE UNIT · Python
read_fasta
cbg-ethz/V-pipe · workflow/scripts/alignmentIntervals.py:79
def read_fasta(fasta_file):
"Parse fasta file"
count = 0
headers = []
sequences = []
aux = []
with open(fasta_file, "r") as infile:
for line in infile:
record = line.rstrip()
if record and record[0] == ">":
headers.append(record[1:])
if count > 0:
sequences.append("".join(aux))
aux = []
else:
aux.append(record)
count += 1