def _start_quast_main(name, args, assemblies, reference_fpath=None, output_dirpath=None, exit_on_exception=True, num_notifications_tuple=None, is_first_run=None): args = args[:] args.extend([asm.fpath for asm in assemblies]) if reference_fpath: args.append('-R') args.append(reference_fpath) if output_dirpath: args.append('-o') args.append(output_dirpath) args.append('--labels') def quote(line): if ' ' in line: line = '"%s"' % line return line args.append(quote(', '.join([asm.label for asm in assemblies]))) import quast reload(quast) quast.logger.set_up_console_handler(indent_val=1, debug=qconfig.debug) quast.logger.set_up_metaquast() logger.info_to_file( '(logging to ' + os.path.join(output_dirpath, qconfig.LOGGER_DEFAULT_NAME + '.log)')) # try: return_code = quast.main(args) if num_notifications_tuple: cur_num_notifications = quast.logger.get_numbers_of_notifications() num_notifications_tuple = map( sum, zip(num_notifications_tuple, cur_num_notifications)) if is_first_run: labels = [ qconfig.assembly_labels_by_fpath[fpath] for fpath in qconfig.assemblies_fpaths ] assemblies = [ Assembly(fpath, qconfig.assembly_labels_by_fpath[fpath]) for fpath in qconfig.assemblies_fpaths ] return return_code, num_notifications_tuple, assemblies, labels else: return return_code, num_notifications_tuple
def _start_quast_main(args, assemblies, reference_fpath=None, output_dirpath=None, num_notifications_tuple=None, labels=None, run_regular_quast=False, is_combined_ref=False, is_parallel_run=False): args = args[:] args.extend([asm.fpath for asm in assemblies]) if reference_fpath: args.append('-R') args.append(reference_fpath) if output_dirpath: args.append('-o') args.append(output_dirpath) args.append('--labels') def quote(line): if ' ' in line: line = '"%s"' % line return line args.append(quote(', '.join([asm.label for asm in assemblies]))) import quast try: import importlib importlib.reload(quast) except (ImportError, AttributeError): reload(quast) quast.logger.set_up_console_handler(indent_val=1, debug=qconfig.debug) if not run_regular_quast: reference_name = os.path.basename(qutils.name_from_fpath(reference_fpath)) if reference_fpath else None quast.logger.set_up_metaquast(is_parallel_run=is_parallel_run, ref_name=reference_name) if is_combined_ref: logger.info_to_file('(logging to ' + os.path.join(output_dirpath, qconfig.LOGGER_DEFAULT_NAME + '.log)')) return_code = quast.main(args) if num_notifications_tuple: cur_num_notifications = quast.logger.get_numbers_of_notifications() num_notifications_tuple = list(map(sum, zip(num_notifications_tuple, cur_num_notifications))) if is_combined_ref: labels[:] = [qconfig.assembly_labels_by_fpath[fpath] for fpath in qconfig.assemblies_fpaths] assemblies[:] = [Assembly(fpath, qconfig.assembly_labels_by_fpath[fpath]) for fpath in qconfig.assemblies_fpaths] return return_code, num_notifications_tuple
def _start_quast_main(args, assemblies, reference_fpath=None, output_dirpath=None, num_notifications_tuple=None, is_first_run=None, run_regular_quast=False): args = args[:] args.extend([asm.fpath for asm in assemblies]) if reference_fpath: args.append('-R') args.append(reference_fpath) if output_dirpath: args.append('-o') args.append(output_dirpath) args.append('--labels') def quote(line): if ' ' in line: line = '"%s"' % line return line args.append(quote(', '.join([asm.label for asm in assemblies]))) import quast try: import imp imp.reload(quast) except: reload(quast) quast.logger.set_up_console_handler(indent_val=1, debug=qconfig.debug) if not run_regular_quast: quast.logger.set_up_metaquast() logger.info_to_file('(logging to ' + os.path.join(output_dirpath, qconfig.LOGGER_DEFAULT_NAME + '.log)')) return_code = quast.main(args) if num_notifications_tuple: cur_num_notifications = quast.logger.get_numbers_of_notifications() num_notifications_tuple = list(map(sum, zip(num_notifications_tuple, cur_num_notifications))) if is_first_run: labels = [qconfig.assembly_labels_by_fpath[fpath] for fpath in qconfig.assemblies_fpaths] assemblies = [Assembly(fpath, qconfig.assembly_labels_by_fpath[fpath]) for fpath in qconfig.assemblies_fpaths] return return_code, num_notifications_tuple, assemblies, labels else: return return_code, num_notifications_tuple
def _start_quast_main( name, args, assemblies, reference_fpath=None, output_dirpath=None, exit_on_exception=True, num_notifications_tuple=None): args = args[:] args.extend([asm.fpath for asm in assemblies]) if reference_fpath: args.append('-R') args.append(reference_fpath) if output_dirpath: args.append('-o') args.append(output_dirpath) args.append('--labels') def quote(line): if ' ' in line: line = '"%s"' % line return line args.append(quote(', '.join([asm.label for asm in assemblies]))) import quast reload(quast) quast.logger.set_up_console_handler(indent_val=1, debug=qconfig.debug) logger.info_to_file('(logging to ' + os.path.join(output_dirpath, qconfig.LOGGER_DEFAULT_NAME + '.log)')) # try: return_code = quast.main(args) if num_notifications_tuple: cur_num_notifications = quast.logger.get_numbers_of_notifications() num_notifications_tuple = map(sum, zip(num_notifications_tuple,cur_num_notifications)) return return_code, num_notifications_tuple
def _start_quast_main(name, args, assemblies, reference_fpath=None, output_dirpath=None, exit_on_exception=True): args = args[:] args.extend([asm.fpath for asm in assemblies]) if reference_fpath: args.append('-R') args.append(reference_fpath) if output_dirpath: args.append('-o') args.append(output_dirpath) args.append('--labels') def quote(line): if ' ' in line: line = '"%s"' % line return line args.append(quote(', '.join([asm.label for asm in assemblies]))) import quast reload(quast) quast.logger.set_up_console_handler(debug=not RELEASE_MODE, indent_val=1) logger.info_to_file( '(logging to ' + os.path.join(output_dirpath, qconfig.LOGGER_DEFAULT_NAME + '.log)')) # try: return quast.main(args)
fasta_filepath = os.path.join(dirpath, fasta_filename) if os.path.isfile( fasta_filepath ) and fasta_filename == project_name + '.fasta': new_filepath = os.path.join( tmp_dir_path, m.group('suffix') + '.fasta') shutil.copyfile(fasta_filepath, new_filepath) contigs_filepaths.append(new_filepath) if len(contigs_filepaths) == 0: print >> sys.stderr, 'No ' + project_name + '.fasta files in spades_* subdirectories' else: # Constructing a new command line arguments array to run quast.py with. new_args = [] for opt, arg in options: new_args.extend([opt, arg]) for contig_filepath in contigs_filepaths: new_args.append(contig_filepath) quast.main(new_args) if os.path.isdir(tmp_dir_name): shutil.rmtree(tmp_dir_name) if __name__ == '__main__': main(sys.argv[1:])
if os.path.isdir(dirpath): m = spades_dir_pattern.match(dirname) if m: for fasta_filename in os.listdir(dirpath): fasta_filepath = os.path.join(dirpath, fasta_filename) if os.path.isfile(fasta_filepath) and fasta_filename == project_name + '.fasta': new_filepath = os.path.join(tmp_dir_path, m.group('suffix') + '.fasta') shutil.copyfile(fasta_filepath, new_filepath) contigs_filepaths.append(new_filepath) if len(contigs_filepaths) == 0: print >>sys.stderr, 'No ' + project_name + '.fasta files in spades_* subdirectories' else: # Constructing a new command line arguments array to run quast.py with. new_args = [] for opt, arg in options: new_args.extend([opt, arg]) for contig_filepath in contigs_filepaths: new_args.append(contig_filepath) quast.main(new_args) if os.path.isdir(tmp_dir_name): shutil.rmtree(tmp_dir_name) if __name__ == '__main__': main(sys.argv[1:])