Skip to content

Commit

Permalink
ch15 WiP
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Bassi committed Mar 2, 2017
1 parent 64a2220 commit 44b2792
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
21 changes: 21 additions & 0 deletions code/ch15_1st/15_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from Bio import SeqIO

INPUT_FILE = '../../samples/fasta22.fas'
OUTPUT_FILE = 'fasta22_out.fas'

def retseq(seq_fh):
"""
Parse a fasta file and store non empty records
into the fullseqs list.
:seq_fh: File handle of the input sequence
:return: A list with non empty sequences
"""
fullseqs = []
for record in SeqIO.parse(seq_fh,'fasta'):
if len(record.seq)!=0:
fullseqs.append(record)
return fullseqs

with open(INPUT_FILE) as in_fh:
with open(OUTPUT_FILE, 'w') as out_fh:
SeqIO.write(retseq(in_fh), out_fh, 'fasta')
9 changes: 9 additions & 0 deletions code/ch15_1st/fasta22_out.fas
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
>SSR86 [ssr] : Tomato-EXPEN 2000 map, chr 3
AGGCCAGCCCCCTTTTCCCTTAAGAACTCTTTGTGAGCTTCCCGCGGTGGCGGCCGCTCT
AG
>SSR252 [ssr]
TGGGCAGAGGAGCTCGTANGCATACCGCGAATTGGGTACACTTACCTGGTACCCCACCCG
GGTGGAAAATCGATGGGCCCGCGGCCGCTCTAGAAGTACTCTCTCTCT
>SSR257 [ssr]
TGAGAATGAGCACATCGATACGGCAATTGGTACACTTACCTGCGACCCCACCCGGGTGGA
AAATCGATGGGCCCGCGGCC

0 comments on commit 44b2792

Please sign in to comment.