Skip to content
Snippets Groups Projects

Function to read in FASTA files and returns a dictionary new file: read_sequencer_package/read_in_FASTA.py

Merged Michael Sandholzer requested to merge read_sequencer into main
1 file
+ 26
0
Compare changes
  • Side-by-side
  • Inline
+ 26
0
'''
This function reads in FASTA files
argument is file_path
it returns a dictionary with the sequences
'''
import sys
def read_in_fasta(file_path):
sequences = {}
f = open(file_path)
for line in f:
if line[0] == '>':
defline = line.srtip()
defline = defline.replace('>', '')
else:
if defline not in sequences:
sequences[defline] = ''
sequences[defline] += line.strip()
return sequences
Loading