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)
Beispiel #2
0
            ]
        else:
            ssrcalc_low = ssrcalc - par.ssrcalc_window
            ssrcalc_high = ssrcalc + par.ssrcalc_window
            precursors = [
                p for p in allprecursors if p[2] != pep['peptide_key']
                and p[4] > ssrcalc_low and p[4] < ssrcalc_high
            ]
    elif not use_db:
        # Use the rangetree
        # correct rounding errors, s.t. we get the same results as before!
        # use the rangetree
        ssrcalc_low = ssrcalc - par.ssrcalc_window + 0.001
        ssrcalc_high = ssrcalc + par.ssrcalc_window - 0.001
        precursor_ids = tuple(
            c_rangetree.query_tree(q1_low, ssrcalc_low, q1_high, ssrcalc_high))
        precursors = [
            parentid_lookup[myid[0]] for myid in precursor_ids
            #dont select myself
            if parentid_lookup[myid[0]][2] != pep['peptide_key']
        ]
    #now calculate collisions in this area of the space
    colldensity = c_getnonuis.calculate_density(transitions, precursors,
                                                q3_low, q3_high, par.q3_window,
                                                par.ppm)
    assert MAX_UIS == 1
    nonuseable = len([c for c in colldensity if c > 0])
    prepare.append((nonuseable, nr_transitions, p_id, 1, exp_key))
    progressm.update(1)

cursor.executemany(
Beispiel #3
0
    collisions_per_peptide = computed_collisions 

    # see SRMCollider::Combinatorics::get_non_uis
    non_useable_combinations = c_getnonuis.get_non_uis( collisions_per_peptide, myorder)
    srm_ids = [t[1] for t in transitions]
    tuples_strike1 = 0
    if not nr_transitions < myorder:
      tuples_strike1 = collider.choose(nr_transitions, myorder ) - len(non_useable_combinations)

    ###############################################################
    #strike 2: it has to be locally clean
    if not skip_strike2:
      ssrcalc_low = ssrcalc - par.ssrcalc_window + 0.001
      ssrcalc_high = ssrcalc + par.ssrcalc_window - 0.001
      precursor_ids = tuple(c_rangetree.query_tree( q1_low, ssrcalc_low, 
                                                   q1_high,  ssrcalc_high )  )
      precursors = tuple([parentid_lookup[myid[0]] for myid in precursor_ids
                          #dont select myself 
                         if parentid_lookup[myid[0]][2]  != pep['transition_group']])

      # collisions_per_peptide: dictionary, for each key the set of interfering transitions is stored
      collisions_per_peptide = c_getnonuis.calculate_collisions_per_peptide_other_ion_series( 
          transitions, precursors, par, q3_low, q3_high, par.q3_window, par.ppm, forceChargeCheck)
      local_interferences = [t[0] for t in c_getnonuis.get_non_uis( collisions_per_peptide, 1).keys()]
      tuples_2strike = []
      for mytuple in tuples_strike1:
          contaminated = 0.0
          for dirty_t in local_interferences:
              if dirty_t in mytuple: contaminated += 1.0
          if contaminated <= contamination_allow: tuples_2strike.append(mytuple)