def test_rangetree(self): c_rangetree.create_tree( self.mytuple1 ) #we get our peptide out again with a large window res = c_rangetree.query_tree( self.q1 - 1, self.ssrcalc -1, self.q1 + 1, self.ssrcalc + 1, 1, 0) self.assertEqual( len(res), 1) self.assertEqual( res[0][0], 101) #same result when lower boundary equals the value res = c_rangetree.query_tree( self.q1 , self.ssrcalc , self.q1 + 1, self.ssrcalc + 1, 1, 0) self.assertEqual( len(res), 1) self.assertEqual( res[0][0], 101) #no result when upper boundary equals the value res = c_rangetree.query_tree( self.q1 - 1, self.ssrcalc -1, self.q1, self.ssrcalc, 1, 0) self.assertEqual( len(res), 0)
'peptide_key': r[1], 'parent_id': r[2], 'q1_charge': r[3], 'q1': r[4], 'ssrcalc': r[5], } for r in alltuples if r[3] == 2 #charge is 2 and r[6] == 0 #isotope is 0 and r[4] >= min_q1 and r[4] < max_q1 ] # we use a rangetree to select the precursors if not use_db: parentid_lookup = [[r[2], (r[4], r[0], r[1])] for r in alltuples] parentid_lookup = dict(parentid_lookup) print "building tree with %s Nodes" % len(alltuples) c_rangetree.create_tree(tuple(alltuples)) # in SWATH mode, select all precursors that are relevant for the background at # once if swath_mode: values = "q1, modified_sequence, peptide_key, q1_charge, ssrcalc" q1_low = min_q1 q1_high = max_q1 query2 = """ select %(values)s from %(pep)s where q1 >= %(q1_low)s and q1 <= %(q1_high)s %(query_add)s """ % { 'q1_high': q1_high, 'q1_low': q1_low,
'ssrcalc' : r[5], } for r in alltuples if r[3] == 2 #charge is 2 and r[6] == 0 #isotope is 0 and r[4] >= min_q1 and r[4] < max_q1 ] # we use a rangetree to select the precursors if not use_db: parentid_lookup = [ [ r[2], (r[4], r[0], r[1]) ] for r in alltuples ] parentid_lookup = dict(parentid_lookup) print "building tree with %s Nodes" % len(alltuples) c_rangetree.create_tree(tuple(alltuples)) # in SWATH mode, select all precursors that are relevant for the background at # once if swath_mode: values="q1, modified_sequence, peptide_key, q1_charge, ssrcalc" q1_low = min_q1; q1_high = max_q1 query2 = """ select %(values)s from %(pep)s where q1 >= %(q1_low)s and q1 <= %(q1_high)s %(query_add)s """ % { 'q1_high' : q1_high, 'q1_low' : q1_low, 'query_add' : par.query2_add,