Beispiel #1
0
def iedb_table():
    mongo = get_mongo_db()
    data = []
    if request.method == 'POST':
        error = None
        gene = request.form["gene_select"]
        aa_pos_start = int(request.form["aa_pos_start"]
                           ) if request.form["aa_pos_start"] != "" else 0
        aa_pos_end = int(request.form["aa_pos_end"]
                         ) if request.form["aa_pos_end"] != "" else 0

        data = list(
            mongo.db.iedb.find(
                {
                    "Gene": gene,
                    "aa_pos": {
                        "$gt": aa_pos_start,
                        "$lt": aa_pos_end
                    }
                }, {'_id': False}))
        if len(data) == 0:
            error = "Epitope not found."
        if error:
            flash(error)
    return render_template('immuno/iedb_epitope_table.html',
                           genes=[
                               "E", "M", "N", "nsp01", "nsp10", "nsp11",
                               "nsp12", "nsp13", "nsp14", "nsp15", "nsp16",
                               "nsp2", "nsp3", "nsp4", "nsp5", "nsp6", "nsp7",
                               "nsp8", "nsp9", "orf10", "orf3a", "orf6",
                               "orf7a", "orf7b", "orf8", "S"
                           ],
                           epitopes=data)
Beispiel #2
0
def hla_I_table():
    mongo = get_mongo_db()
    data = []
    if request.method == 'POST':

        gene = request.form["gene_select"]
        binding_affinity = float(
            request.form["binding_affinity"]
        ) if request.form["binding_affinity"] != "" else 0
        flash((gene, binding_affinity))
        data = mongo.db.hla.find({
            "gene": gene,
            "binding_affinity": {
                "$lt": binding_affinity
            }
        })

    return render_template('immuno/hla_I_table.html',
                           genes=[
                               "E", "M", "N", "nsp01", "nsp10", "nsp11",
                               "nsp12", "nsp13", "nsp14", "nsp15", "nsp16",
                               "nsp2", "nsp3", "nsp4", "nsp5", "nsp6", "nsp7",
                               "nsp8", "nsp9", "orf10", "orf3a", "orf6",
                               "orf7a", "orf7b", "orf8", "S"
                           ],
                           epitopes=data)
def primer_result(run_id):
    mongo = get_mongo_db()
    parameters = mongo.db.primer_results.find_one({'_id': str(run_id)})
    print({'_id': str(run_id)})
    print(parameters)
    return render_template('diagnostics/primer_result.html',
                           run_id=str(run_id),
                           parameters=parameters)
Beispiel #4
0
def primers():
    mongo = get_mongo_db()
    if request.method == 'POST':
        uniq_id = str(uuid.uuid4())
        primerF = request.form["primerF"]
        primerR = request.form["primerR"]
        probe = request.form["probe"]
        save_dir = app.root_path+"/"+app.static_url_path+"/results/"
        run_primer_conservation.delay(primerF=primerF,primerR=primerR,probe=probe,uniq_id=uniq_id, save_dir=save_dir)
        return redirect(url_for('analyse.primer_result', run_id=str(uniq_id)))


    return render_template('analyse/diagnostics.html')
Beispiel #5
0
def phylogeny():
    mongo = get_mongo_db()
    if request.method == 'POST':
        uniq_id = str(uuid.uuid4())
        if request.files['file1'].filename=="":
            error = "No files found, please try again!"
        filename1 = secure_filename(request.files['file1'].filename)
        server_fname1 = os.path.join(app.config["UPLOAD_FOLDER"], filename1)
        request.files['file1'].save(server_fname1)
        run_phylogeny.delay(server_fname1,uniq_id,working_dir=app.config["APP_ROOT"]+url_for('static', filename='results'))

        return redirect(url_for('analyse.phylogeny_result', run_id=uniq_id))


    return render_template('analyse/phylogeny.html')
Beispiel #6
0
def phylogeny_result(run_id):
    mongo = get_mongo_db()
    file_prefix = "%s/%s" % (app.config["APP_ROOT"]+url_for('static', filename='results'), run_id)
    status = {
        "msa":"OK" if os.path.isfile(file_prefix+".aln") else "Processing",
        "vcf": "OK" if os.path.isfile(file_prefix+".vcf.gz") else "Processing",
        "variant_info": "OK" if os.path.isfile(file_prefix+".variant_info.csv") else "Processing",
        "phylogeny": "OK" if os.path.isfile(file_prefix+".aln.iqtree") else "Processing",
    }
    print(status)
    csv_data = []
    if status["variant_info"]=="OK":
        for row in csv.DictReader(open(file_prefix+".variant_info.csv")):
            csv_data.append(row)

    return render_template('analyse/phylogeny_result.html',run_id=run_id, status=status, csv_data=csv_data)
