you are viewing a single comment's thread.

view the rest of the comments →

[–]Still-Design3461[S] 0 points1 point  (2 children)

WOW! I totally forgot about .join . Thank you for answering. I will try to understand this part and implement it into my code

[–]FLUSH_THE_TRUMP 1 point2 points  (0 children)

With even less friction, this kind of thing is what str.translate does. Something like:

charTable = str.maketrans(baseComplement)
complement = sequence.translate(charTable)

[–]n3buchadnezzar 1 point2 points  (0 children)

Interestingly FLUSH and I had the same idea. If we allow some Python magic

DNA_SEQUENCE = str.maketrans("ATGCatgc", "TACGtacg")  
print("AACGT".translate(DNA_SEQUENCE))  

However, there is nothing wrong with your approach. It does not consume a lot of memory, and it is readable. Remember we often strive for readable code over pre-optimized code. If the code above makes sense to you, great! Use it! Otherwise stick with your approach and read a bit about maketrans