def main(): #initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser=_prepare_optparser() (options,args) = optparser.parse_args() #verify options arg_pass=_verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if options.debug: utils_logging.init_logging(logging.DEBUG) utils_logging.init_logging(output_level=None, log_file_name=os.path.join(options.output_dir,"extract_and_assemble.log")) bam_files=[options.bam_files] if len(args)>0: bam_files.extend(args) all_assembler_to_try = options.assembler_name.split(',') assembly_function_list=[] for assembler_name in all_assembler_to_try: assembly_function=RAD_assemble_read2.get_assembly_function(assembler_name) assembly_function_list.append(assembly_function) command_runner.set_command_to_run_localy() if options.rg_ids: rg_ids=options.rg_ids.split() else: rg_ids=[] extract_and_assemble(bam_files, options.read1_consensus_file, options.white_list_file, options.output_dir, assembly_function_list, subsample_nb_read=options.subsample_nb_read, rg_ids=rg_ids, adapter_file=options.adapter_file)
def main(): # initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if options.debug: utils_logging.init_logging(logging.DEBUG) bam_files = [options.bam_file] if len(args) > 0: bam_files.extend(args) command_runner.set_command_to_run_localy() if options.output_dir: list_consensus = read_white_list(options.white_list_file) extract_reads_from_all_bam_files_set_of_consensus(bam_files, list_consensus, options.output_dir, genome_loader=None, all_read1_consensus_file=options.read1_consensus_file) else: iter_dir_and_file = split_whitelist(white_list_file=options.white_list_file, nb_consensus_per_dir=options.nb_consensus_per_dir) for output_dir, sub_whitelist in iter_dir_and_file: command = 'python %s -g %s -w %s -o %s -b %s' % ( sys.argv[0], options.read1_consensus_file, sub_whitelist, output_dir, ' '.join(bam_files)) print command
def main(): #initialize the logging utils_logging.init_logging() #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) utils_logging.change_log_stdout_to_log_stderr() if options.print_commands: utils_logging.change_log_stdout_to_log_stderr() else: command_runner.set_command_to_run_localy() run_fine = run_BWA_Command(options.genome_file, options.fastq_file1, options.fastq_file2, options.output_dir, options.name, analysis_type=options.analysis, sort=options.sort, thread=options.thread, read_group=options.read_group, illumina=options.illumina) if run_fine: logging.info('Run completed') else: logging.error('Run Failed') sys.exit(1)
def main(): # initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if options.debug: utils_logging.init_logging(logging.DEBUG) bam_files = [options.bam_file] if len(args) > 0: bam_files.extend(args) command_runner.set_command_to_run_localy() if options.output_dir: list_consensus = read_white_list(options.white_list_file) extract_reads_from_all_bam_files_set_of_consensus( bam_files, list_consensus, options.output_dir, genome_loader=None, all_read1_consensus_file=options.read1_consensus_file) else: iter_dir_and_file = split_whitelist( white_list_file=options.white_list_file, nb_consensus_per_dir=options.nb_consensus_per_dir) for output_dir, sub_whitelist in iter_dir_and_file: command = 'python %s -g %s -w %s -o %s -b %s' % ( sys.argv[0], options.read1_consensus_file, sub_whitelist, output_dir, ' '.join(bam_files)) print command
def main(): #initialize the logging utils_logging.init_logging() #Setup options optparser=_prepare_optparser() (options,args) = optparser.parse_args() #verify options arg_pass=_verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) utils_logging.change_log_stdout_to_log_stderr() if options.print_commands: utils_logging.change_log_stdout_to_log_stderr() else: command_runner.set_command_to_run_localy() run_fine=run_BWA_Command(options.genome_file, options.fastq_file1, options.fastq_file2, options.output_dir, options.name,analysis_type=options.analysis, sort=options.sort, thread=options.thread, read_group=options.read_group, illumina=options.illumina) if run_fine: logging.info('Run completed') else: logging.error('Run Failed') sys.exit(1)
def main(): #initialize the logging utils_logging.init_logging(logging.INFO) #utils_logging.init_logging(logging.CRITICAL) #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if options.debug: utils_logging.init_logging(logging.DEBUG) if not options.print_command: command_runner.set_command_to_run_localy() start_time = time.time() #comment = '%s: contig_align:%s, mismatches:%s site with 1 contig:%s site with more than 1 contig:%s' all_assembler_to_try = options.assembler_name.split(',') assembly_function_list = [] for assembler_name in all_assembler_to_try: assembly_function = get_assembly_function(assembler_name) assembly_function_list.append(assembly_function) if options.rg_ids: rg_ids = options.rg_ids.split() else: rg_ids = [] if options.fastq_dir: run_all_fastq_files(options.fastq_dir, assembly_function_list, options.estimated_size, options.subsample_nb_read, rg_ids, options.force_merge, adapter_file=options.adapter_file) elif options.fastq_file: output_dir = os.path.dirname(options.fastq_file) name = os.path.basename(options.fastq_file)[:-len("_2.fastq")] read1_fasta = os.path.join(output_dir, name + "_1.fa") contig_file = run_one_fastq_file( options.fastq_file, output_dir, assembly_function_list, estimated_size=options.estimated_size, subsample_nb_read=options.subsample_nb_read, read1_fasta=read1_fasta, name=name, force_merge=options.force_merge, adapter_file=options.adapter_file) logging.info("Elapsed time:%.1f seconds" % (time.time() - start_time))
def main(): #initialize the logging utils_logging.init_logging() #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) command_runner.set_command_to_run_localy() mark_duplicate(options.input_bam)
def main(): #initialize the logging utils_logging.init_logging() #Setup options optparser=_prepare_optparser() (options,args) = optparser.parse_args() #verify options arg_pass=_verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) command_runner.set_command_to_run_localy() mark_duplicate(options.input_bam)
def main(): # initialize the logging utils_logging.init_logging() #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) command_runner.set_command_to_run_localy() shift_reads(options.bam_file, options.fasta_file, options.output_file)
def main(): # initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) command_runner.set_command_to_run_localy() if options.debug: utils_logging.init_logging(logging.DEBUG) run_all_snps_call(options.consensus_dir)
def main(): #initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser=_prepare_optparser() (options,args) = optparser.parse_args() #verify options arg_pass=_verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if not options.print_command: command_runner.set_command_to_run_localy() assess_read2_contigs(options.contig_file, options.genome_file,options.sites_file, options.output_sites)
def main(): #initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if not options.print_command: command_runner.set_command_to_run_localy() assess_read2_contigs(options.contig_file, options.genome_file, options.sites_file, options.output_sites)
def main(): #initialize the logging utils_logging.init_logging(logging.INFO) #utils_logging.init_logging(logging.CRITICAL) #Setup options optparser=_prepare_optparser() (options,args) = optparser.parse_args() #verify options arg_pass=_verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if options.debug: utils_logging.init_logging(logging.DEBUG) if not options.print_command: command_runner.set_command_to_run_localy() start_time = time.time() #comment = '%s: contig_align:%s, mismatches:%s site with 1 contig:%s site with more than 1 contig:%s' all_assembler_to_try = options.assembler_name.split(',') assembly_function_list=[] for assembler_name in all_assembler_to_try: assembly_function=get_assembly_function(assembler_name) assembly_function_list.append(assembly_function) if options.rg_ids: rg_ids=options.rg_ids.split() else: rg_ids=[] if options.fastq_dir: run_all_fastq_files(options.fastq_dir, assembly_function_list, options.estimated_size, options.subsample_nb_read, rg_ids, options.force_merge, adapter_file=options.adapter_file) elif options.fastq_file: output_dir = os.path.dirname(options.fastq_file) name = os.path.basename(options.fastq_file)[:-len("_2.fastq")] read1_fasta = os.path.join(output_dir, name + "_1.fa") contig_file = run_one_fastq_file(options.fastq_file, output_dir, assembly_function_list, estimated_size=options.estimated_size, subsample_nb_read=options.subsample_nb_read, read1_fasta=read1_fasta, name=name, force_merge=options.force_merge, adapter_file=options.adapter_file) logging.info("Elapsed time:%.1f seconds"%(time.time()-start_time))
def main(): # initialize the logging utils_logging.init_logging(logging.INFO) #utils_logging.init_logging(logging.CRITICAL) #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if options.debug: utils_logging.init_logging(logging.DEBUG) if not options.print_command: command_runner.set_command_to_run_localy() start_time = time.time() run_all_fastq_files(options.consensus_dir, readgroup_file=options.readgroup_file, snp_call=options.snp_call) logging.info("Elapsed time:%.1f seconds" % (time.time() - start_time))
def main(): #initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser=_prepare_optparser() (options,args) = optparser.parse_args() #verify options arg_pass=_verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if not options.print_commands: command_runner.set_command_to_run_localy() if options.debug: utils_logging.init_logging(logging.DEBUG) if options.final_merge: code = merge_all_results(options.consensus_dir) else: code = merge_results(options.consensus_dir) sys.exit(code)
def main(): #initialize the logging utils_logging.init_logging(logging.INFO) #Setup options optparser = _prepare_optparser() (options, args) = optparser.parse_args() #verify options arg_pass = _verifyOption(options) if not arg_pass: logging.warning(optparser.get_usage()) logging.critical("Non valid arguments: exit") sys.exit(1) if not options.print_commands: command_runner.set_command_to_run_localy() if options.debug: utils_logging.init_logging(logging.DEBUG) bam_files = [options.bam_files] if len(args) > 0: bam_files.extend(args) code = merge_bam_files(bam_files, options.output_file, options.genome_file, options.read_group_file, options.per_sample) sys.exit(code)
logging.info("Merging Failed try extending consensus") if os.path.exists(merged_fa): os.remove(merged_fa) os.remove(alignment_report) extended_sequence_file = os.path.join(parent_dir, consensus_name + "_1_extended.fa") if not os.path.exists(extended_sequence_file): extended_sequence_file = extend_read1_consensus(fastq_1, fastq_2, ">%s_extended"%consensus_name, extended_sequence_file) if extended_sequence_file: return merge_2_contigs(consensus_name, extended_sequence_file, contig_file2, output_dir, allow_extension=False) else: logging.info("Merging Failed") results = None if os.path.exists(merged_fa): os.remove(merged_fa) os.remove(alignment_report) return results if __name__ == "1__main__": alignment_report = sys.argv[1] parse_alignment_report(alignment_report) if __name__ == "1__main__": utils_logging.init_logging() command_runner.set_command_to_run_localy() fasta_file = sys.argv[1] read_consensus(fasta_file)
parent_dir, consensus_name + "_1_extended.fa") if not os.path.exists(extended_sequence_file): extended_sequence_file = extend_read1_consensus( fastq_1, fastq_2, ">%s_extended" % consensus_name, extended_sequence_file) if extended_sequence_file: return merge_2_contigs(consensus_name, extended_sequence_file, contig_file2, output_dir, allow_extension=False) else: logging.info("Merging Failed") results = None if os.path.exists(merged_fa): os.remove(merged_fa) os.remove(alignment_report) return results if __name__ == "1__main__": alignment_report = sys.argv[1] parse_alignment_report(alignment_report) if __name__ == "1__main__": utils_logging.init_logging() command_runner.set_command_to_run_localy() fasta_file = sys.argv[1] read_consensus(fasta_file)