Learning Scientific Programming with Python (2nd edition)
P2.3.1: GC-content of a nucleotide sequence
Question P2.3.1
(a) Given a string representing a base-pair sequence (i.e. containing only the letters A, G, C and T), determine the fraction of G and C bases in the sequence.
[Hint: strings have a count
method, returning the number of occurences of a substring]
(b) Using only string methods, devise a way to determine if a nucleotide sequence is a palindrome in the sense that it is equal to the its own complementary sequence read backwards. For example, the sequence TGGATCCA is palindromic because its complement is ACCTAGGT which is the same as the original sequence backwards. The complementary base pairs are (A, T) and (C, G).