import sys, fasta
Table of Contents
| \This is a neutral comment. Isn't it a pretty day today? | 0.0 |
| \Look, I can reuse this one! | -45 |
| \This one has no points! | 0.0 |
| \Look, I can reuse this one! | -45 |
-45Look, I can reuse this one! - None
001
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
'''
-45Look, I can reuse this one! - None
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) 001
blah