コード例 #1
0
def task_id_edit(_id=None):
    task_id_form = TaskIDForm()
    task_id_query = TaskId.objects.get_or_404(_id=_id)
    if task_id_form.validate_on_submit():
        data = task_id_form.data
        data_count = Specie.objects(srr_id=data["srr_id"]).count()
        if data_count == 0:
            TaskId.objects(task_id=_id).update_one(set__srr_id=data["srr_id"])
            TaskId.objects(task_id=_id).update_one(set__email=data["email"])
            TaskId.objects(task_id=_id).update_one(
                set__task_time=datetime.now())
            flash("edit done !", "ok")
            return redirect(url_for("admin.task_id_edit", _id=_id))
        elif data_count == 1 and task_id_query.srr_id != data["srr_id"]:
            flash("this task is already exist !", "err")
            return redirect(url_for("admin.task_id_edit", _id=_id))
        elif data_count == 1 and task_id_query.srr_id == data["srr_id"]:
            TaskId.objects(task_id=_id).update_one(set__email=data["email"])
            TaskId.objects(task_id=_id).update_one(
                set__task_time=datetime.now())
            flash("edit done !", "ok")
            return redirect(url_for("admin.task_id_edit", _id=_id))
    return render_template("admin/task_id_edit.html",
                           form=task_id_form,
                           task_id=task_id_query)
コード例 #2
0
def task_id_add():
    task_id_form = TaskIDForm()
    if task_id_form.validate_on_submit():
        data = task_id_form.data
        new_task_id = TaskId(task_id=str(uuid.uuid1()),
                             srr_id=data["srr_id"],
                             email=data["email"],
                             task_time=datetime.now())
        new_task_id.save()
        flash("this task is added !", "ok")
        return redirect(url_for("admin.task_id_add"))
    return render_template("admin/task_id_add.html", form=task_id_form)
コード例 #3
0
ファイル: view.py プロジェクト: felixlyd/operondemmoDB
def task_id(_id):
    task_query = TaskId.objects(task_id=_id).first()
    srr_id_query = task_query.srr_id
    srr_task_query = SrrTask.objects.get_or_404(_id=srr_id_query)
    each = {"_id": srr_task_query._id, "kegg_id": srr_task_query.kegg_id, "method": srr_task_query.method,
            "operon": srr_task_query.operon_path, "jbrowse": srr_task_query.browse_link}
    return render_template("home/task.html", each=each)
コード例 #4
0
ファイル: forms.py プロジェクト: felixlyd/operondemmoDB
 def validate_srr_id(self, field):
     data = field.data
     data_count = TaskId.objects(srr_id=data).count()
     if data_count > 0:
         raise ValidationError("the srr id is already exist !")
コード例 #5
0
def task_id_del(_id=None):
    TaskId.objects(task_id=_id).delete()
    flash("delete it done !", "ok")
    return redirect(url_for("admin.task_id"))
コード例 #6
0
def task_id(page=None):
    if page is None:
        page = 1
    page_data = TaskId.objects().paginate(page=page, per_page=10)
    return render_template("admin/task_id.html", page_data=page_data)
コード例 #7
0
ファイル: view.py プロジェクト: felixlyd/operondemmoDB
def index():
    submit_form = SubmitForm()
    if submit_form.condition_add.data:
        submit_form.condition.append_entry()
        return render_template("home/index.html", form=submit_form)
    i_iter = 0
    for con in submit_form.condition.entries:
        if con.condition_del.data:
            submit_form.condition.entries.pop(i_iter)
            return render_template("home/index.html", form=submit_form)
        if con.repeat_add.data:
            submit_form.condition.entries[i_iter].repeat.append_entry()
            return render_template("home/index.html", form=submit_form)
        j_iter = 0
        for rep in con.repeat.entries:
            if rep.repeat_del.data:
                submit_form.condition.entries[i_iter].repeat.entries.pop(j_iter)
                return render_template("home/index.html", form=submit_form)
            j_iter = j_iter + 1
        i_iter = i_iter + 1
    auto = ""
    if submit_form.kegg_auto.data:
        auto = "y"
    if submit_form.kegg_not_auto.data:
        auto = "n"
    if submit_form.validate_on_submit():
        data = submit_form.data
        srr_list = []
        all_srr = []
        for con in data["condition"]:
            srr_list.append([])
            for each in con["repeat"]:
                srr_list[-1].append(each['srr'])
                all_srr.append(each['srr'])
        all_srr = sorted(all_srr)
        srr_id = "-".join(all_srr)
        data_count = SrrTask.objects(_id=srr_id).count()
        if data_count == 1:
            return redirect(url_for("home.srr_id", _id=srr_id))

        new_task_id = TaskId(task_id=str(uuid.uuid1()), srr_id=srr_id, email=data["email"], task_time=datetime.now())
        new_task_id.save()

        if submit_form.gff_file.data is not None:
            gff = submit_form.gff_file.data
            gff_filename = secure_filename(gff.filename)
            gff_path = os.path.join(path, data["kegg_id"], gff_filename)
            if not os.path.exists(path):
                os.system("mkdir " + path)
            if not os.path.exists(os.path.join(path, data["kegg_id"])):
                os.system("mkdir " + os.path.join(path, data["kegg_id"]))
            gff.save(gff_path)
            fna = submit_form.fna_file.data
            fna_filename = secure_filename(fna.filename)
            fna_path = os.path.join(path, data["kegg_id"], fna_filename)
            if not os.path.exists(os.path.join(path, data["kegg_id"])):
                os.system("mkdir " + os.path.join(path, data["kegg_id"]))
            fna.save(fna_path)

        kegg_id = data["kegg_id"]
        soft = data["software_select"]
        method = data["method_select"]
        corr = data["correlation_select"]

        executor.submit(operon_predict, srr_list, kegg_id, soft, method, corr, srr_id)

        return redirect(url_for("home.wait"))

    return render_template("home/index.html", form=submit_form, auto=auto)