예제 #1
0
def find_clashes_small(self, mycollider, cursor, par, pepids):
        swath_mode = False
        mycollider.allpeps = {}
        mycollider.non_unique_count = 0
        mycollider.total_count = 0
        MAX_UIS = 5
        for kk, pep in enumerate(pepids):
            precursor = Precursor(parent_id=pep['parent_id'], q1=pep['q1'], 
                ssrcalc=pep['ssrcalc'], modified_sequence = pep['mod_sequence'], 
                transition_group = pep['transition_group'])

            q3_low, q3_high = par.get_q3range_transitions()
            transitions = precursor.calculate_transitions(q3_low, q3_high)
            nr_transitions = len(transitions)

            ### if use_db and not swath_mode:
            precursors = mycollider._get_all_precursors(par, precursor, cursor)
            collisions_per_peptide = collider.get_coll_per_peptide_from_precursors(mycollider,
                    transitions, precursors, par, precursor, forceNonCpp=False)
            collisions_per_peptide_python = collider.get_coll_per_peptide_from_precursors_obj_wrapper(mycollider,
                    transitions, precursors, par, precursor, forceNonCpp=True)
            self.assertEqual(collisions_per_peptide, collisions_per_peptide_python)
            non_uis_list = collider.get_nonuis_list(collisions_per_peptide, MAX_UIS)
            # 
            # here we count how many are locally clean, e.g. look at UIS of order 1
            mycollider.allpeps[precursor.parent_id] = 1.0 - len(non_uis_list[1]) * 1.0  / nr_transitions
            mycollider.non_unique_count += len(non_uis_list[1])
            mycollider.total_count += nr_transitions
예제 #2
0
  def test_runuis_nonswath_rangetree(self):
    self.assertEqual(len(self.precursors_to_evaluate), 905)
    par = self.par
    cursor = self.db.cursor()

    # If we dont use the DB, we use the rangetree to query and get our list of
    # precursors that are interfering. In SWATH we dont include a +/- q1_window
    # around our range or precursors because the precursor window is fixed to
    # (min_q1,max_q1) and no other precursors are considered.
    self.myprecursors.getFromDB(par, cursor, self.min_q1 - par.q1_window, self.max_q1 + par.q1_window)
    rtree = self.myprecursors.build_rangetree()

    prepare = []

    for precursor in self.precursors_to_evaluate:

      q3_low, q3_high = par.get_q3range_transitions()
      transitions = precursor.calculate_transitions(q3_low, q3_high)
      nr_transitions = len(transitions)

      # Use the rangetree, whether it is swath or not
      collisions_per_peptide = self.myprecursors.get_collisions_per_peptide_from_rangetree(precursor, precursor.q1 - par.q1_window, precursor.q1 + par.q1_window, transitions, par, rtree)
      non_uis_list = collider.get_nonuis_list(collisions_per_peptide, par.max_uis)

      for order in range(1,min(par.max_uis+1, nr_transitions+1)): 
        prepare.append( (len(non_uis_list[order]), collider.choose(nr_transitions, 
          order), precursor.parent_id , order, -1) )

    self.assertEqual(len(prepare), 905*par.max_uis)
    self.assertEqual(prepare[0], (0, 17.0, 1, 1, -1)) 
    final_report = self.get_final_report(par, prepare)
    self.check_final_report_nonswath(final_report)
예제 #3
0
  def test_runuis_nonswath(self):
    self.assertEqual(len(self.precursors_to_evaluate), 905)
    par = self.par
    cursor = self.db.cursor()
    prepare = []

    for precursor in self.precursors_to_evaluate:

      q3_low, q3_high = par.get_q3range_transitions()
      transitions = precursor.calculate_transitions(q3_low, q3_high)
      nr_transitions = len(transitions)

      precursors_obj = self.acollider._get_all_precursors(par, precursor, cursor)
      collisions_per_peptide = collider.get_coll_per_peptide_from_precursors(self.acollider, 
                transitions, precursors_obj, par, precursor)
      non_uis_list = collider.get_nonuis_list(collisions_per_peptide, par.max_uis)

      for order in range(1,min(par.max_uis+1, nr_transitions+1)): 
        prepare.append( (len(non_uis_list[order]), collider.choose(nr_transitions, 
          order), precursor.parent_id , order, -1) )

    self.assertEqual(len(prepare), 905*par.max_uis)
    self.assertEqual(prepare[0], (0, 17.0, 1, 1, -1)) 

    final_report = self.get_final_report(par, prepare)
    self.check_final_report_nonswath(final_report)
