reverse_complement on mutated sequence Biopython
1
Hi Biostars,
When I you use reverse_complement()
from Biopython to a mutated sequence made by SeqIO I get None
.
For example
rev_comp=record.seq.reverse_complement()
print rev_comp
Above code works well. But
sequence=record.seq.tomutable()
reverse_seq=sequence.reverse_complement()
print reverse_seq
prints "None"
How could I change this behaviour?
Thanks
biopython
reverse_complement
• 1.7k views
The method reverse_complement()
executed on mutable sequence, reverse the sequence in place and returns None
value, so you shouldn't assign it to a variable.
For example:
from Bio.Seq import Seq
seq = Seq("ACGTTGCAC")
mutseq = seq.tomutable()
mutseq.reverse_complement()
print(mutseq) # GTGCAACGT
If you want your reversed sequence to be assigned to a variable you can use reverse_complement()
function, instead of the method.
from Bio.Seq import Seq
from Bio.Seq import reverse_complement
seq = Seq("ACGTTGCAC")
mutseq = seq.tomutable()
reverse_seq = reverse_complement(mutseq)
print(reverse_seq) # GTGCAACGT
Login before adding your answer.
Traffic: 2742 users visited in the last hour
You're not actually "mutating" the sequence.