Exemplo n.º 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
Exemplo n.º 2
0
def commence_file_io(job_id):

    print "DEBUG?? ", "{0}".format(cfront_settings.get("debug_mode", False))

    if v: print "commencing file io"

    job = Session.query(Job).get(job_id)
    Session.add(job)

    if len(job.good_spacers) == 0 or job.genome_name != 'hg19':
        job.files_failed = True
        job.date_failed = datetime.datetime.utcnow()
        return

    write_f4(job_id)
    write_f5_f6(job_id)

    if len([f for f in job.files if f["ready"] == False]) == 0:
        job.files_ready = True
        job.date_completed = datetime.datetime.utcnow()
    else:
        job.files_failed = True

    try:
        if job.email_complete:
            if (not cfront_settings.get("debug_mode",
                                        False)) and cfront_settings.get(
                                            "mails_on_completion", False):
                mail.mail_completed_job(None, job)
    except mail.MailError as m:
        print "writing mail on complete failed for job {0}".format(job.id)
Exemplo n.º 3
0
def add_jobs(data_tsv):
    cols = ['id', 'sequence', 'date_submitted', 'genome', 'name', 'email', 'date_completed', 'chr', 'start', 'strand', 'computing_spacers', 'computed_spacers', 'files_computing', 'files_ready', 'email_complete', 'key']
    rows = []
    with open(data_tsv) as f :
        for l in f:
            rows.append(dict( zip(cols,[e.strip() for e in  l.split('\t')])  ))
    
    with transaction.manager:
        for r in rows:
            
            sequence = r["sequence"].upper()
            sequence = re.sub("\s","",sequence)
            if re.compile("[^AGTC]").search(sequence) is not None:
                continue

            j = Job(key = r['key'],
                    name = r["name"],
                    email = r["email"],
                    chr = r["chr"],
                    start = r["start"],
                    strand = r["strand"],
                    sequence = sequence,
                    genome = r["genome"],
                    email_complete=True if r["email_complete"] else False,
                    date_submitted = datetime.datetime.utcnow())

            Session.add(j)
Exemplo n.º 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:
                    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
Exemplo n.º 5
0
def commence_file_io(job_id):

    print "DEBUG?? ", "{0}".format( cfront_settings.get("debug_mode",False))

    if v: print "commencing file io"

    job = Session.query(Job).get(job_id)    
    Session.add(job)
    
    if  len(job.good_spacers) == 0 or job.genome_name != 'hg19':
        job.files_failed = True
        job.date_failed = datetime.datetime.utcnow()
        return 

    write_f4(job_id)
    write_f5_f6(job_id)
    
    if len([f for f in job.files if f["ready"] == False]) == 0:
        job.files_ready = True
        job.date_completed = datetime.datetime.utcnow()
    else:
        job.files_failed = True

    
    try:
        if job.email_complete:
            if (not cfront_settings.get("debug_mode",False)) and cfront_settings.get("mails_on_completion",False):
                mail.mail_completed_job(None, job)
    except mail.MailError as m:
        print "writing mail on complete failed for job {0}".format(job.id)
Exemplo n.º 6
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
Exemplo n.º 7
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