#NEWLINE# def strip_fasta( fname , substr = '_' ) : #NEWLINE# #INDENT# good = False #NEWLINE# name = '' #NEWLINE# rmlist = [ ] #NEWLINE# def callback( ) : #NEWLINE# #INDENT# if good : #NEWLINE# #INDENT# return ( '%s (removed %s)' % ( name , len ( rmlist ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( '%s [x] (removed %s)' % ( name , len ( rmlist ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# for line in eta_open_iter ( fname , callback = callback ) : #NEWLINE# #INDENT# if ( line [ 0 ] == '>' ) : #NEWLINE# #INDENT# name = line [ 1 : ] . strip ( ) . split ( ' ' ) [ 0 ] #NEWLINE# if ( substr in name ) : #NEWLINE# #INDENT# good = False #NEWLINE# rmlist . append ( name ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# good = True #NEWLINE# #UNINDENT# #UNINDENT# if good : #NEWLINE# #INDENT# sys . stdout . write ( n ) #NEWLINE# #UNINDENT# #UNINDENT# sys . stderr . write ( 'Removed:\n' ) #NEWLINE# for n in rmlist : #NEWLINE# #INDENT# sys . stderr . write ( ( '%s\n' % n ) )