Guest User

Untitled

a guest
Dec 14th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.75 KB | None | 0 0
  1. #readFile.py                                                                    
  2. #This function takes a file name as input and                                  
  3. #reads the entire file and returns the resault as a single string              
  4. #! /usr/bin/env python                                                          
  5. def readFile(str):
  6.     file = open(str)
  7.     return file.read()
  8.  
  9. for i in range(1, 3):
  10.     myVar = readFile('lab1/Sequence' + str(i) + '.txt')
  11.     print 'C = ' + str(myVar.count('C'))
  12.     print 'G = ' + str(myVar.count('G'))
  13.     print 'T = ' + str(myVar.count('T'))
  14.     print 'Total = ' + str(len(myVar))
  15.     print 'C fraction = ' + str(float(myVar.count('C'))/len(myVar))
  16.     print 'G fraction = ' + str(float(myVar.count('G'))/len(myVar))
  17.     print '\n'
Add Comment
Please, Sign In to add comment