Pick an (ungapped) alphabet for an alignment consesus sequence.
This just looks at the sequences we have, checks their type, and
returns as appropriate type which seems to make sense with the
sequences we've got.

00171 :
"""Pick an (ungapped) alphabet for an alignment consesus sequence. This just looks at the sequences we have, checks their type, and returns as appropriate type which seems to make sense with the sequences we've got. """#Start with the (un-gapped version of) the alignment alphabet
a = Alphabet._get_base_alphabet(self.alignment._alphabet)
#Now check its compatible with all the rest of the sequencesfor record in self.alignment :
#Get the (un-gapped version of) the sequence's alphabet
alt = Alphabet._get_base_alphabet(record.seq.alphabet)
ifnot isinstance(alt, a.__class__) :
raise ValueError \
("Alignment contains a sequence with an incompatible alphabet.")
#Check the ambiguous character we are going to use in the consensus#is in the alphabet's list of valid letters (if defined).if hasattr(a, "letters") and a.letters isnotNone \
and ambiguous notin a.letters :
#We'll need to pick a more generic alphabet...if isinstance(a, IUPAC.IUPACUnambiguousDNA) :
if ambiguous in IUPAC.IUPACUnambiguousDNA().letters :
a = IUPAC.IUPACUnambiguousDNA()
else :
a = Alphabet.generic_dna
elif isinstance(a, IUPAC.IUPACUnambiguousRNA) :
if ambiguous in IUPAC.IUPACUnambiguousRNA().letters :
a = IUPAC.IUPACUnambiguousRNA()
else :
a = Alphabet.generic_rna
elif isinstance(a, IUPAC.IUPACProtein) :
if ambiguous in IUPAC.ExtendedIUPACProtein().letters :
a = IUPAC.ExtendedIUPACProtein()
else :
a = Alphabet.generic_protein
else :
a = Alphabet.single_letter_alphabet
return a
def replacement_dictionary(self, skip_chars = []):