when p_value is assigned to 0.01, the "if" statement near the bottom of the program acknowledges it and the program only prints the results with a p_value of < 0.01.
when p_value is assigned to form['pvalue_number'].value, which is equal to 0.01 (verified by print), it's as if the "for" loop completely ignores the "if" statement.
i've done a lot of debugging and concluded that the if clause does not evaluate to false and the for loop runs the code without exiting. all relevant variables have been verified by printing them.
lengthy irrelevant parts of the program have been cut out to improve readability.
Code:
from rpy import *
import MySQLdb, cgi
import cgitb; cgitb.enable()
print "Content-Type: text/html\n\n"
print "<pre>"
form = cgi.FieldStorage()
exp_date = form['exp_date'].value
p_value = 0.01
#p_value = form['pvalue_number'].value
print form['pvalue_number'].value
general_conditions = # ... snip
conditions = # ... snip
fields = # ... snip
query = 'SELECT %s FROM `%s_allGels` LEFT JOIN `%s_statistics` \nUSING ( NUMBER )
%s \nGROUP BY `ctrl4 ID`'
db=MySQLdb.connect(host="localhost", user="xxxx", passwd="xxxx",
db="2d-gels")
cursor=db.cursor()
def analysis(n):
cursor.execute(query % (fields, exp_date, exp_date, conditions[n]))
data=cursor.fetchall()
pvalues = []
for dataslice in data:
fullstats = r.t_test(dataslice[0:4],dataslice[4:8])
pvalues.extend([[fullstats['p.value'], dataslice[8], dataslice[9], dataslice[10],
dataslice[11], dataslice[12], dataslice[13]]])
pvalues.sort()
for value in pvalues:
if value[0] < p_value:
print "%5d" % value[1], " %8f" % float(value[0]), " %5.3f" %
value[2], " %5.2f" % value[3], " %5.3f" % value[4], " %5.2f" % value[5], " %6.3f" %
value[6]
else:
print "failed"
analysis(1)
analysis(2)
i'd appreciate any suggestions. i'm at a dead end here.