def _consensus_alphabet(alphabets):
 base = _consensus_base_alphabet(alphabets)
 gap = None
 stop = None
 new_letters = ''
 for alpha in alphabets:
  if (not hasattr(alpha, 'gap_char')):
   pass
  elif (gap is None):
   gap = alpha.gap_char
  elif (gap == alpha.gap_char):
   pass
  else:
   raise ValueError('More than one gap character present')
  if (not hasattr(alpha, 'stop_symbol')):
   pass
  elif (stop is None):
   stop = alpha.stop_symbol
  elif (stop == alpha.stop_symbol):
   pass
  else:
   raise ValueError('More than one stop symbol present')
  if hasattr(alpha, 'new_letters'):
   for letter in alpha.new_letters:
    if ((letter not in new_letters) and (letter != gap) and (letter != stop)):
     new_letters += letter
 alpha = base
 if new_letters:
  alpha = AlphabetEncoder(alpha, new_letters)
 if gap:
  alpha = Gapped(alpha, gap_char=gap)
 if stop:
  alpha = HasStopCodon(alpha, stop_symbol=stop)
 return alpha

def _consensus_alphabet ( alphabets ) : base = _consensus_base_alphabet ( alphabets ) gap = None stop = None new_letters = '' for alpha in alphabets : if ( not hasattr ( alpha , 'gap_char' ) ) : pass elif ( gap is None ) : gap = alpha . gap_char elif ( gap == alpha . gap_char ) : pass else : raise ValueError ( 'More than one gap character present' ) if ( not hasattr ( alpha , 'stop_symbol' ) ) : pass elif ( stop is None ) : stop = alpha . stop_symbol elif ( stop == alpha . stop_symbol ) : pass else : raise ValueError ( 'More than one stop symbol present' ) if hasattr ( alpha , 'new_letters' ) : for letter in alpha . new_letters : if ( ( letter not in new_letters ) and ( letter != gap ) and ( letter != stop ) ) : new_letters += letter alpha = base if new_letters : alpha = AlphabetEncoder ( alpha , new_letters ) if gap : alpha = Gapped ( alpha , gap_char = gap ) if stop : alpha = HasStopCodon ( alpha , stop_symbol = stop ) return alpha
returns a common but often generic alphabet object .