Beispiel #1
0
def process_queue(ofs, stride):
    # start a transaction to compute spacers for any jobs which lack them
    # NOTE this is the second place in our code where spacers can be created
    # this should be fixed as we don't do the same checks here that we do in
    # the first -- at views_ajax/post_new.
    #
    # here we protect against the case where no spacers pass but don't do
    # any checking of the input query.

    possible_spacer_jobs = Session.query(Job).filter(Job.computed_spacers == False).all()
    selected_jobs = [j for j in possible_spacer_jobs if j.id % stride == ofs and j.genome_name != "rn5"]

    for j in selected_jobs[:100]:
        with transaction.manager:
            try:
                print "computing spacers {0}".format(j.id)
                spacer_infos = webserver_db.compute_spacers(j.sequence)
                if (len(spacer_infos)) == 0:
                    raise JobERR(Job.NOSPACERS, j)
                for spacer_info in spacer_infos:
                    Session.add(Spacer(job=j, **spacer_info))
                j.computed_spacers = True
                Session.add(j)
            except JobERR, e:
                print "Excepted a job error during Spacer finding for Job: {0}".format(j.id)
                print j.sequence
def process_queue(ofs, stride):
    # start a transaction to compute spacers for any jobs which lack them
    # NOTE this is the second place in our code where spacers can be created
    # this should be fixed as we don't do the same checks here that we do in
    # the first -- at views_ajax/post_new.
    #
    #here we protect against the case where no spacers pass but don't do
    # any checking of the input query.

    possible_spacer_jobs = Session.query(Job).filter(
        Job.computed_spacers == False).all()
    selected_jobs = [
        j for j in possible_spacer_jobs
        if j.id % stride == ofs and j.genome_name != "rn5"
    ]

    for j in selected_jobs[:100]:
        with transaction.manager:
            try:
                print 'computing spacers {0}'.format(j.id)
                spacer_infos = webserver_db.compute_spacers(j.sequence)
                if (len(spacer_infos)) == 0:
                    raise JobERR(Job.NOSPACERS, j)
                for spacer_info in spacer_infos:
                    Session.add(Spacer(job=j, **spacer_info))
                j.computed_spacers = True
                Session.add(j)
            except JobERR, e:
                print "Excepted a job error during Spacer finding for Job: {0}".format(
                    j.id)
                print j.sequence
Beispiel #3
0
def process_queue(ofs, stride):
    possible_spacer_jobs = Session.query(Job).filter(Job.computed_spacers == False).all()
    selected_jobs = possible_spacer_jobs

    for j in selected_jobs[:100]:
        with transaction.manager:
            try:
                print 'computing spacers {0}'.format(j.id)
                spacer_infos = webserver_db.compute_spacers(j.sequence)
                if(len(spacer_infos)) == 0:
                    raise JobERR(Job.NOSPACERS, j)
                for spacer_info in spacer_infos:
                    Session.add(Spacer(job = j,**spacer_info))
                j.computed_spacers = True
                Session.add(j)
                print j.id
            except JobERR, e:
                if e.message == Job.NOSPACERS:
                    print "No spacers in JOB ID: {0}".format(j.id)
                elif e.message == Job.ERR_INVALID_CHARACTERS:
                    print e.message
                else:
                    print "Excepted a job error during Spacer finding for Job: {0}".format(j.id)
                    print j.id
                    print j.sequence
                    raise e
Beispiel #4
0
def process_queue(ofs, stride):
    possible_spacer_jobs = Session.query(Job).filter(Job.computed_spacers == False).all()
    selected_jobs = possible_spacer_jobs

    for j in selected_jobs[:100]:
        with transaction.manager:
            try:
                print 'computing spacers {0}'.format(j.id)
                spacer_infos = webserver_db.compute_spacers(j.sequence)  
                if(len(spacer_infos)) == 0:
                    raise JobERR(Job.NOSPACERS, j)
                for spacer_info in spacer_infos:
                    Session.add(Spacer(job = j,**spacer_info))
                j.computed_spacers = True
                Session.add(j)
                print j.id
            except JobERR, e:
                if e.message == Job.NOSPACERS:
                    j.failed = True
                    j.computed_spacers = True
                    Session.add(j)
                    print "No spacers in JOB ID: {0}".format(j.id)
                elif e.message == Job.ERR_INVALID_CHARACTERS:
                    j.failed = True
                    j.computed_spacers = True
                    Session.add(j)
                    print e.message
                else:
                    print "Excepted a job error during Spacer finding for Job: {0}".format(j.id)
                    j.failed = True
                    Session.add(j)
                    print j.id
                    print j.sequence
                    raise e