#NEWLINE# def test_fastx( filepath ) : #NEWLINE# #INDENT# with open ( filepath , encoding = 'latin-1' ) as fastx_file : #NEWLINE# #INDENT# sequences = OrderedDict ( ) #NEWLINE# seq = [ ] #NEWLINE# header = '' #NEWLINE# found_caret = False #NEWLINE# for ( row_index , row ) in enumerate ( fastx_file , 1 ) : #NEWLINE# #INDENT# if ( row_index > 30 ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# if ( not row . strip ( ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( found_caret is False ) and ( row [ 0 ] != '>' ) ) : #NEWLINE# #INDENT# if ( row [ 0 ] == ';' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# break #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( found_caret is False ) and ( row [ 0 ] == '>' ) ) : #NEWLINE# #INDENT# found_caret = True #NEWLINE# #UNINDENT# #UNINDENT# if ( row and ( rows [ 0 ] == '>' ) ) : #NEWLINE# #INDENT# if seq : #NEWLINE# #INDENT# sequences [ header ] = '' . join ( seq ) #NEWLINE# seq = [ ] #NEWLINE# #UNINDENT# header = row #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if row : #NEWLINE# #INDENT# seq . append ( row ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( seq and header ) : #NEWLINE# #INDENT# sequences [ header ] = '' . join ( seq ) #NEWLINE# #UNINDENT# if sequences : #NEWLINE# #INDENT# rows = [ ] #NEWLINE# [ rows . extend ( [ i , v ] ) for ( i , v ) in six . iteritems ( sequences ) ] #NEWLINE# return ( True , rows ) #NEWLINE# #UNINDENT# #UNINDENT# return ( False , None )