def test_get_non_uis2(self): print '\nTesting non_uis_list' pep = test_shared.runpep2 transitions = test_shared.runtransitions2 precursors = test_shared.runprecursors2 transitions = tuple([ (t[0], i) for i,t in enumerate(transitions)]) collisions_per_peptide, ctime = runcpp(self, pep, transitions, precursors) MAX_UIS = self.MAX_UIS non_uis_list = [set() for i in range(MAX_UIS+1)] #here we calculate the UIS for this peptide with the given RT-range st = time.time() for pepc in collisions_per_peptide.values(): for i in range(1,MAX_UIS+1): collider.get_non_uis(pepc, non_uis_list[i], i) oldtime = time.time() - st st = time.time() for kk in range(10): non_uis_list_new = [{} for i in range(MAX_UIS+1)] for order in range(1,MAX_UIS+1): non_uis_list_new[order] = c_getnonuis.get_non_uis( collisions_per_peptide, order) non_uis_list_new = [set( res.keys() ) for res in non_uis_list_new] ctime = (time.time() - st)/10 self.assertEqual(non_uis_list_new, non_uis_list) print ctime, oldtime print "Speedup:", oldtime / ctime
def test_get_non_uis(self): test = set() collider.get_non_uis( [1,2,3], test,2 ) self.assertEqual(test, set([(1, 2), (1, 3), (2, 3)]) ) test = set() collider.get_non_uis( [1,2,3,4], test,2 ) self.assertEqual(test, set([(1, 2), (1, 3), (1, 4), (2, 3), (3, 4), (2, 4)]))
def test_get_non_uis2(self): print '\nTesting non_uis_list' pep = test_shared.runpep2 transitions = test_shared.runtransitions2 precursors = test_shared.runprecursors2 transitions = tuple([(t[0], i) for i, t in enumerate(transitions)]) collisions_per_peptide, ctime = runcpp(self, pep, transitions, precursors) MAX_UIS = self.MAX_UIS non_uis_list = [set() for i in range(MAX_UIS + 1)] #here we calculate the UIS for this peptide with the given RT-range st = time.time() for pepc in collisions_per_peptide.values(): for i in range(1, MAX_UIS + 1): collider.get_non_uis(pepc, non_uis_list[i], i) oldtime = time.time() - st st = time.time() for kk in range(10): non_uis_list_new = [{} for i in range(MAX_UIS + 1)] for order in range(1, MAX_UIS + 1): non_uis_list_new[order] = c_getnonuis.get_non_uis( collisions_per_peptide, order) non_uis_list_new = [set(res.keys()) for res in non_uis_list_new] ctime = (time.time() - st) / 10 self.assertEqual(non_uis_list_new, non_uis_list) print ctime, oldtime print "Speedup:", oldtime / ctime
def get_non_UIS_from_transitions_old(transitions, collisions, par, MAX_UIS, unsorted=False): """ Get all combinations that are not UIS """ #collisions #q3, q1, srm_id, peptide_key #transitions #q3, srm_id collisions_per_peptide = {} non_uis_list = [set() for i in range(MAX_UIS+1)] q3_window_used = par.q3_window for t in transitions: if par.ppm: q3_window_used = par.q3_window * 10**(-6) * t[0] this_min = q3_window_used for c in collisions: if abs( t[0] - c[0] ) <= q3_window_used: #gets all collisions if collisions_per_peptide.has_key(c[3]): if not t[1] in collisions_per_peptide[c[3]]: collisions_per_peptide[c[3]].append( t[1] ) else: collisions_per_peptide[c[3]] = [ t[1] ] #here we calculate the UIS for this peptide with the given RT-range for pepc in collisions_per_peptide.values(): for i in range(1,MAX_UIS+1): collider.get_non_uis(pepc, non_uis_list[i], i) return non_uis_list