def test_stringtie(): bam = testVars.hisatSortedBam gtf = testVars.gtf stie = assembly.Stringtie(reference_gtf=gtf) result = stie.perform_assembly(bam, out_dir=testVars.testDir, objectid="test") assert pu.check_files_exist(result) == True, "Failed stringtie"
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"
samOb = tools.Samtools(**{"-@": "16"}) bamList = [] i = 0 for sam in samList: print("Processing:" + sam) thisBam = samOb.sam_sorted_bam(sam, delete_sam=True, delete_bam=True, objectid=sraObjects[i].srr_accession) i += 1 if thisBam: bamList.append(thisBam) print("Sorted bam files:" + ",".join(bamList)) st = assembly.Stringtie() gtfList = [] i = 0 for bam in bamList: print("Processing:" + bam) gtfList.append( st.perform_assembly(bam, objectid=sraObjects[i].srr_accession, **{ "-m": "150", "-p": "16" })) i += 1 print("Final GTFs:" + ",".join(gtfList))
"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) #sra ob sraOb = sra.SRA(srr, workingDir) st = sraOb.fastq_exists() assert st == True, "fasterq-dump failed" def test_pipeline1(): st = sraOb.trim(bbdOb).align(hs).assemble(stie).quant(kl) assert st != None, "pipeline 1 failed"
idsfile = sys.argv[1] analysis = sys.argv[2] runquant = False runalign = False if analysis == 'quant': runquant = True if analysis == 'align': runalign = True with open(idsfile) as f: data = f.read().splitlines() #set infile dir as workdir basedir = pu.get_file_directory(idsfile) #pyrpipe objects star = mapping.Star() #Create stringtie object stieobj = assembly.Stringtie() #biobambam biobb = Bamtofastq() #salmon for quant salmon = quant.Salmon() #delete final sorted bam delete_bam = True #out_dir is same name as input file out_dir = basedir progresslog = open(idsfile + '_progress.log', 'w') bam_suffix = '.Aligned.sortedByCoord.out.patched.md.bam' #process each bam for line in data: temp = line.split('\t')
#if hs.buildHisat2Index("/home/usingh/work/urmi/hoap/test/yeastInd2","index22","/home/usingh/work/urmi/hoap/test/hisatYeast/S288C_reference_genome_R64-2-1_20150113/S288C_reference_sequence_R64-2-1_20150113.fsa",**hsbArgs): # print("Success") #run hisat sam=hs.perform_alignment(sraOb,**{"--dta-cufflinks":"","-p":"8"}) #get sorted bam samOb=tools.Samtools(**{"-@":"8"}) bam=samOb.sam_sorted_bam(sam,delete_sam=True,delete_bam=True) #bt2=mapping.Bowtie2("/home/usingh/work/urmi/hoap/test/bowtieIndex/rRNAindex") #bt2.performAlignment(sraOb) #run stringtie st=assembly.Stringtie() g1=st.perform_assembly(bam,objectid="myob") #gtfs=(g1,) #test stmerge #merged=st.performStringtieMerge(g1,g1,outFileSuffix="_stOUT",overwrite=True) #if not merged: # print("Fail") """ bamList=[] sraObList=[] for s in ['SRR5507495','SRR5507442','SRR5507362']: sraOb=sra.SRA(s,testDir) #download sra sraOb.downloadSRAFile()