Exemple #1
0
def test_bbduk():
    bd = qc.BBmap()
    bdOpts = {
        "in": fq1,
        "in2": fq2,
        "out": testVars.testDir + "/bdo1.fq",
        "out2": testVars.testDir + "/bdo2.fq"
    }
    st = bd.run_bbduk(**bdOpts)
    assert st == True, "BBDUK failed"
Exemple #2
0
def test_bbsplit():
    bs = qc.BBmap()
    #build index
    bsOpts = {"ref_x": rRNAfasta, "path": testVars.testDir}
    st = bs.run_bbsplit(**bsOpts)
    assert st == True, "BBSplit index failes"

    #run split
    bsOpts = {
        "in1": fq1,
        "in2": fq2,
        "outu1": testVars.testDir + "/bso1.fq",
        "outu2": testVars.testDir + "/bso2.fq",
        "path": testVars.testDir
    }
    st == bs.run_bbsplit(**bsOpts)
    assert st == True, "BBSplit failed"
Exemple #3
0
def test_pipeline1():
    sraOb = sra.SRA(srr, workingDir)
    st = sraOb.download_sra()
    assert st == True, "SRA download failed"

    st = sraOb.run_fasterqdump(delete_sra=False,
                               **{
                                   "-e": "8",
                                   "-f": "",
                                   "-t": workingDir
                               })
    assert st == True, "fqdump failed"

    bbdOpts = {
        "ktrim": "r",
        "k": "23",
        "mink": "11",
        "qtrim": "'rl'",
        "trimq": "10",
        "--": ("-Xmx2g", ),
        "ref": testVars.bbdukAdapters
    }
    bbdOb = qc.BBmap(**bbdOpts)
    st = sraOb.perform_qc(bbdOb)
    assert st == True, "bbduk failed"

    tgOpts = {
        "--cores": "10",
        "-o": testVars.testDir,
        "--paired": "",
        "--": (fq1, fq2)
    }
    tg = qc.Trimgalore(**tgOpts)
    st = sraOb.perform_qc(tg)
    assert st == True, "tg failed"

    #runbowtie2
    bt = mapping.Bowtie2(bowtie2_index="")
    assert bt.check_index() == False, "Failed bowtie2 check_index"
    st = bt.build_index(testVars.testDir + "/btIndex", "bowtieIndex",
                        testVars.genome)
    assert st == True, "Failed to build bowtie2 index"
    st = bt.perform_alignment(sraOb)
    assert os.path.isfile(st) == True, "bowtie failed"

    hsOpts = {"--dta-cufflinks": "", "-p": "8"}
    hs = mapping.Hisat2(hisat2_index="", **hsOpts)
    st = hs.build_index(testVars.testDir, "hisatindex", testVars.genome)
    assert st == True, "Failed to build hisat2 index"
    #perform alignment with sraobject
    st = hs.perform_alignment(sraOb)
    assert os.path.isfile(st) == True, "hisat failed"

    hisatSam = st
    samOb = tools.Samtools(**{"-@": "8"})
    bam = samOb.sam_sorted_bam(hisatSam, delete_sam=False, delete_bam=False)
    assert os.path.isfile(bam) == True, "sam to bam failed"

    stie = assembly.Stringtie(reference_gtf=testVars.gtf)
    result = stie.perform_assembly(bam, out_dir=testVars.testDir)
    assert pu.check_files_exist(result) == True, "Failed stringtie"

    tr = assembly.Trinity()
    tr_out = tr.perform_assembly(sraOb, verbose=True)
    assert pu.check_files_exist(tr_out) == True, "Failed stringtie"

    kl = quant.Kallisto(kallisto_index="")
    assert kl.check_index() == False, "Failed kallisto check_index"
    st = kl.build_index(index_path=testVars.testDir + "/kallistoIndex",
                        index_name="kalIndex",
                        fasta=testVars.cdna)
    assert st == True, "Failed to build kallisto index"
    st = kl.perform_quant(sraOb)
    assert os.path.isdir(st) == True, "Failed to run kallisto"

    sl = quant.Salmon(salmon_index="")
    assert sl.check_index() == False, "Failed salmon check_index"
    st = sl.build_index(index_path=testVars.testDir + "/salmonIndex",
                        index_name="salIndex",
                        fasta=testVars.cdna)
    assert st == True, "Failed to build salmon index"

    st = sl.perform_quant(sraOb)
    assert os.path.isdir(st) == True, "Failed to run salmon"
