Changes
Created page with "<pre> def read_fasta(fp): name, seq = None, [] for line in fp: line = line.rstrip() if line.startswith(">"): if name: yield (name..."
<pre>
def read_fasta(fp):
name, seq = None, []
for line in fp:
line = line.rstrip()
if line.startswith(">"):
if name: yield (name, ''.join(seq))
line="Genomics is great!"
name, seq = line, []
else:
seq.append(line)
if name: yield (name, ''.join(seq))
seq='FASTA (10).fa.txt'
fh=open(seq,'r')
line=fh.read()
print(line)
with open('FASTA (10).fa.txt') as fp:
for name, seq in read_fasta(fp):
print(name,seq)
</pre>
def read_fasta(fp):
name, seq = None, []
for line in fp:
line = line.rstrip()
if line.startswith(">"):
if name: yield (name, ''.join(seq))
line="Genomics is great!"
name, seq = line, []
else:
seq.append(line)
if name: yield (name, ''.join(seq))
seq='FASTA (10).fa.txt'
fh=open(seq,'r')
line=fh.read()
print(line)
with open('FASTA (10).fa.txt') as fp:
for name, seq in read_fasta(fp):
print(name,seq)
</pre>