Python 1

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search



file = open("text1.txt")
DNA = file.readline()
RNA = ""
Reverse = ""

A = 0;
C = 0;
T = 0;
G = 0;
i = 0;

while i < len(DNA):
 if DNA[i] == 'A':
  A = A+1
  RNA = RNA + 'A'
  Reverse = 'T' + Reverse
 elif DNA[i] == 'C':
  C = C +1
  RNA = RNA + 'C'
  Reverse = 'G' + Reverse
 elif DNA[i] == 'T':
  T = T +1
  RNA = RNA + 'U'
  Reverse = 'A' + Reverse
 else:
  G = G +1
  RNA = RNA + 'G'
  Reverse = 'C' + Reverse
 i = i+1
print "Activity 1: ", A, C, T, G
print "Activity 2: ", RNA
print "Activity 3: ", Reverse