Clean up when we've finished the record.
00934 : """Clean up when we've finished the record. """ from Bio import Alphabet from Bio.Alphabet import IUPAC from Bio.Seq import Seq # add the last feature in the table which hasn't been added yet self._add_feature() # add the sequence information # first, determine the alphabet # we default to an generic alphabet if we don't have a # seq type or have strange sequence information. seq_alphabet = Alphabet.generic_alphabet if self._seq_type: # mRNA is really also DNA, since it is actually cDNA if self._seq_type.find('DNA') != -1 or \ self._seq_type.find('mRNA') != -1: seq_alphabet = IUPAC.ambiguous_dna # are there every really RNA sequences in GenBank? elif self._seq_type.find('RNA') != -1: seq_alphabet = IUPAC.ambiguous_rna elif self._seq_type == "PROTEIN": seq_alphabet = IUPAC.protein # or extended protein? # work around ugly GenBank records which have circular or # linear but no indication of sequence type elif self._seq_type in ["circular", "linear"]: pass # we have a bug if we get here else: raise ValueError("Could not determine alphabet for seq_type %s" % self._seq_type) # now set the sequence sequence = "".join(self._seq_data) self.data.seq = Seq(sequence, seq_alphabet) class _RecordConsumer(_BaseGenBankConsumer):