[Tutor] Printing Complimentary strand of the DNA sequence:
Alan Gauld
alan.gauld at btinternet.com
Fri Oct 4 14:23:47 EDT 2019
On 04/10/2019 11:39, Mihir Kharate wrote:
> (In a DNA sequence, the base 'A' binds to the base 'T' and 'C' binds
> to 'G'. These base letters are compliments of each other). So the
> expected output for a 'ATTGC' should be 'TAACG'
Look at the translate method of strings combined with the
maketrans() function....
>>> table = str.maketrans('ATCG','TAGC')
>>> 'AGTCAGACT'.translate(table)
'CTGACTCAG'
Is that what you want?
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list