I have this equation for reverse complementing DNA in python:
def complement(s):
basecomplement = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'}
letters = list(s)
letters = [basecomplement[base] for base in letters]
return ''.join(letters)
def revcom(s):
complement(s[::-1])
print("ACGTAAA")
print(complement("ACGTAAA"[::-1]))
print(revcom("ACGTAAA"))
however the lines:
print(complement("ACGTAAA"[::-1]))
print(revcom("ACGTAAA"))
do not equal one another. only the top line gives an answer. the bottom just prints "NONE"
any help why this is?
Reverse Complement converts a DNA sequence into its reverse, complement, or reverse-complement counterpart. The entire IUPAC DNA alphabet is supported, and the case of each input sequence character is maintained. You may want to work with the reverse-complement of a sequence if it contains an ORF on the reverse strand.
Reverse/Complement. Often we need to obtain the complementary strand of a DNA sequence. As DNA is antiparallel, we really need the reverse complement sequence to keep our 5' and 3' ends properly oriented. While this is easy to do manually with short sequences, for longer sequences computer programs are easier.
The RNA goes in the reverse direction compared to the DNA, but its base pairs still match (e.g. G to C). The reverse complementary RNA for a positive strand DNA sequence will be identical to the corresponding negative strand DNA sequence.
You forgot the return
statement in revcom
. Try this:
def revcom(s):
return complement(s[::-1])
If you don't explicitly return a value from a function in Python, then the function returns None
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With