def _get_all_precursors(self, par, precursor, cursor): precursors = [] R = Residues.Residues("mono") pep = precursor.to_old_pep() for res in self._get_all_precursors_sub(par, pep, cursor): p = Precursor() p.initialize(*res) if p.included_in_isotopic_range(precursor.q1 - par.q1_window, precursor.q1 + par.q1_window, par): precursors.append(p) return precursors
def _get_all_precursors(self, par, precursor, cursor): precursors = [] R = Residues.Residues('mono') pep = precursor.to_old_pep() for res in self._get_all_precursors_sub(par, pep, cursor): p = Precursor() p.initialize(*res) if (p.included_in_isotopic_range(precursor.q1 - par.q1_window, precursor.q1 + par.q1_window, par)): precursors.append(p) return precursors
def setUp(self): self.limit = 100 self.limit_large = 100 self.limit = 300 self.limit_large = 600 try: import MySQLdb #db_l = MySQLdb.connect(read_default_file="~/.my.cnf.local") db = MySQLdb.connect(read_default_file="~/.srm.cnf") cursor = db.cursor() self.cursor = cursor par = test_shared.get_default_setup_parameters() par.use_sqlite = True par.q1_window = 1.2 / 2.0 par.q3_window = 2.0 / 2.0 par.ssrcalc_window = 4 / 2.0 par.ssrcalc_window = 9999 / 2.0 par.peptide_tables = ['hroest.srmPeptides_yeast'] par.transition_table = 'hroest.srmTransitions_yeast' par.isotopes_up_to = 3 self.mycollider = collider.SRMcollider() par.select_by = "id" self.par = par self.min_q1 = 440 self.max_q1 = 450 ## For debugging ##self.max_q1 = 440.18 ##par.q1_window = 0.009 / 2.0 ##par.q3_window = 2.0 / 2.0 ##par.isotopes_up_to = 1 import Residues R = Residues.Residues('mono') isotope_correction = par.isotopes_up_to * R.mass_diffC13 / min(par.parent_charges) start = time.time() query = """ select modified_sequence, transition_group, parent_id, q1_charge, q1, ssrcalc, isotope_nr, 0, 0 from %s where q1 between %s and %s #and isotope_nr = 0 """ % (par.peptide_tables[0], self.min_q1 - par.q1_window, self.max_q1 + par.q1_window) cursor.execute(query) self.alltuples = list(cursor.fetchall() ) #print "len alltuples", len(self.alltuples) query = """ select modified_sequence, transition_group, parent_id, q1_charge, q1, ssrcalc, isotope_nr, 0, 0 from %s where q1 between %s - %s and %s and isotope_nr = 0 """ % (par.peptide_tables[0], self.min_q1 - par.q1_window, isotope_correction, self.max_q1 + par.q1_window) cursor.execute(query) self.alltuples_isotope_correction = list(cursor.fetchall()) #print "len alltuples zero", len(self.alltuples_isotope_correction) self.myprecursors = Precursors() # myprecursors.getFromDB(par, db.cursor(), self.min_q1 - par.q1_window, self.max_q1 + par.q1_window) ##### LEGACY getFromDB -- have isotope_nr = 0 in there! # Get all precursors from the DB within a window of Q1 lower_q1 = self.min_q1 - par.q1_window upper_q1 = self.max_q1 + par.q1_window self.myprecursors.precursors = [] isotope_correction = par.isotopes_up_to * R.mass_diffC13 / min(par.parent_charges) q = """ select modified_sequence, transition_group, parent_id, q1_charge, q1, ssrcalc, modifications, missed_cleavages, isotopically_modified from %(peptide_table)s where q1 between %(lowq1)s - %(isotope_correction)s and %(highq1)s and isotope_nr = 0 """ % {'peptide_table' : par.peptide_tables[0], 'lowq1' : lower_q1, # min_q1 - par.q1_window 'highq1' : upper_q1, # max_q1 + par.q1_window, 'isotope_correction' : isotope_correction } cursor.execute(q) for res in cursor.fetchall(): p = Precursor() p.initialize(*res) # Only include those precursors that are actually have isotopes in the specified range if(p.included_in_isotopic_range(lower_q1, upper_q1, par) ): self.myprecursors.precursors.append(p) ##### END LEGACY getFromDB self.precursors_to_evaluate = self.myprecursors.getPrecursorsToEvaluate(self.min_q1, self.max_q1) except Exception as inst: print "something went wrong" print inst
def setUp(self): self.limit = 100 self.limit_large = 100 self.limit = 300 self.limit_large = 600 try: import MySQLdb #db_l = MySQLdb.connect(read_default_file="~/.my.cnf.local") db = MySQLdb.connect(read_default_file="~/.srm.cnf") cursor = db.cursor() self.cursor = cursor par = test_shared.get_default_setup_parameters() par.use_sqlite = True par.q1_window = 1.2 / 2.0 par.q3_window = 2.0 / 2.0 par.ssrcalc_window = 4 / 2.0 par.ssrcalc_window = 9999 / 2.0 par.peptide_tables = ['hroest.srmPeptides_yeast'] par.transition_table = 'hroest.srmTransitions_yeast' par.isotopes_up_to = 3 self.mycollider = collider.SRMcollider() par.select_by = "id" self.par = par self.min_q1 = 440 self.max_q1 = 450 ## For debugging ##self.max_q1 = 440.18 ##par.q1_window = 0.009 / 2.0 ##par.q3_window = 2.0 / 2.0 ##par.isotopes_up_to = 1 import Residues R = Residues.Residues('mono') isotope_correction = par.isotopes_up_to * R.mass_diffC13 / min( par.parent_charges) start = time.time() query = """ select modified_sequence, transition_group, parent_id, q1_charge, q1, ssrcalc, isotope_nr, 0, 0 from %s where q1 between %s and %s #and isotope_nr = 0 """ % (par.peptide_tables[0], self.min_q1 - par.q1_window, self.max_q1 + par.q1_window) cursor.execute(query) self.alltuples = list(cursor.fetchall()) #print "len alltuples", len(self.alltuples) query = """ select modified_sequence, transition_group, parent_id, q1_charge, q1, ssrcalc, isotope_nr, 0, 0 from %s where q1 between %s - %s and %s and isotope_nr = 0 """ % (par.peptide_tables[0], self.min_q1 - par.q1_window, isotope_correction, self.max_q1 + par.q1_window) cursor.execute(query) self.alltuples_isotope_correction = list(cursor.fetchall()) #print "len alltuples zero", len(self.alltuples_isotope_correction) self.myprecursors = Precursors() # myprecursors.getFromDB(par, db.cursor(), self.min_q1 - par.q1_window, self.max_q1 + par.q1_window) ##### LEGACY getFromDB -- have isotope_nr = 0 in there! # Get all precursors from the DB within a window of Q1 lower_q1 = self.min_q1 - par.q1_window upper_q1 = self.max_q1 + par.q1_window self.myprecursors.precursors = [] isotope_correction = par.isotopes_up_to * R.mass_diffC13 / min( par.parent_charges) q = """ select modified_sequence, transition_group, parent_id, q1_charge, q1, ssrcalc, modifications, missed_cleavages, isotopically_modified from %(peptide_table)s where q1 between %(lowq1)s - %(isotope_correction)s and %(highq1)s and isotope_nr = 0 """ % { 'peptide_table': par.peptide_tables[0], 'lowq1': lower_q1, # min_q1 - par.q1_window 'highq1': upper_q1, # max_q1 + par.q1_window, 'isotope_correction': isotope_correction } cursor.execute(q) for res in cursor.fetchall(): p = Precursor() p.initialize(*res) # Only include those precursors that are actually have isotopes in the specified range if (p.included_in_isotopic_range(lower_q1, upper_q1, par)): self.myprecursors.precursors.append(p) ##### END LEGACY getFromDB self.precursors_to_evaluate = self.myprecursors.getPrecursorsToEvaluate( self.min_q1, self.max_q1) except Exception as inst: print "something went wrong" print inst