예제 #4
0
  def test_runuis_swath(self):
    self.assertEqual(len(self.precursors_to_evaluate), 905)
    swath_mode = False
    par = self.par
    R = self.R
    cursor = self.db.cursor()
    prepare = []

    self.min_q1 = 500
    self.max_q1 = 525

    # Get the precursors (now for 500-525 instead of the full range)
    ###########################################################################
    myprecursors = Precursors()
    cursor = self.db.cursor()
    myprecursors.getFromDB(par, cursor, self.min_q1 - par.q1_window, self.max_q1 + par.q1_window)
    rtree = myprecursors.build_rangetree()
    self.precursors_to_evaluate = myprecursors.getPrecursorsToEvaluate(self.min_q1, self.max_q1)
    self.assertEqual(len(self.precursors_to_evaluate), 39)

    isotope_correction = par.isotopes_up_to * R.mass_diffC13 / min(par.parent_charges)
    temp_precursors = Precursors()
    temp_precursors.getFromDB(par, self.db.cursor(), self.min_q1 - isotope_correction, self.max_q1)
    all_swath_precursors = []
    for p in temp_precursors.precursors:
      if(p.included_in_isotopic_range(self.min_q1, self.max_q1, par) ): 
        all_swath_precursors.append(p)

    for precursor in self.precursors_to_evaluate:

      q3_low, q3_high = par.get_q3range_transitions()
      transitions = precursor.calculate_transitions(q3_low, q3_high)
      nr_transitions = len(transitions)


      if par.ssrcalc_window > 1000:
          precursors_obj = [p for p in all_swath_precursors if p.transition_group != precursor.transition_group]
      else:
          ssrcalc_low =  precursor.ssrcalc - par.ssrcalc_window 
          ssrcalc_high = precursor.ssrcalc + par.ssrcalc_window 
          precursors_obj = [p for p in all_swath_precursors if p.transition_group != precursor.transition_group
                       and p.ssrcalc > ssrcalc_low and p.ssrcalc < ssrcalc_high ]
      collisions_per_peptide = collider.get_coll_per_peptide_from_precursors(self.acollider, 
              transitions, precursors_obj, par, precursor)


      non_uis_list = collider.get_nonuis_list(collisions_per_peptide, par.max_uis)

      for order in range(1,min(par.max_uis+1, nr_transitions+1)): 
        prepare.append( (len(non_uis_list[order]), collider.choose(nr_transitions, 
          order), precursor.parent_id , order, -1) )

    self.assertEqual(len(prepare), 39*par.max_uis)
    self.assertEqual(prepare[0], (5, 8.0, 69, 1, -1) )

    final_report = self.get_final_report(par, prepare)
    self.check_final_report_swath(final_report)
예제 #5
0
def find_clashes_small(self, mycollider, cursor, par, pepids):
    swath_mode = False
    mycollider.allpeps = {}
    mycollider.non_unique_count = 0
    mycollider.total_count = 0
    MAX_UIS = 5
    for kk, pep in enumerate(pepids):
        precursor = Precursor(parent_id=pep['parent_id'],
                              q1=pep['q1'],
                              ssrcalc=pep['ssrcalc'],
                              modified_sequence=pep['mod_sequence'],
                              transition_group=pep['transition_group'])

        q3_low, q3_high = par.get_q3range_transitions()
        transitions = precursor.calculate_transitions(q3_low, q3_high)
        nr_transitions = len(transitions)

        ### if use_db and not swath_mode:
        precursors = mycollider._get_all_precursors(par, precursor, cursor)
        collisions_per_peptide = collider.get_coll_per_peptide_from_precursors(
            mycollider,
            transitions,
            precursors,
            par,
            precursor,
            forceNonCpp=False)
        collisions_per_peptide_python = collider.get_coll_per_peptide_from_precursors_obj_wrapper(
            mycollider,
            transitions,
            precursors,
            par,
            precursor,
            forceNonCpp=True)
        self.assertEqual(collisions_per_peptide, collisions_per_peptide_python)
        non_uis_list = collider.get_nonuis_list(collisions_per_peptide,
                                                MAX_UIS)
        #
        # here we count how many are locally clean, e.g. look at UIS of order 1
        mycollider.allpeps[precursor.parent_id] = 1.0 - len(
            non_uis_list[1]) * 1.0 / nr_transitions
        mycollider.non_unique_count += len(non_uis_list[1])
        mycollider.total_count += nr_transitions
예제 #6
0
            precursors_obj = [p for p in all_swath_precursors if p.transition_group != precursor.transition_group
                         and p.ssrcalc > ssrcalc_low and p.ssrcalc < ssrcalc_high ]
        collisions_per_peptide = collider.get_coll_per_peptide_from_precursors(mycollider, 
                transitions, precursors_obj, par, precursor)
    elif not use_db:
        if swath_mode:
        # Case 3: SRMCollider in SWATH mode, get transitions from the rangetree
          collisions_per_peptide = myprecursors.get_collisions_per_peptide_from_rangetree(
              precursor, min_q1, max_q1, transitions, par, rtree)
        else:
          # Case 4: regular SRMCollider, get transitions from the rangetree
          collisions_per_peptide = myprecursors.get_collisions_per_peptide_from_rangetree(
              precursor, precursor.q1 - par.q1_window, precursor.q1 + par.q1_window, 
              transitions, par, rtree)

    non_uis_list = collider.get_nonuis_list(collisions_per_peptide, MAX_UIS)
    ## 
    ## Lets count the number of peptides that interfere
    if count_avg_transitions:
        tr_arr = [0 for i in range(nr_transitions)]
        for v in collisions_per_peptide.values():
            for vv in v:
                tr_arr[vv] += 1
        allintertr.extend( tr_arr )
    ##
    #
    for order in range(1,min(MAX_UIS+1, nr_transitions+1)): 
        prepare.append( (len(non_uis_list[order]), collider.choose(nr_transitions, 
            order), precursor.parent_id , order, exp_key) )
    progressm.update(1)