Beispiel #1
0
    def setUp(self):
        try:
            import c_getnonuis
            self.transitions = test_shared.transitions_def1
            self.collisions = test_shared.collisions_def1
            self.pep1 = test_shared.peptide1
            self.pep2 = test_shared.peptide2

            self.transitions_12_between300_1500 = test_shared.transitions_12_between300_1500
            self.pep1_yseries = test_shared.pep1_yseries
            self.pep1_bseries = test_shared.pep1_bseries

            tuples = []
            tuples.append(self.pep1)
            tuples.append(self.pep2)
            self.tuples = tuple(tuples)

            self.R = Residues('mono')

            class Minimal:
                pass

            self.par = Minimal()
            self.par.q3_window = 4.0
            self.par.ppm = False
            self.q3_high = 1500
            self.q3_low = 300
            self.MAX_UIS = 5

            self.par.bions = True
            self.par.yions = True
            self.par.aions = False
            self.par.aMinusNH3 = False
            self.par.bMinusH2O = False
            self.par.bMinusNH3 = False
            self.par.bPlusH2O = False
            self.par.yMinusH2O = False
            self.par.yMinusNH3 = False
            self.par.cions = False
            self.par.xions = False
            self.par.zions = False
            self.par.MMinusH2O = False
            self.par.MMinusNH3 = False

        except ImportError:
            pass
Beispiel #2
0
    def _process(self, line):
        """Parses DOM records.
    
        Records consist of 4 tab deliminated fields;
        sid, pdbid, residues, hierarchy
        """
        #For example ::
        #
        #d1sctg_ 1sct    g:      1.001.001.001.001.001
        #d1scth_ 1sct    h:      1.001.001.001.001.001
        #d1flp__ 1flp    -       1.001.001.001.001.002
        #d1moh__ 1moh    -       1.001.001.001.001.002

        line = line.rstrip()  # no trailing whitespace
        columns = line.split("\t")  # separate the tab-delineated cols
        if len(columns) != 4:
            raise ValueError("I don't understand the format of %s" % line)
        self.sid, pdbid, res, self.hierarchy = columns
        self.residues = Residues(res)
        self.residues.pdbid = pdbid
Beispiel #3
0
    def getSeqMap(self, residues):
        """Get the sequence map for a collection of residues.

        residues -- A Residues instance, or a string that can be converted into
                    a Residues instance.
        """
        if type(residues) == StringType:
            residues = Residues(residues)

        pdbid = residues.pdbid
        frags = residues.fragments
        if not frags:
            frags = (('_', '', ''), )  # All residues of unnamed chain

        seqMap = None
        for frag in frags:
            chainid = frag[0]
            if chainid == '' or chainid == '-' or chainid == ' ' or chainid == '_':
                chainid = '_'
            id = pdbid + chainid

            sm = self[id]

            #Cut out fragment of interest
            start = 0
            end = len(sm.res)
            if frag[1]: start = int(sm.index(frag[1], chainid))
            if frag[2]: end = int(sm.index(frag[2], chainid) + 1)

            sm = sm[start:end]

            if seqMap == None:
                seqMap = sm
            else:
                seqMap += sm

        return seqMap
Beispiel #4
0
#!/usr/bin/python
# -*- coding: utf-8  -*-
"""
 *
 * Program       : SRMCollider
 * Author        : Hannes Roest <*****@*****.**>
 * Date          : 13.11.2012
"""
import srmcollider_website_helper
import DDB, collider, sys

from Residues import Residues
R = Residues('mono')
peptideparser = srmcollider_website_helper.PeptideParser(R)

###########################################################################
# Parse options
from optparse import OptionParser, OptionGroup
usage = "usage: %prog [options]"
parser = OptionParser(usage=usage)
group = OptionGroup(parser, "Run options")
group.add_option("--in",
                 dest="inputfile",
                 type="str",
                 help="Input file with one peptide sequence per line")
group.add_option("--out",
                 dest="outputfile",
                 type="str",
                 help="Output file in mProphet format")
parser.add_option_group(group)
 def __init__(self):
     self.peptides = []
     self.R = Residues('mono')
Beispiel #6
0
    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):

        try:
            import MySQLdb
            self.database_available = True
        except ImportError:
            print """Module MySQLdb not available.
            
            Please install it if you want to use it.
            Use the following command (on Ubuntu systems):
                sudo apt-get install python-mysqldb
            """
            self.database_available = False

        try:
            self.db = MySQLdb.connect(read_default_file=mysql_conf_file)
            self.database_available = True
        except MySQLdb.OperationalError as e:
            print "Could not connect to database: Please check the configuration in test/test_db.py!\n", e
            self.database_available = False

        class Minimal:
            def get_q3_window_transitions(self, q3):
                if self.ppm:
                    return [
                        q3 - self.q3_window * 10**(-6) * q3,
                        q3 + self.q3_window * 10**(-6) * q3
                    ]
                else:
                    return [q3 - self.q3_window, q3 + self.q3_window]

        self.par = Minimal()
        self.par.q3_window = 4.0
        self.par.ppm = False
        self.MAX_UIS = 5
        self.q3_high = 1500
        self.q3_low = 300

        self.par.q1_window = 1.2 / 2.0
        self.par.ssrcalc_window = 9999
        self.par.query2_add = ' and isotope_nr = 0 '
        self.par.peptide_tables = [test_database + '.srmPeptides_human']
        self.par.transition_table = test_database + '.srmTransitions_human'
        self.par.print_query = False
        self.par.select_floor = False
        self.par.isotopes_up_to = 3
        self.par.select_by = "id"

        self.par.parent_charges = [2, 3]

        self.par.bions = True
        self.par.yions = True
        self.par.aions = False
        self.par.aMinusNH3 = False
        self.par.bMinusH2O = False
        self.par.bMinusNH3 = False
        self.par.bPlusH2O = False
        self.par.yMinusH2O = False
        self.par.yMinusNH3 = False
        self.par.cions = False
        self.par.xions = False
        self.par.zions = False
        self.par.MMinusH2O = False
        self.par.MMinusNH3 = False

        def returntrue():
            return True

        self.par.do_b_y_only = returntrue

        def returnrange():
            return self.q3_low, self.q3_high

        self.par.get_q3range_collisions = returnrange
        #self.par.get_q3_window_transitions = get_q3_window_transitions
        #self.par.get_q3_window_transitions = collider.SRM_parameters.get_q3_window_transitions

        import sys
        self.R = Residues('mono')

        self.acollider = collider.SRMcollider()
        self.aparamset = collider.testcase(testdatabase=test_database)