from Bio.Seq import UnknownSeq from Bio.Alphabet import IUPAC unk = UnknownSeq(20, alphabet=IUPAC.ambiguous_dna) unk.complement() unk.reverse_complement() unk_rna = unk.transcribe() print(unk_rna) unk_protein = unk.translate() print(unk_protein)
mutSeq.reverse() # reverse() and reverse_complement() change object itself print mutSeq #MutableSeq can't be a dictionary key, Seq and string can #UnknownSeq # Subclass of Seq when you know length but not the characters to save memory from Bio.Seq import UnknownSeq unk = UnknownSeq(25) print unk, len(unk), type(unk) unkDNA = UnknownSeq(20, alphabet=IUPAC.ambiguous_dna) print unkDNA # N = any base unkProt = UnknownSeq(10, alphabet=IUPAC.protein) print unkProt # X = any aminoacid print unkDNA.complement(), unkDNA.reverse_complement() print unkDNA.transcribe(), unkDNA.translate() unkProt = unkDNA.translate() print unkProt, len(unkProt) #Directly on strings from Bio.Seq import reverse_complement, transcribe, back_transcribe, translate noseq = 'GCTGTTATGGGTCGTTGGAAGGGTGGTCGTGCTGCTGGTTAG' print reverse_complement(noseq) # these functions print transcribe(noseq) # receive either strings print back_transcribe(noseq) # Seq, MutableSeq, UnknownSeq print translate(noseq) #SeqRecord object #.seq A Seq object #.id a string ID identifier of the sequence #.name a string common name for the sequence