Exemple #4
0
print("Following runs downloaded:")
for ob in sraObjects:
    print(ob.srr_accession)

pathToAdapters = "adapters2.fa"
bbdOpts = {
    "ktrim": "r",
    "k": "23",
    "mink": "11",
    "qtrim": "'rl'",
    "trimq": "10",
    "--": ("-Xmx2g", ),
    "ref": pathToAdapters
}
bbdOb = qc.BBmap(**bbdOpts)
for ob in sraObjects:
    ob.perform_qc(bbdOb)

for ob in sraObjects:
    print("SRR Accession: {}, fastq files: {}. {}".format(
        ob.srr_accession, ob.localfastq1Path, ob.localfastq2Path))

    if ob.fastqFilesExistsLocally():
        print("Both files exist!!")
    else:
        print("Error")
        raise Exception("Fastq files not found")

hsOpts = {"--dta-cufflinks": "", "-p": "16"}
hs = mapping.Hisat2(hisat2_index="", **hsOpts)
Exemple #5
0
#new tests
# test samtools
sam=testDir+"/test_files/athaliana/mapping/hisat2.sam"
sm=tools.Samtools(threads=5)
bam1=sm.sam_to_bam(sam,out_suffix="test2",threads=3, delete_sam=False,verbose=True,quiet=False,logs=True,objectid="NA",**{"-@":"4"})
print(bam1)
bam2=sm.sort_bam(bam1,out_suffix="test2",threads=2,delete_bam=False,verbose=True,quiet=False,logs=True,objectid="NA")
print(bam2)
#bam=sm.sam_sorted_bam(sam,delete_sam=False,delete_bam=False)

txd=tools.Transdecoder()
infa="/Users/usingh/work/urmi/tests/txd/test.fa"
outdir=txd.run_transdecoder_longorfs(infa,out_dir="/Users/usingh/work/urmi/tests/txd/mtout1")
print(outdir)

poutdir="/Users/usingh/work/urmi/tests/txd/mypredout"
predout=txd.run_transdecoder_predict(infa,longorfs_dir=outdir,out_dir=poutdir)
print(predout)


newSRA=sra.SRA('SRR5507343',testDir)
newSRA.download_fastq()
#run trimgalore
tg=qc.Trimgalore(threads=4)  #specify to use 8 cores
bd=qc.BBmap(threads=4,max_memory=1)

newSRA.perform_qc(bd)
#newSRA.perform_qc(tg)


Exemple #6
0
f = open('pyrpipe_conf.yaml', 'w')
f.write('dry: true\n')
f.write('threads: 1\n')
f.write('safe: true\n')
f.close()

#create objects
bbdOpts = {
    "ktrim": "r",
    "k": "23",
    "mink": "11",
    "qtrim": "'rl'",
    "trimq": "10",
    "ref": testVars.bbdukAdapters
}
bbdOb = qc.BBmap(None, **bbdOpts)
tg = qc.Trimgalore()
bt = mapping.Bowtie2(index=testVars.testDir + "/btIndex",
                     genome=testVars.genome)
hsOpts = {"--dta-cufflinks": "", "-p": "8"}
hs = mapping.Hisat2(index=testVars.testDir + "/hisatindex",
                    genome=testVars.genome,
                    **hsOpts)
star = mapping.Star(index=os.path.join(testVars.testDir, "starIndex"),
                    genome=testVars.genome)
samOb = tools.Samtools()
stie = assembly.Stringtie()
kl = quant.Kallisto(index=testVars.testDir + "/kallistoIndex/kalIndex",
                    transcriptome=testVars.cdna)
sl = quant.Salmon(index=testVars.testDir + "/salmonIndex/salIndex",
                  transcriptome=testVars.cdna_big)