def main(): ''' main method for the commandline interface of the circ_combination module ''' print('Program call:') print(' '.join(sys.argv)) _, o = get_command_line_options() create_output_dirs(o) t_start = wutils.get_current_time() print(t_start[1] + 'Start Combination of circRNA predictions') algo_circ_combination.combine_circular_rna(o.inCircs1, o.inCircs2, o.outIntersection, o.outUnion, o.outIntersectedUnion, o.minReads) t_end = wutils.get_current_time() print(t_end[1] + 'Finished. Check out the results in ' + o.outIntersection + ', ' + o.outIntersection + ' and ' + o.outIntersectedUnion) wutils.print_resources(t_end[0] - t_start[0], child_processes=False) if (o.returnFilePath is not None): returnVars = [('circIntersection', o.outIntersection), ('circUnion', o.outUnion), ('circIntersectedUnion', o.outIntersectedUnion)] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
def main(): ''' main method for running phantompeakqualtools as watchdog module ''' # print command print('Program call:') print(' '.join(sys.argv) + '\n') # check options and prepare output location _, o = get_command_line_options() paths = create_outfiles(o) # log start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Welcome to the module for running phantompeakqualtools!\n') # run the external program call_phantom_peak_script(o.inBam, paths[0], paths[1], paths[2], o.sppPath, o.rscriptPath, o.tmpdir, o.threads) # log end_timepoint = wutils.get_current_time() print(end_timepoint[1] + 'Module finished successfully!\n-> check out the results:\n' + '\n'.join(paths)) wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=True)
def main(): ''' main method for running the bwa aln wrapper as watchdog module ''' # check options and prepare output locations _, o = get_command_line_options() create_outfiles(o) # log start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Welcome to the module for running bwa sampe !\n') # print command print('Program call:') print(' '.join(sys.argv) + '\n') # run the main program run_bwa_sampe(o.bwaIndex, o.inReads1, o.inReads2, o.inSai1, o.inSai2, o.outSam, o.bwaPath, o.indexInRam) # log end_timepoint = wutils.get_current_time() print(end_timepoint[1] + 'Module finished successfully!\n-> check out \'' + o.outSam + '\' for the output of bwa aln') wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=True) # write return file for watchdog if (o.returnFilePath is not None): returnVars = [('bwaPairedSamFile', o.outSam)] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
def main(): ''' main method for converting bam -> bigwig using the watchdog module ''' # check options and prepare output location _, o = get_command_line_options() create_outfiles(o) # log start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Welcome to the module for converting bam to bigwig format !\n') # print command print('Program call:') print(' '.join(sys.argv) + '\n') # run the main program run_bam_coverage(o.inBam, o.outBw, o.binSize, o.numberOfProcessors, o.bamCoveragePath) # log end_timepoint = wutils.get_current_time() print( end_timepoint[1] + 'Module finished successfully!\n-> the bigwig file is located at \'' + o.outBw + '\'') wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=True) # write return file for watchdog if (o.returnFilePath is not None): returnVars = [('bigWigFile', o.outBw)] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
def main(): ''' main method for converting bam to bedgraph and tdf ''' # print command print('Program call:') print(' '.join(sys.argv)+'\n') # check options and prepare output location p,o = get_command_line_options() create_tdf = check_option_interactions(p,o) bedgraph_out, tdf_out = create_outfiles(o) # log start_timepoint=wutils.get_current_time() print(start_timepoint[1]+'Welcome to the genomeCoverage Module!\n') # perform conversion bam -> bedgraph -> tdf bam_to_bedgraph(o.bam, bedgraph_out, bedtools_exec=o.bedtoolsPath) if create_tdf: bedgraph_to_tdf(bedgraph_out, o.genome, tdf_out, igvtools_exec=o.igvtoolsPath) # log end_timepoint=wutils.get_current_time() print(end_timepoint[1]+'Module finished successfully!') if create_tdf: print('-> the tdf file is located at \''+tdf_out+'\'') else: print('-> the bedgraph file is located at \''+bedgraph_out+'\'') wutils.print_resources(end_timepoint[0]-start_timepoint[0], child_processes=True)
def main(): ''' main method for running the module''' # print command print('Program call:') print(' '.join(sys.argv) + '\n') # check options and prepare output locations _, o = get_command_line_options() re_unmapped, re_imppairs, qual_cut, hit_cut, single_end = process_option_interactions( o) check_input_file(o) create_outfiles(o) # log start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Welcome to the module for fitlering the output of bwa sampe !\n') algo_filter_bwa_sampe.remove_reads(o.inSamBam, o.outSamBam, re_unmapped, re_imppairs, qual_cut, hit_cut, single_end) # log end_timepoint = wutils.get_current_time() print(end_timepoint[1] + 'Module finished successfully!\n-> check out \'' + o.outSamBam + '\' with the filtered read pairs') wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=False) # write return file for watchdog if (o.returnFilePath is not None): returnVars = [('filteredPairs', o.outSamBam)] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
def main(): ''' main method running the command line interface ''' print('Program call:') print(' '.join(sys.argv)) # parse command line p, o = get_command_line_options() check_inputfiles(p, o) get_and_create_outfiles(o) start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Starting CIRI2 wrapper...') # run BWA if (o.inSAM is None): # get index for BWA if (o.bwaIndex is None): index_prefix = o.outPrefix + 'bwaIndex' runner.buildIndex(o.reference, index_prefix, o.bwaPath) else: index_prefix = o.bwaIndex # call bwa mem bwa_sam_file = o.outPrefix + 'bwa.sam' runner.runBWA(o.inReads1, o.inReads2, index_prefix, bwa_sam_file, o.bwaThreads, o.bwaPath, o.bwaSeedSize, o.bwaScoreThreshold) else: bwa_sam_file = o.inSAM # run CIRI ciri_raw_output = o.outPrefix + 'rawPred.txt' runner.runCIRI2(bwa_sam_file, ciri_raw_output, o.reference, o.ciriAnnotation, o.ciriThreads, o.ciriPath, o.ciriStringency, o.ciriKeepTmpFiles) # create the final output if (o.outCirc is None): final_output_file = o.outPrefix + 'ciriCirc.txt' else: final_output_file = o.outCirc runner.writeOutput(ciri_raw_output, final_output_file) end_timepoint = wutils.get_current_time() print(end_timepoint[1] + 'CIRI2 finished, check out \'' + final_output_file + '\' for the results') # output resources consumed by the script wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=True) # write watchdog return variables if (o.returnFilePath is not None): wutils.write_watchdog_return_file(o.returnFilePath, [('ciriCircs', final_output_file)])
def main(): ''' main method for running the watchdog module for calculation of readout in recount data ''' # print command print('Program call:') print(' '.join(sys.argv) + '\n') # check options and prepare output location _, o = get_command_line_options() remove_tmp_sample, remove_tmp_proj, parallel_down = resolve_booleans(o) check_gene_tsv(o) proj_list = get_project_list(o) # log start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Welcome to the module for calculating readout from recount !\n') # iterate over all projects for projID in proj_list: proj_timepoint = wutils.get_current_time() print(proj_timepoint[1] + 'Processing project ' + projID) # create output and tmp folder for the current project res_folder, tmp_folder = create_outfolders(o, projID) # run the R code if possible try: run_Rscript_recount(projID, o.geneTSV, res_folder, tmp_folder, o.threads, remove_tmp_sample, parallel_down, o.localRecountFolder, o.Rscript) except subprocess.CalledProcessError: sys.stderr.write('An error occurred in the R script \n') raise # clean up temporary data finally: remove_tmp_data(remove_tmp_sample, remove_tmp_proj, res_folder, tmp_folder) # log end_timepoint = wutils.get_current_time() print( end_timepoint[1] + 'Module finished successfully!\n-> the readout data is located at \'' + o.outfolder + '\'') wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=True)
def main(): ''' main method for calling removeLinearReads from commandline ''' print('Program call:') print(' '.join(sys.argv)) _,o = get_command_line_options() wutils.make_parent_dirs(o.circOut) t_start = wutils.get_current_time() print(t_start[1]+'Start Removal of Linearly Mappable Reads') algo.remove_linearly_mappable_reads(o.circRNAPrediction, o.mapping, o.circOut, o.minReads, o.paired) t_end = wutils.get_current_time() print(t_end[1]+'Finished. Check out the results in '+o.circOut) wutils.print_resources(t_end[0]-t_start[0], child_processes=False) if(o.returnFilePath is not None): returnVars = [('filteredCircs', o.circOut)] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
def main(): ''' main method for converting bam -> bed using the watchdog module ''' # check options and prepare output location _, o = get_command_line_options() create_outfiles(o) # log start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Welcome to the module for converting bam to bed format !\n') # print command print('Program call:') print(' '.join(sys.argv) + '\n') # run the main program split_spliced = True if o.nosplit: split_spliced = False run_bedtools_bamtobed(bam_file=o.inBam, bed_file=o.outBed, bedtools_path=o.bedtoolsPath, split=split_spliced) # log end_timepoint = wutils.get_current_time() print(end_timepoint[1] + 'Module finished successfully!\n-> the bed file is located at \'' + o.outBed + '\'') wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=True) # write return file for watchdog if (o.returnFilePath is not None): returnVars = [('bedFile', o.outBed)] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
def main(): ''' main function calling the rrna filter ''' # print command print('Program call:') print(' '.join(sys.argv)+'\n') # check options and prepare output locations p,o = get_command_line_options() check_input_files(p,o) create_outfiles(o) # log start_timepoint=wutils.get_current_time() print(start_timepoint[1]+'Welcome to the rRNA filter module!\n') # run the main program rrna_filter_algo.runFilter.run(in1=o.in1, in2=o.in2, rrnaIndex=o.rrnaIndex, workdir=o.workdir, out1=o.out1, out2=o.out2, sam=o.sam, seedSize=o.seedSize, threads = o.threads, maxEditDistance=o.maxEditDistance, maxMismatches=o.maxMismatches, maxIndels=o.maxIndels, pairFiltering=o.pairFiltering, bwapath=o.bwaPath, keeptmp=o.keepTmp) # log end_timepoint=wutils.get_current_time() res_files = o.out1 if(o.out2 is not None): res_files+= ', '+o.out2 print(end_timepoint[1]+'Module finished successfully!\n-> check out \''+res_files+'\' for the non-rRNA reads') wutils.print_resources(end_timepoint[0]-start_timepoint[0], child_processes=True) # write return file for watchdog if(o.returnFilePath is not None): returnVars = [('rrnaSAMFile', o.sam), ('filteredFQ1', o.out1)] if(o.out2 is None): returnVars.append(('filteredFQ2', 'not_defined_for_single_end')) else: returnVars.append(('filteredFQ2', o.out2)) wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
def main(): ''' main method for the commandline interface of the circrna_finder module ''' print('Program call:') print(' '.join(sys.argv)) # handle command line options p, o = get_command_line_options() check_inputfiles(p, o) get_and_create_outfiles(o) start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Starting circRNA_finder wrapper') # call STAR if (o.inSTAR is None): # build STAR index if (o.starIndex is None): index_location = o.outPrefix + 'star_index' os.mkdir(index_location) run_circrna_finder.build_STAR_index(o.reference, index_location, star_path=o.starPath, star_thread_nr=o.starThreads) else: index_location = o.starIndex # map reads with STAR star_file_prefix = o.outPrefix run_circrna_finder.map_with_STAR(o.inReads1, o.inReads2, index_location, star_file_prefix, star_path=o.starPath, star_thread_nr=o.starThreads) else: star_file_prefix = o.inSTAR # call circRNA_finder run_circrna_finder.run_circRNA_finder(star_file_prefix, o.outPrefix, circRNA_finder_path=o.cfPath) # create final output file if (o.outCirc is None): final_file = o.outPrefix + 'cfCirc.txt' else: final_file = o.outCirc run_circrna_finder.annotate_and_wirte_output(o.outPrefix, star_file_prefix, final_file, o.strandedLibrary) end_timepoint = wutils.get_current_time() print(end_timepoint[1] + 'circRNA_finder finished, check out \'' + final_file + '\' for the results') # output resources wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=True) # write watchdog return variables if (o.returnFilePath is not None): wutils.write_watchdog_return_file(o.returnFilePath, [('cfCircs', final_file)])
# start of execution start_timepoint = wutils.get_current_time() print(start_timepoint[1] + 'Starting trimmedFastqPairFilter module...') print('Input:') print(inpaths) print('Output:') print(outpaths) algo_trimmedFastqPairFilter.filterFastqs(inpaths[0], inpaths[1], outpaths[0], outpaths[1], outpaths[2]) # end of execution end_timepoint = wutils.get_current_time() print(end_timepoint[1] + 'trimmedFastqPairFilter module finished, check out \'' + ','.join(outpaths) + '\' for the results') # output resources consumed by the script wutils.print_resources(end_timepoint[0] - start_timepoint[0], child_processes=False) # write return variables if (o.returnFilePath is not None): returnVars = [('pairedReads1', outpaths[0]), ('pairedReads2', outpaths[1]), ('singletonReads', outpaths[2])] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)
cmdl_options = parser.parse_args() return parser, cmdl_options def create_output_dirs(cmdl_options): ''' create parent directories of concatenated output file ''' wutils.make_parent_dirs(cmdl_options.outFile) if __name__ == '__main__': print('Program call:') print(' '.join(sys.argv)) p, o = get_command_line_options() create_output_dirs(o) t_start = wutils.get_current_time() print(t_start[1] + 'Welcome! Concatenation of files in progress...') algo_concatenate.concatenate_files(o.inFile, o.outFile) t_end = wutils.get_current_time() print(t_end[1] + 'Finished. Check out the results in ' + o.outFile) wutils.print_resources(t_end[0] - t_start[0], child_processes=False) if (o.returnFilePath is not None): returnVars = [('concatenatedFile', o.outFile)] wutils.write_watchdog_return_file(o.returnFilePath, returnVars)