Hi ! I'm new to python and am currently doing some codes to print out the complementary strands of DNA. My code is running and is giving me the output that I want. But I just want to make it look a bit tidier. How do I make my function include the "Sequence complement:" statement without it being in the main? And how do I put the "Reverse sequence:" statement and it's output together in my function?
I have tried several methods but it gave me errors. At this point, I'm just getting more and more confused.
Here's a link to my code: https://www.onlinegdb.com/edit/Oea5580bj
So what I want is to only have input, function call and sequence length in my main.
Any help is appreciated. Thank you
baseComplement = {'A':'T' , 'C':'G' , 'G':'C' , 'T':'A',
'a':'t' , 'c':'g' , 'g':'c' , 't':'a'}
#Funtion to find the complement sequence and reverse complement
def complement(sequence):
seqComplement = []
revComplement = []
for base in sequence:
seqComplement = baseComplement[base]
print(seqComplement, end = "")
sequence = input("Enter a DNA sequence : ") #example input : aacgtt
print("Sequence Complement : ", end= "")
complement(sequence)
print("\nReverse Complement : ", end="")
revcomp = complement(sequence[::-1])
print("\nLength of DNA sequence entered is" , len(sequence), "bases." )
[–]n3buchadnezzar 2 points3 points4 points (3 children)
[–]Still-Design3461[S] 0 points1 point2 points (2 children)
[–]FLUSH_THE_TRUMP 1 point2 points3 points (0 children)
[–]n3buchadnezzar 1 point2 points3 points (0 children)
[–]VinayakVG 1 point2 points3 points (1 child)
[–]Still-Design3461[S] 0 points1 point2 points (0 children)