# complement_1.py # Author: Sami Khuri # Last updated: January 15, 2016 # Purpose: A function to construct the complement of a given DNA sequence # Program uses a function, a dictionary, for loop, string concatination # and a docstring: first line of function enclosed in """. def complement(s): """Return the complementary sequence string of s.""" basecomp = {'A': 'T', 'C': 'G', 'G': 'C', 'T': 'A'} seqcomp = "" for base in s: seqcomp = seqcomp + basecomp[base] return seqcomp dna_seq = 'CCGGAAGAGCTTACTTAG' print "DNA sequence:\t", dna_seq print "Its complement:\t", complement(dna_seq)