The task is: Write a script (call it what you want) that that can analyze a fastafile (MySequences.fasta) by finding the reverse complement of the sequences. Using python.
from itertools import repeat
#opening file
filename = "MySequences.fasta"
file = open(filename, 'r')
#reading the file
for line in file:
line = line.strip()
if ">" in line:
header = line
elif (len(line) == 0):
continue
else:
seq = line
#reverse complement
def reverse_complement(seq):
compline = ''
for n in seq:
if n == 'A':
compline += 'T'
elif n == 'T':
compline += 'A'
elif n == 'C':
compline += 'G'
elif n == 'G':
compline += 'C'
return((compline)[::-1])
#run each line
for line in file:
rc = reverse_complement(seq)
print(rc)