# Function for counting occurrences of T. def countT(seq): count = 0 for ch in seq: if ch=="T": count = count + 1 return count # count the occurrences of A def countA(seq): count = 0 for ch in seq: if ch=="A": count += 1 return count # count the occurrences of a given nucleotide def countN(seq, n): count = 0 for ch in seq: if ch==n: count += 1 return count #fast python way to do this def countNfast(seq, n): return seq.count(n) # Return the reverse complement of a nucleotide sequence. def revComp(seq): compDict = {'A' : 'T', 'T' : 'A', 'C' : 'G', 'G' : 'C'} complement = "" for nuc in seq: cmp = compDict[nuc] complement = complement + cmp return complement[::-1] # even better way to get the reverse complement def revComp2(seq): compDict = {'A' : 'T', 'T' : 'A', 'C' : 'G', 'G' : 'C'} complement = "" for nuc in seq: cmp = compDict[nuc] complement = cmp + complement return complement