Assignment 0  -  Problem: sample.py  -  Student: jstringham


Check out what students see

Inline Comments:


Comment Generated Score: 
     


 
001
import sys, fasta
 
002
 
 
003
REGIONSIZE = 10000
 
004
BPLOOKFOR = 'GC'
 
005
 
 
006
# load the file
 
007
header, sequence = fasta.loadSingle(sys.argv[1])
 
008
 
 
009
def percentage(region, lookFor):
 
010
'''
 
011
calculates the percentage of the sequence made up of lookFor
 
012
'''
 
013
count = 0
 
014
 
 
015
# iterate over each letter in the sequence, incrementing count if
 
016
# it is in lookFor
 
017
for letter in region:
 
018
if letter in lookFor:
 
019
count += 1
 
020
 
 
021
# return the percentage of this region
 
022
return float(count)/len(region)
 
023
 
 
024
# compute the number of regions
 
025
regions = (len(sequence)/REGIONSIZE) + 1
 
026
 
 
027
regionList = []
 
028
 
 
029
# for each region, get the sequence cooresponding to this region, and
 
030
# print the result
 
031
for x in range(regions):
 
032
currentRegion = sequence[x * REGIONSIZE : (x + 1) * REGIONSIZE]
 
033
regionList.append(currentRegion)
 
034
print percentage(currentRegion, BPLOOKFOR)

Test results (copy and paste the tests and results)



Comment Generated Score: