#NEWLINE# def regex2iupac( pattern ) : #NEWLINE# #INDENT# 'convert regex to iupac pattern' #NEWLINE# def _split( p ) : #NEWLINE# #INDENT# g = p . split ( '[' ) #NEWLINE# for c in g [ 0 ] : #NEWLINE# #INDENT# ( yield c ) #NEWLINE# #UNINDENT# for x in g [ 1 : ] : #NEWLINE# #INDENT# ( a , b ) = x . split ( ']' ) #NEWLINE# ( yield '' . join ( sorted ( a ) ) ) #NEWLINE# for c in b : #NEWLINE# #INDENT# ( yield c ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# a = [ ] #NEWLINE# for x in _split ( x ) : #NEWLINE# #INDENT# a . append ( regexdict [ x ] ) #NEWLINE# #UNINDENT# return '' . join ( a )