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)
from Bio.Seq import MutableSeq from Bio.Alphabet import IUPAC mutable_seq = MutableSeq("GCCATTGTAATGGGCCGCTGAAAGGGTGCCCGA", IUPAC.unambiguous_dna) mutable_seq mutable_seq[5] = "C" mutable_seq mutable_seq.remove("T") mutable_seq mutable_seq.reverse() mutable_seq # UnknownSeq objects from Bio.Seq import UnknownSeq unk = UnknownSeq(20) unk print(unk) len(unk) from Bio.Seq import UnknownSeq from Bio.Alphabet import IUPAC unk_dna = UnknownSeq(20, alphabet=IUPAC.ambiguous_dna) unk_dna print(unk_dna) unk_protein = unk_dna.translate() unk_protein # Connecting with biological databases
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