Help me?
Scroll to the bottom for the question.
Okay, so, see that shit in bold at the very end of this program? I'm having an issue. The program runs fine, but what I'm trying to say at the end there is that if the stdev is too high, that the entire big loop should start again at "for i in range(number_range)" (in bold up top), but increment the number_range by 10. But I can't make it loop through. Help me?!
*I realize there's probably some fancy schmancy way of figuring out the stdev shit that I don't know, but I just learned Python yesterday and what I have is fine for my purposes.
Scroll to the bottom for the question.
rad_sq = {"C": 3.24, "N": 1.96, "O": 2.56, "S": 3.24, "H": 1.0}
pos_volume = 0
volume_list = []
number_range = 10
for i in range(number_range):
for j in range(999):
randomX = uniform(xmin,xmax) # uses above defined min and max coordinate values to
randomY = uniform(ymin,ymax) # generate a random point within the box
randomZ = uniform(zmin,zmax)
randpoint = (randomX, randomY, randomZ)
for k in range(natom):
a = coords[k][0] - randomX # measures distance between random point and each
b = coords[k][1] - randomY # atom's coordinates
c = coords[k][2] - randomZ
dist_sq = (a*a + b*b + c*c)
if dist_sq <= rad_sq[atomtype[i]]: # if the distance between the random point and
pos_volume += 1 # an atomic coordinate is within van der waahls
# radii, the point is inside of the protein
box_volume = (xmax - xmin) * (ymax - ymin) * (zmax-zmin)
box_fraction = pos_volume / 1000. # calculates the percentage of points inside protein
molec_vol = (box_fraction) * box_volume # calculates protein volume based on percentage
volume_list.append(molec_vol)
def mean(volume_list): # defines mean of generated protein volume list
length = len(volume_list)
sum = 0
for i in range(length):
sum = sum + volume_list[i]
mean_value = sum / length
return mean_value
mean_value = mean(volume_list)
def stdev(volume_list, meanval = None): # defines std dev of generated protein volume list
if meanval == None: meanval = mean_value
return sqrt(sum([(m - meanval)**2 for m in volume_list]) / (len(volume_list)-1))
if stdev(volume_list) < 100: # if a reasonable std dev obtained, prints averaged volume answer
print "Your volume is: ",mean(volume_list)
print "Your standard deviation for this calculation is: ",stdev(volume_list)
else: # if std dev too high, increments the number of times through
number_range += 10 # loop by 10 and tries again
Okay, so, see that shit in bold at the very end of this program? I'm having an issue. The program runs fine, but what I'm trying to say at the end there is that if the stdev is too high, that the entire big loop should start again at "for i in range(number_range)" (in bold up top), but increment the number_range by 10. But I can't make it loop through. Help me?!
*I realize there's probably some fancy schmancy way of figuring out the stdev shit that I don't know, but I just learned Python yesterday and what I have is fine for my purposes.
