Ejemplo n.º 1
0
def test(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    outdir = FS.location
    os.system('qsub -v pipeline="jbrowser",bench_id="' + 'F33H7949W0C2FFY' + '",key="' + pipeline_id + '",outdir="' + outdir +
              '",name="' + pipeline_id + '_jbrowser"' + ' -N ' + pipeline_id + '_jbrowser /shared/sRNAtoolbox/core/bash_scripts/run_sRNAjbrowser.sh')

    return redirect("/srnatoolbox/jobstatus/srnajbrowser/?id=" + pipeline_id)
Ejemplo n.º 2
0
def test(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    outdir = FS.location
    name = pipeline_id + '_gfree'
    os.system('qsub -v pipeline="gfree",input="' + "/shared/sRNAtoolbox/testData/Ddent_exo.fa" + '",key="' + pipeline_id + '",minReadLength="' + "19" +
              '",maxReadLength="' + "23" + '",microRNA="' + "sja:sma:egr:emu:sme:cel:bta" + '",minRC="' + "10" + '",noMM="' + "0" +
              '",outdir="' + outdir + '",name="' + name + '" -N ' + name +
              ' /shared/sRNAtoolbox/core/bash_scripts/run_sRNAgfree.sh')

    return redirect("/srnatoolbox/jobstatus/srnagfree/?id=" + pipeline_id)
Ejemplo n.º 3
0
def test(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    outdir = FS.location
    os.system(
        'qsub -v pipeline="dejbrowser",groups="' + "cell#exosome" + '",key="' +
        pipeline_id + '",outdir="' + outdir + '",name="' + pipeline_id +
        '_dejbrowser",bench_id="' + "RG5TRAJIOOFS7II#F33H7949W0C2FFY" +
        '" -N ' + pipeline_id +
        '_dejbrowser /shared/sRNAtoolbox/core/bash_scripts/run_sRNAdejbrowser_nolength.sh'
    )

    return redirect("/srnatoolbox/jobstatus/srnajbrowserde/?id=" + pipeline_id)
Ejemplo n.º 4
0
def run(request):
    if request.POST["bench_id"].replace(" ", "") != "":
        pipeline_id = pipeline_utils.generate_uniq_id()
        bench_id = request.POST["bench_id"]
        FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
        make_dir(FS.location)
        outdir = FS.location

        os.system('qsub -v pipeline="jbrowser",bench_id="' + bench_id + '",key="' + pipeline_id + '",outdir="' + outdir +
                  '",name="' + pipeline_id + '_jbrowser"' + ' -N ' + pipeline_id + '_jbrowser /shared/sRNAtoolbox/core/bash_scripts/run_sRNAjbrowser.sh')

        return redirect("/srnatoolbox/jobstatus/srnajbrowser/?id=" + pipeline_id)

    else:
        return render(request, "error_page.html", {"errors": ["sRNAbench ID must be provided"]})
Ejemplo n.º 5
0
def test(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)

    annotations = ["go"]
    go_table = "goa_hsa"
    exp = "true"
    outdir = FS.location
    mir_list = "/shared/sRNAtoolbox/testData/functerms_test_data.txt"

    os.system(
        'qsub -v pipeline="functerms",annot="' + ",".join(annotations) +
        '",outdir="' + outdir + '",go_table="' + go_table + '",exp="' + exp +
        '",key="' + pipeline_id + '",name="' + pipeline_id +
        '_functerms",input="' + mir_list + '",type="list"  -N ' + pipeline_id +
        '_functerms /shared/sRNAtoolbox/core/bash_scripts/run_sRNAfuncterms.sh'
    )

    return redirect("/srnatoolbox/jobstatus/srnafuncterms/?id=" + pipeline_id)
Ejemplo n.º 6
0
def test(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    outdir = FS.location
    program_string = "TS:MIRANDA:PITA"
    parameter_string = ":::"

    os.system('cp /shared/sRNAtoolbox/testData/rno_miR.fa ' + FS.location)
    os.system('cp /shared/sRNAtoolbox/testData/rn5_refSeq_3utr.fa ' + FS.location)

    miRNA_file = os.path.join(FS.location, "rno_miR.fa")
    utr_file = os.path.join(FS.location, "rn5_refSeq_3utr.fa")
    go_table = "goa_hsa"

    os.system(
        'qsub -v pipeline="mirnafunctargets",program_string="' + program_string + '",parameter_string="' + parameter_string + '",key="' + pipeline_id + '",outdir="' + outdir + '",miRNA_file="' + miRNA_file + '",utr_file="' + utr_file + '",go_table="' + go_table +
        '",name="' + pipeline_id + '_mirnafunctargets"' + ' -N ' + pipeline_id + '_mirnafunctargets /shared/sRNAtoolbox/core/bash_scripts/run_mirnafunctargets.sh')

    return redirect("/srnatoolbox/jobstatus/mirnafunctargets/?id=" + pipeline_id)
Ejemplo n.º 7
0
def run(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    input = ""
    outdir = FS.location

    if len(request.POST["id"].replace(" ", "")) > 0:
        input = request.POST["id"]
        length = request.POST["length"]
        desc = request.POST["desc"]

        response = check_ids_param(input, desc, length)

        if response is not True:
            return render(request, "error_page.html", response)

        if len(length.replace(" ", "")) > 0:
            os.system(
                'qsub -v pipeline="dejbrowser",groups="' + desc + '",key="' +
                pipeline_id + '",outdir="' + outdir + '",length="' + length +
                '",name="' + pipeline_id + '_dejbrowser",bench_id="' + input +
                '" -N ' + pipeline_id +
                '_dejbrowser /shared/sRNAtoolbox/core/bash_scripts/run_sRNAdejbrowser.sh'
            )

        else:
            os.system(
                'qsub -v pipeline="dejbrowser",groups="' + desc + '",key="' +
                pipeline_id + '",outdir="' + outdir + '",name="' +
                pipeline_id + '_dejbrowser",bench_id="' + input + '" -N ' +
                pipeline_id +
                '_dejbrowser /shared/sRNAtoolbox/core/bash_scripts/run_sRNAdejbrowser_nolength.sh'
            )

        return redirect("/srnatoolbox/jobstatus/srnajbrowserde/?id=" +
                        pipeline_id)

    else:
        return render(request, "error_page.html",
                      {"errors": ["sRNAbench IDs must be provided"]})
Ejemplo n.º 8
0
def test(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    guess_adapter = None
    recursive_adapter_trimming = None
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    id = "4XVGNWRUK0ZCUM1"
    file_to_copy = os.path.join("/shared/sRNAtoolbox/webData", id, "reads.fa")
    #os.system("head  -n 50 " + file_to_copy + " > " + os.path.join(FS.location, "reads.fa"))
    #ifile = os.path.join(FS.location, "reads.fa")
    ifile = file_to_copy
    adapter = None
    adapter_minLength = "10"
    adapterMM = "1"

    newConf = SRNABlastConfig(
        "nr",
        "/shared/exec/blast/blastn",
        FS.location,
        "/shared/sRNAbenchDB",
        ifile,
        "1",
        maxReads="10",
        minEvalue="10",
        adapter=adapter,
        recursiveAdapterTrimming=recursive_adapter_trimming,
        adapterMinLength=str(adapter_minLength),
        adapterMM=str(adapterMM),
        guessAdapter=guess_adapter,
        local=None)

    conf_file_location = os.path.join(FS.location, "conf.txt")
    newConf.write_conf_file(conf_file_location)
    os.system(
        'qsub -v pipeline="blast",configure="' + conf_file_location +
        '",key="' + pipeline_id + '",outdir="' + FS.location + '",name="' +
        pipeline_id + '_sRNAblast' + '" -N ' + pipeline_id +
        '_sRNAblast /shared/sRNAtoolbox/core/bash_scripts/run_sRNAblast.sh')

    return redirect("/srnatoolbox/jobstatus/srnablast/?id=" + pipeline_id)
Ejemplo n.º 9
0
def run(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    rc = request.POST["rc"]
    rl = "19"
    mm = request.POST["mm"]
    xrl = "23"
    homolog = request.POST["ajax_names"]
    name = pipeline_id + '_gfree'

    if homolog.replace(" ", "") == "":
        homolog = "false"
        #return render(request, "error_page.html", {"errors": ["Any species name must be provided. Please check the manual"]})



    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)

    if "reads_file" in request.FILES:
        file_to_update = request.FILES['reads_file']
        uploaded_file = str(file_to_update)
        FS.save(uploaded_file, file_to_update)
        input = os.path.join(FS.location, uploaded_file)

        outdir = FS.location


        os.system('qsub -v pipeline="gfree",input="' + input + '",key="' + pipeline_id + '",minReadLength="' + rl +
                  '",maxReadLength="' + xrl + '",microRNA="' + homolog + '",minRC="' + rc + '",noMM="' + mm +
                  '",outdir="' + outdir + '",name="' + name + '" -N ' + name +
                  ' /shared/sRNAtoolbox/core/bash_scripts/run_sRNAgfree.sh')

        print ('qsub -v pipeline="gfree",input="' + input + '",key="' + pipeline_id + '",minReadLength="' + rl +'",maxReadLength="' + xrl + '",microRNA="' + homolog + '",minRC="' + rc + '",noMM="' + mm +'",outdir="' + outdir + '",name="' + name + '" -N ' + name +' /shared/sRNAtoolbox/core/bash_scripts/run_sRNAgfree.sh')


        return redirect("/srnatoolbox/jobstatus/srnagfree/?id=" + pipeline_id)

    else:
        return render(request, "error_page.html", {"errors": ["Reads File must be provided"]})
Ejemplo n.º 10
0
def run(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)

    miRNA_file = ""
    utr_file = ""
    program_list = []
    parameters_list = []

    if "miRNA_file" in request.FILES:
        file_to_update = request.FILES['miRNA_file']
        uploaded_file = str(file_to_update).replace(" ", "").replace(
            ")", "").replace("(", "")
        if str(file_to_update).split(".")[1] not in [
                "fa", "fasta", "mfasta", "mfa", "txt"
        ]:
            return render(
                request, "error_page.html", {
                    "errors": [
                        'miRNAs file extension must be: fa, fasta, mfasta, mfa or txt. ".'
                        + str(file_to_update).split(".")[1] + '" found'
                    ]
                })
        FS.save(uploaded_file, file_to_update)
        miRNA_file = os.path.join(FS.location, uploaded_file)

    if "utr_file" in request.FILES:
        file_to_update = request.FILES['utr_file']
        uploaded_file = str(file_to_update).replace(" ", "").replace(
            ")", "").replace("(", "")
        if str(file_to_update).split(".")[1] not in [
                "fa", "fasta", "mfasta", "mfa", "txt"
        ]:
            return render(
                request, "error_page.html", {
                    "errors": [
                        'UTRs file extension must be: fa, fasta, mfasta, mfa or txt. ".'
                        + str(file_to_update).split(".")[1] + '" found'
                    ]
                })
        FS.save(uploaded_file, file_to_update)
        utr_file = os.path.join(FS.location, uploaded_file)

    if not ("miRNA_file" in request.FILES and "utr_file" in request.FILES):
        return render(
            request, "error_page.html",
            {"errors": ["miRNAs file and UTR file should be provided"]})

    for program in request.POST.getlist("programs"):
        program_list.append(program)

    program_string = ":".join(program_list)

    if len(program_list) < 1:
        return render(request, "error_page.html",
                      {"errors": ["At least one program should be chosen"]})

    for i, Parameter in enumerate(request.POST.getlist("Parameters")):
        if TOOLS[i] in program_list:
            parameters_list.append(Parameter)

    parameter_string = ":".join(parameters_list).replace("-", "55-55")

    if parameter_string == "":
        parameter_string = "".join([":" for i in program_list])

    outdir = FS.location

    os.system(
        'qsub -v pipeline="mirconstarget",program_string="' + program_string +
        '",parameter_string="' + parameter_string + '",key="' + pipeline_id +
        '",outdir="' + outdir + '",miRNA_file="' + miRNA_file +
        '",utr_file="' + utr_file + '",name="' + pipeline_id +
        '_mirconstarget"' + ' -N ' + pipeline_id +
        '_mirconstarget /shared/sRNAtoolbox/core/bash_scripts/run_mirnatarget.sh'
    )

    return redirect("/srnatoolbox/jobstatus/mirconstarget/?id=" + pipeline_id)
Ejemplo n.º 11
0
 def generate_id(self):
     is_new = True
     while is_new:
         pipeline_id = generate_uniq_id()
         if not JobStatus.objects.filter(pipeline_key=pipeline_id):
             return pipeline_id
Ejemplo n.º 12
0
def run(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    guess_adapter = None
    recursive_adapter_trimming = None
    local = None
    ifile = ""

    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)

    if "reads_file" in request.FILES:
        file_to_update = request.FILES['reads_file']
        uploaded_file = str(file_to_update)
        if str(file_to_update).split(".")[1] not in ["fastq", "fa", "rc"]:
            return render(
                request, "error_page.html", {
                    "errors": [
                        'Reads file extension must be: "fastq", "fa", "rc" ".'
                        + str(file_to_update).split(".")[1] + '" found'
                    ]
                })
        FS.save(uploaded_file, file_to_update)
        ifile = os.path.join(FS.location, uploaded_file)

    elif request.POST["bench_id"].replace(" ", "") != "":
        id = request.POST["bench_id"]
        file_to_copy = os.path.join("/shared/sRNAtoolbox/webData", id,
                                    "reads.fa")
        #os.system("head  -n 50 " + file_to_copy + " > " + os.path.join(FS.location, "reads.fa"))
        #ifile = os.path.join(FS.location, "reads.fa")
        ifile = file_to_copy

    elif request.POST["reads_url"].replace(" ", "") != "":
        url_input = request.POST["reads_url"]
        dest = os.path.join(FS.location, os.path.basename(url_input))
        handler = urllib.URLopener()
        handler.retrieve(url_input, dest)
        ifile = dest

    else:
        return render(
            request, "error_page.html",
            {"errors": ["Read File, URL or sRNAbench ID must be provided"]})

    if "guessAdapter" in request.POST:
        guess_adapter = "true"

    adapter = request.POST["adapter"]
    maxReads = request.POST["maxReads"]
    minEvalue = request.POST["minEvalue"]
    if minEvalue.replace(" ", "") != "":
        try:
            float(minEvalue)
        except:
            return render(request, "error_page.html", {
                "errors": ["Read File, URL or sRNAbench ID must be provided"]
            })

    else:
        minEvalue = "10"

    minrc = "1"
    alter_adapter = request.POST["alterAdapter"].upper().replace(" ", "")
    blastDB = request.POST["blastDB"]
    if len(alter_adapter) > 1:
        adapter = alter_adapter
    if adapter == "XXX":
        adapter = None

    adapter_minLength = request.POST["adapterMinLength"]
    adapterMM = request.POST["adapterMM"]

    if "recursiveAdapterTrimming" in request.POST:
        recursive_adapter_trimming = "true"

    if "local" in request.POST:
        blastDB = "/shared/blastDB/nt"
        local = "true"

    newConf = SRNABlastConfig(
        blastDB,
        "/shared/exec/blast/blastn",
        FS.location,
        "/shared/sRNAbenchDB",
        ifile,
        minrc,
        maxReads=maxReads,
        minEvalue=minEvalue,
        adapter=adapter,
        recursiveAdapterTrimming=recursive_adapter_trimming,
        adapterMinLength=str(adapter_minLength),
        adapterMM=str(adapterMM),
        guessAdapter=guess_adapter,
        local=local)

    conf_file_location = os.path.join(FS.location, "conf.txt")
    newConf.write_conf_file(conf_file_location)

    os.system(
        'qsub -v pipeline="blast",configure="' + conf_file_location +
        '",key="' + pipeline_id + '",outdir="' + FS.location + '",name="' +
        pipeline_id + '_sRNAblast' + '" -N ' + pipeline_id +
        '_sRNAblast /shared/sRNAtoolbox/core/bash_scripts/run_sRNAblast.sh')

    return redirect("/srnatoolbox/jobstatus/srnablast/?id=" + pipeline_id)
Ejemplo n.º 13
0
def run(request, tool):
    pipeline_id = pipeline_utils.generate_uniq_id()
    species = None
    taxonomy = None
    ifile = None
    string = None
    remove = "false"

    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    fdw = open(os.path.join(FS.location,"error.txt"),"w")
    if tool == "removedup" or tool == "extract":

        if "ifile" in request.FILES:
            file_to_update = request.FILES['ifile']
            uploaded_file = str(file_to_update)
            if str(file_to_update).split(".")[1] not in ["fa", "fasta", "gz"]:
                return render(request, "error_page.html", {"errors": [
                    'File extension must be: "fa" or "fasta".' + str(file_to_update).split(".")[
                        1] + '" found']})
            FS.save(uploaded_file, file_to_update)
            ifile = os.path.join(FS.location, uploaded_file)

        elif request.POST["url"].replace(" ", "") != "":
            url_input = request.POST["url"]
            dest = os.path.join(FS.location, os.path.basename(url_input))
            handler = urllib.URLopener()
            handler.retrieve(url_input, dest)
            ifile = dest


        else:
            return render(request, "error_page.html", {"errors": ["URL of file must be provided"]})

        string = request.POST["string"]



        if tool == "removedup":
            if string.replace(" ", "") == "":
                return render(request, "error_page.html", {
                    "errors": ["A string of characters must be provided to be drop out from the sequence names"]})

            if "duplicates" in request.POST:
                remove = "true"

            os.system(
                'qsub -v pipeline="helper",mode="rd",key="' + pipeline_id + '",outdir="' + FS.location +
                '",inputfile="' + ifile + '",string="' + string + '",remove="' + remove + '",name="'
                + pipeline_id + '_h_rd' + '" -N ' + pipeline_id +
                '_h_rd /shared/sRNAtoolbox/core/bash_scripts/run_helper_remove_duplicates.sh')


        else:
            if string.replace(" ", "") == "":
                return render(request, "error_page.html",
                              {"errors": ["A string of characters must be provided to select the sequences:"]})

            os.system(
                'qsub -v pipeline="helper",mode="extract",key="' + pipeline_id + '",outdir="' + FS.location +
                '",inputfile="' + ifile + '",string="' + string + '",name="'
                + pipeline_id + '_h_extract' + '" -N ' + pipeline_id +
                '_h_extract /shared/sRNAtoolbox/core/bash_scripts/run_helper_extract.sh')

            fdw.write('qsub -v pipeline="helper",mode="extract",key="' + pipeline_id + '",outdir="' + FS.location +
                '",inputfile="' + ifile + '",string="' + string + '",name="'
                + pipeline_id + '_h_extract' + '" -N ' + pipeline_id +
                '_h_extract /shared/sRNAtoolbox/core/bash_scripts/run_helper_extract.sh')





    if tool == "ncbiparser" or tool == "ensemlparser":

        if "ifile" in request.FILES:
            file_to_update = request.FILES['ifile']
            uploaded_file = str(file_to_update)
            FS.save(uploaded_file, file_to_update)
            ifile = os.path.join(FS.location, uploaded_file)

        elif request.POST["url"].replace(" ", "") != "":
            url_input = request.POST["url"]
            dest = os.path.join(FS.location, os.path.basename(url_input))
            handler = urllib.URLopener()
            handler.retrieve(url_input, dest)
            ifile = dest

        else:
            return render(request, "error_page.html", {"errors": ["URL of file must be provided"]})

        if tool == "ncbiparser":
            os.system(
                'qsub -v pipeline="helper",mode="ncbi",key="' + pipeline_id + '",outdir="' + FS.location +
                '",inputfile="' + ifile + '",name="' + pipeline_id + '_h_ncbi' + '" -N ' + pipeline_id +
                '_h_ncbi /shared/sRNAtoolbox/core/bash_scripts/run_helper_ncbi.sh')
        else:
            os.system(
                'qsub -v pipeline="helper",mode="ensembl",key="' + pipeline_id + '",outdir="' + FS.location +
                '",inputfile="' + ifile + '",name="' + pipeline_id + '_h_ens' + '" -N ' + pipeline_id +
                '_h_ens /shared/sRNAtoolbox/core/bash_scripts/run_helper_ensembl.sh')

    if tool == "rnacentralparser":
        species = request.POST["species"]
        if species.replace(" ", "") == "":
            taxonomy = request.POST["taxonomy"]
            taxonomy = taxonomy.replace(" ", "_")
            os.system(
                'qsub -v pipeline="helper",mode="rnacentral",key="' + pipeline_id + '",outdir="' + FS.location +
                '",taxon="' + taxonomy + '",name="' + pipeline_id + '_h_rnac' + '" -N ' + pipeline_id +
                '_h_rca /shared/sRNAtoolbox/core/bash_scripts/run_helper_rnacentral_taxon.sh')
        else:
            species = species.replace(" ", "_")
            fdw.write('qsub -v pipeline="helper",mode="rnacentral",key="' + pipeline_id + '",outdir="' + FS.location +
                '",species="' + species + '",name="' + pipeline_id + '_h_rnac' + '" -N ' + pipeline_id +
                '_h_rca /shared/sRNAtoolbox/core/bash_scripts/run_helper_rnacentral.sh')
            os.system(
                'qsub -v pipeline="helper",mode="rnacentral",key="' + pipeline_id + '",outdir="' + FS.location +
                '",species="' + species + '",name="' + pipeline_id + '_h_rnac' + '" -N ' + pipeline_id +
                '_h_rca /shared/sRNAtoolbox/core/bash_scripts/run_helper_rnacentral.sh')


    if tool == "trnaparser":
        species = request.POST["species"]
        if species.replace(" ", "") == "":
            return render(request, "error_page.html", {"errors": ['Species can\'t be empty']})
        else:
            species = species.replace(" ", "_")
            os.system(
                'qsub -v pipeline="helper",mode="trna",key="' + pipeline_id + '",outdir="' + FS.location +
                '",species="' + species + '",name="' + pipeline_id + '_h_trna' + '" -N ' + pipeline_id +
                '_h_trna /shared/sRNAtoolbox/core/bash_scripts/run_helper_trna.sh')


    #return redirect("/srnatoolbox/jobstatus/helper/?id=" + pipeline_id)
    return redirect("/srnatoolbox_dev/")
Ejemplo n.º 14
0
def run(request):
    """
    :rtype : redirect
    :param request: posts and gets
    :return: redirect to results
    """
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)
    fdw = file(FS.location + "/error.txt", "w")
    annotations = ["go"]
    go_table = request.POST["db_table"]
    """
    if "go" in request.POST:
        annotations.append("go")
    if "kegg" in request.POST:
        annotations.append("kegg")
    if "biocyc" in request.POST:
        annotations.append("biocyc")"""
    outdir = FS.location
    exp = "false"

    if "exp" in request.POST:
        exp = "true"

    if "list" in request.FILES:
        # Upload file
        file_to_update = request.FILES['list']
        uploaded_file = str(file_to_update)
        FS.save(uploaded_file, file_to_update)
        mir_list = os.path.join(FS.location, uploaded_file)

        if not istext(mir_list):
            return render(
                request, "error_page.html",
                {"errors": ["miRNA list file should be a text file"]})

    elif request.POST["id"] != "":

        try:
            new_record = JobStatus.objects.get(pipeline_key=request.POST["id"])
        except:
            return render(
                request, "error_page.html", {
                    "errors": [
                        "Job with ID: " + request.POST["id"] +
                        " does not exist."
                    ]
                })

        mirna_file = os.path.join("/shared/sRNAtoolbox/webData",
                                  request.POST["id"], "miRBase_main.txt")

        if os.path.isfile(mirna_file):
            fd = file(mirna_file)
            mir_list = os.path.join(FS.location,
                                    "top_10_" + os.path.basename(mirna_file))
            fdw = file(mir_list, "w")
            fd.readline()
            i = 0

            while i < 10:
                fdw.write(fd.readline().split("\t")[0] + "\n")
                i += 1

        else:
            return render(
                request, "error_page.html", {
                    "errors": [
                        "Job with ID: " + request.POST["id"] +
                        " has not the appropriate results to launch sRNAFuncterms"
                    ]
                })

    elif request.POST["de_id"] != "":
        try:
            new_record = JobStatus.objects.get(
                pipeline_key=request.POST["de_id"])
        except:
            return render(
                request, "error_page.html", {
                    "errors": [
                        "Job with ID: " + request.POST["de_id"] +
                        " does not exist."
                    ]
                })

        assert isinstance(new_record, JobStatus)

        all_consensus = []

        if new_record.job_status == "Finished":

            for xls in new_record.xls_files:
                workbook = xlrd.open_workbook(xls)
                names = workbook.sheet_names()
                Selection = [name for name in names if "Selection" in name]

                if Selection > 0:
                    parser = SRNAdeParser(xls, "none")
                    list_d = [obj for obj in parser.get_consensus(*Selection)]
                    all_consensus = all_consensus + list_d

            mir_list = os.path.join(
                FS.location, "differential_expression_mirna_all_condition.txt")

            fdw = file(mir_list, "w")

            for consensus in all_consensus:
                fdw.write(consensus.miRNA_Name + "\n")
            fdw.close()

        else:
            return render(
                request, "error_page.html", {
                    "errors": [
                        "Job with ID: " + request.POST["de_id"] +
                        " has not the appropriate results to launch sRNAFuncterms"
                    ]
                })

    else:
        return render(
            request, "error_page.html", {
                "errors": [
                    "sRNAde ID, sRNAbench ID or miRNA list file should be provided"
                ]
            })

    # call qsub
    fdw.write(
        'qsub -v pipeline="functerms",annot="' + ",".join(annotations) +
        '",outdir="' + outdir + '",go_table="' + go_table + '",exp="' + exp +
        '",key="' + pipeline_id + '",name="' + pipeline_id +
        '_functerms",input="' + mir_list + '",type="list"  -N ' + pipeline_id +
        '_functerms /shared/sRNAtoolbox/core/bash_scripts/run_sRNAfuncterms.sh'
    )
    os.system(
        'qsub -v pipeline="functerms",annot="' + ",".join(annotations) +
        '",outdir="' + outdir + '",go_table="' + go_table + '",exp="' + exp +
        '",key="' + pipeline_id + '",name="' + pipeline_id +
        '_functerms",input="' + mir_list + '",type="list"  -N ' + pipeline_id +
        '_functerms /shared/sRNAtoolbox/core/bash_scripts/run_sRNAfuncterms.sh'
    )

    return redirect("/srnatoolbox/jobstatus/srnafuncterms/?id=" + pipeline_id)
Ejemplo n.º 15
0
def test(request):
    pipeline_id = pipeline_utils.generate_uniq_id()
    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)

    libs_files = []
    lib_mode = False
    no_libs = False
    guess_adapter = None
    recursive_adapter_trimming = None
    high_conf = False
    solid = None
    ifile = "/shared/sRNAtoolbox/testData/IK_exo.fastq.gz"

    adapter = "TGGAATTCTCGGGTGCCAAGG"
    species = ["hg19_5_mp", "NC_007605"]
    assemblies = ["hg19", "NC_007605"]
    mircro_names = ["hsa", "ebv"]

    mir = ":".join(mircro_names)
    homolog = ""

    adapter_minLength = "10"
    adapterMM = "1"

    outdir = FS.location

    rc = "2"
    mm = "0"
    seed = "20"
    align_type = "n"
    remove_barcode = "0"

    species_annotation_file = SpeciesAnnotationParser(SPECIES_ANNOTATION_PATH)
    species_annotation = species_annotation_file.parse()

    newConf = SRNABenchConfig(
        species_annotation,
        DB,
        FS.location,
        ifile,
        iszip="true",
        RNAfold="RNAfold2",
        bedGraph="true",
        writeGenomeDist="true",
        predict="true",
        graphics="true",
        species=species,
        assembly=assemblies,
        adapter=adapter,
        recursiveAdapterTrimming=recursive_adapter_trimming,
        libmode=lib_mode,
        nolib=no_libs,
        microRNA=mir,
        removeBarcode=str(remove_barcode),
        adapterMinLength=str(adapter_minLength),
        adapterMM=str(adapterMM),
        seed=str(seed),
        noMM=str(mm),
        alignType=str(align_type),
        rc=str(rc),
        solid=solid,
        guessAdapter=guess_adapter,
        highconf=high_conf,
        homolog=homolog,
        user_files=libs_files)

    conf_file_location = os.path.join(FS.location, "conf.txt")
    newConf.write_conf_file(conf_file_location)

    os.system(
        'qsub -v pipeline="bench",configure="' + conf_file_location +
        '",key="' + pipeline_id + '",outdir="' + outdir + '",name="' +
        pipeline_id + '_sRNAbench' + '" -N ' + pipeline_id +
        '_sRNAbench /shared/sRNAtoolbox/core/bash_scripts/run_sRNAbench.sh')

    return redirect("/srnatoolbox/jobstatus/srnabench/?id=" + pipeline_id)
Ejemplo n.º 16
0
def run(request):
    libs_files = []
    pipeline_id = pipeline_utils.generate_uniq_id()
    lib_mode = False
    no_libs = False
    species = []
    assemblies = []
    guess_adapter = None
    recursive_adapter_trimming = None
    high_conf = False
    solid = None
    ifile = ""
    mircro_names = []
    name_modifier = None

    FS.location = os.path.join("/shared/sRNAtoolbox/webData", pipeline_id)
    make_dir(FS.location)

    if len(request.POST["job_name"].replace(" ", "")) > 1:
        name_modifier = request.POST["job_name"].replace(" ", "")

    if "reads_file" in request.FILES:
        file_to_update = request.FILES['reads_file']

        extension = ".".join(str(file_to_update).split(".")[1:])

        if extension not in [
                "fastq", "fa", "rc", "fastq.gz", "fa.gz", "rc.gz", "txt",
                "txt.gz", "sra"
        ]:
            return render(
                request, "error_page.html", {
                    "errors": [
                        'Reads file extension must be: "fastq", "fa", "rc", "rc.gz", "fa.gz", "fastq.gz" , "txt", "txt.gz", "sra". We have detected: '
                        + extension +
                        ' please use one of the supported formats'
                    ]
                })

        if name_modifier is not None:
            uploaded_file = str(name_modifier) + "." + extension
        else:
            uploaded_file = str(file_to_update).replace(" ", "")
        FS.save(uploaded_file, file_to_update)
        ifile = os.path.join(FS.location, uploaded_file)

    elif request.POST["reads_url"].replace(" ", "") != "":
        url_input = request.POST["reads_url"]

        extension = ".".join(os.path.basename(url_input).split(".")[1:])

        if extension not in [
                "fastq", "fa", "rc", "fastq.gz", "fa.gz", "rc.gz", "txt",
                "txt.gz", "sra"
        ]:
            return render(
                request, "error_page.html", {
                    "errors": [
                        'Reads file extension must be: "fastq", "fa", "rc", "rc.gz", "fa.gz", "fastq.gz", "txt", "txt.gz", "sra"  ".'
                        + extension + '" found'
                    ]
                })

        if name_modifier is not None:
            dest = os.path.join(FS.location,
                                str(name_modifier) + "." + extension).replace(
                                    " ", "")
        else:
            dest = os.path.join(FS.location, os.path.basename(url_input))

        handler = urllib.URLopener()
        handler.retrieve(url_input, dest)
        ifile = dest

    else:
        return render(request, "error_page.html",
                      {"errors": ["Read File or URL must be provided"]})

    if "user_files" in request.FILES:
        for i, afile in enumerate(request.FILES.getlist("user_files")):
            file_to_update = afile
            uploaded_file = str(file_to_update).replace(" ", "")
            FS.save(uploaded_file, file_to_update)
            libs_files.append(os.path.join(FS.location, uploaded_file))

    if "user_urls" in request.POST:
        for i, url in enumerate(request.POST.getlist("user_urls")):
            if url != "":
                libfile = urllib.URLopener()
                dest = os.path.join(FS.location,
                                    os.path.basename(url)).replace(" ", "")
                libfile.retrieve(url, dest)
                libs_files.append(dest)

    if "libMode" in request.POST:
        lib_mode = True

    if "noLibs" in request.POST:
        no_libs = True

    for specie in request.POST.getlist("species"):
        if specie != "":
            species.append(specie.split(":")[2])
            assemblies.append(specie.split(":")[1])
            mircro_names.append(specie.split(":")[0])

    if "guessAdapter" in request.POST:
        guess_adapter = "true"

    adapter = request.POST["adapter"]
    alter_adapter = request.POST["alterAdapter"].upper().replace(" ", "")

    if len(alter_adapter) > 1:
        adapter = alter_adapter
    if adapter == "XXX":
        adapter = None

    adapter_minLength = request.POST["adapterMinLength"]
    adapterMM = request.POST["adapterMM"]

    if "recursiveAdapterTrimming" in request.POST:
        recursive_adapter_trimming = "true"

    if "highconf" in request.POST:
        high_conf = True

    mir = request.POST["miR"]
    homolog = request.POST["homolog"]

    if len(homolog) < 1:
        homolog = None

    if "genomeMiR" in request.POST:
        mir = ":".join(mircro_names)

    if "solid" in request.POST:
        solid = "true"

    rc = request.POST["rc"]
    mm = request.POST["mm"]
    seed = request.POST["seed"]
    align_type = request.POST["alignType"]
    remove_barcode = request.POST["removeBarcode"]
    minReadLength = request.POST["minReadLength"]
    mBowtie = request.POST["mBowtie"]

    if "predict" in request.POST:
        predict = "true"
    else:
        predict = None

    species_annotation_file = SpeciesAnnotationParser(SPECIES_ANNOTATION_PATH)
    species_annotation = species_annotation_file.parse()

    newConf = SRNABenchConfig(
        species_annotation,
        DB,
        FS.location,
        ifile,
        iszip="true",
        RNAfold="RNAfold2",
        bedGraph="true",
        writeGenomeDist="true",
        predict=predict,
        graphics="true",
        species=species,
        assembly=assemblies,
        short_names=mircro_names,
        adapter=adapter,
        recursiveAdapterTrimming=recursive_adapter_trimming,
        libmode=lib_mode,
        nolib=no_libs,
        microRNA=mir,
        removeBarcode=str(remove_barcode),
        adapterMinLength=str(adapter_minLength),
        adapterMM=str(adapterMM),
        seed=str(seed),
        noMM=str(mm),
        alignType=str(align_type),
        minRC=str(rc),
        solid=solid,
        guessAdapter=guess_adapter,
        highconf=high_conf,
        homolog=homolog,
        user_files=libs_files,
        minReadLength=minReadLength,
        mBowtie=mBowtie)

    conf_file_location = os.path.join(FS.location, "conf.txt")
    newConf.write_conf_file(conf_file_location)

    os.system(
        'qsub -v pipeline="bench",configure="' + conf_file_location +
        '",key="' + pipeline_id + '",outdir="' + FS.location + '",name="' +
        pipeline_id + '_sRNAbench' + '" -N ' + pipeline_id +
        '_sRNAbench /shared/sRNAtoolbox/core/bash_scripts/run_sRNAbench.sh')

    return redirect("/srnatoolbox/jobstatus/srnabench/?id=" + pipeline_id)