Beispiel #7
0
def run_result(sample_id):
    mongo = get_mongo_db()

    run = mongo.db.profiler_results.find_one({"_id": str(sample_id)})

    if run == None:
        error = "Run does not exist"
        abort(404)

    if run["status"] == "done":
        pdb_ids = [
            x.split("/")[-1].split(".")[0]
            for x in os.listdir(app.config["APP_ROOT"] +
                                url_for('static', filename='pdb'))
            if x[-4:] == ".pdb"
        ]
        structures = defaultdict(dict)
        for id in pdb_ids:
            d = json.load(
                open(app.config["APP_ROOT"] +
                     url_for('static',
                             filename='pdb/%s.pdb.available_residues.json' %
                             id)))
            for key, val in d["mapping"].items():
                structures[val]["pdb_code"] = id
                structures[val]["pdb_file"] = url_for('static',
                                                      filename='pdb/%s.pdb' %
                                                      id)
                structures[val]["chain"] = key
                structures[val]["residues"] = d["residues"][val]

        structure_variants = []
        print(run)
        for mutation in run["results"]["variants"]:
            if mutation["types"] != "missense": continue
            residue = int(re.match("(\d+)", mutation["changes"]).group(1))
            if mutation["gene"] in structures:
                if residue in structures[mutation["gene"]]["residues"]:
                    structure_variants.append(mutation)

        return render_template('results/run_result.html',
                               run=run,
                               structures=structures,
                               structure_variants=structure_variants)
    else:
        return render_template('results/run_result.html', run=run)
Beispiel #8
0
def mutation(position):
    db = get_db()
    mongo = get_mongo_db()
    mutation = mongo.db.mutations.find_one({"position": str(position)})
    del mutation["_id"]

    if mutation == None:
        error = "Mutation does not exist"
        abort(404)
    tmp = json.dumps(mutation)
    mutation["json_string"] = tmp

    tree_text = mongo.db.tree.find_one()["tree"]
    meta = mongo.db.meta.find_one()
    del meta["_id"]
    tree = {"newick": tree_text, "meta": json.dumps(meta), "created": "test"}

    return render_template('results/mutations.html',
                           mutation=mutation,
                           tree=tree)
Beispiel #9
0
def profile():
    mongo = get_mongo_db()
    if request.method == 'POST':
        cp.log("Recieved POST request with files %s\n" % (", ".join([request.files[x].filename for x in request.files])) )
        error=None
        # username = g.user['username'] if g.user else 'private'
        username = '******'
        uniq_id = str(uuid.uuid4())
        sample_name = uniq_id
        if request.files['file1'].filename=="":
            error = "No files found, please try again!"
        if "fasta_submit" in request.form and error==None:
            run_sample(mongo,username,uniq_id,sample_name,"fasta",request.files['file1'])
            return redirect(url_for('results.run_result', sample_id=uniq_id))
        elif "fastq_submit" in request.form and error==None:
            run_sample(mongo,username,uniq_id,sample_name,"fastq",request.files['file1'],request.files['file2'])
            return redirect(url_for('results.run_result', sample_id=uniq_id))

        flash(request.form)
        flash(error)
    return render_template('analyse/profile.html')
def diagnostics():
    mongo = get_mongo_db()
    if request.method == 'POST':
        uniq_id = str(uuid.uuid4())
        primerF = request.form["primerF"]
        primerR = request.form["primerR"]
        probe = request.form["probe"]
        save_dir = app.root_path + "/" + app.static_url_path + "/results/"
        mongo.db.primer_results.insert_one({
            "_id": str(uniq_id),
            "status": "processing",
            "primerF": primerF,
            "primerR": primerR,
            "probe": probe
        })
        profile_primer.delay(primerF=primerF,
                             primerR=primerR,
                             probe=probe,
                             uniq_id=uniq_id,
                             save_dir=save_dir)
        return redirect(
            url_for('diagnostics.primer_result', run_id=str(uniq_id)))

    return render_template('diagnostics/diagnostics.html')
Beispiel #11
0
def analyse():
    mongo = get_mongo_db()
    return render_template('analyse/analyse.html')
Beispiel #12
0
def primer_result(run_id):
    mongo = get_mongo_db()
    json_file = app.root_path+"/"+app.static_url_path+"/results/%s.plots.json" % str(run_id)
    data = json.load(open(json_file)) if os.path.isfile(json_file) else None

    return render_template('analyse/primer_result.html',run_id=str(run_id),data = data)
Beispiel #13
0
def test():
    mongo = get_mongo_db()
    return render_template('test/test.html')
Beispiel #14
0
def table(gene):
    mongo = get_mongo_db()
    data = mongo.db.immuno.find({"Gene": gene}, {'_id': False})

    return render_template('immuno/main_table.html', data=data)
Beispiel #15
0
def mutation_table():
    mongo = get_mongo_db()
    mutations = mongo.db.mutations.find()
    return render_template('results/mutation_table.html', mutations=mutations)