def seq1(seq, custom_map=None, undef_code='X'):
 if (custom_map is None):
  custom_map = {'Ter': '*'}
 onecode = dict(((k.upper(), v) for (k, v) in IUPACData.protein_letters_3to1_extended.items()))
 onecode.update(((k.upper(), v) for (k, v) in custom_map.items()))
 seqlist = [seq[(3 * i):(3 * (i + 1))] for i in range((len(seq) // 3))]
 return ''.join((onecode.get(aa.upper(), undef_code) for aa in seqlist))

def seq1 ( seq , custom_map = None , undef_code = 'X' ) : if ( custom_map is None ) : custom_map = { 'Ter' : '*' } onecode = dict ( ( ( k . upper ( ) , v ) for ( k , v ) in IUPACData . protein_letters_3to1_extended . items ( ) ) ) onecode . update ( ( ( k . upper ( ) , v ) for ( k , v ) in custom_map . items ( ) ) ) seqlist = [ seq [ ( 3 * i ) : ( 3 * ( i + 1 ) ) ] for i in range ( ( len ( seq ) // 3 ) ) ] return '' . join ( ( onecode . get ( aa . upper ( ) , undef_code ) for aa in seqlist ) )
turns a three-letter code protein sequence into one with single letter codes .