def output_maps(self, all_mapping_results, form): csv_files = CSVFiles() ## Obtain OutputPrinter: out file set to None. CSV file will be asigned later beauty_nums = True show_headers = True if form.get_collapsed_view(): output_printer = OutputFacade.get_collapsed_printer(None, self._verbose, beauty_nums, show_headers) else: output_printer = OutputFacade.get_expanded_printer(None, self._verbose, beauty_nums, show_headers) ## Output the different maps multiple_param = form.get_multiple() for mapping_results in all_mapping_results: map_config = mapping_results.get_map_config() map_id = map_config.get_id() map_csv_files = MapCSVFiles(map_id) csv_files.set_map_csv_files(map_id, map_csv_files) ## Map positions csv_file = self._output_map(mapping_results, output_printer, multiple_param) map_csv_files.set_mapped(csv_file) ## Enriched if form.get_show_markers() and mapping_results.get_map_with_markers(): csv_file = self._output_map_with_markers(mapping_results, output_printer, multiple_param) map_csv_files.set_map_with_markers(csv_file) if form.get_show_genes() and mapping_results.get_map_with_genes(): annotator = mapping_results.get_annotator() csv_file = self._output_map_with_genes(mapping_results, output_printer, multiple_param, annotator) map_csv_files.set_map_with_genes(csv_file) if form.get_show_anchored() and mapping_results.get_map_with_anchored(): csv_file = self._output_map_with_anchored(mapping_results, output_printer, multiple_param) map_csv_files.set_map_with_anchored(csv_file) ## Unmapped if mapping_results.get_unmapped(): csv_file = self._output_unmapped(mapping_results, output_printer) map_csv_files.set_unmapped(csv_file) ## Unaligned if mapping_results.get_unaligned(): csv_file = self._output_unaligned(mapping_results, output_printer) map_csv_files.set_unaligned(csv_file) return csv_files ## END
def __features_to_map_file(features, maps_path, map_config, map_output_path, verbose_param): multiple_param = True mapMarkers = MapMarkers(maps_path, map_config, verbose=verbose_param) unaligned = [] # Better this than None mapMarkers.create_map(features, unaligned, map_config.get_default_sort_by(), multiple_param) mapping_results = mapMarkers.get_mapping_results() sys.stderr.write("Mapped results " + str(len(mapping_results.get_mapped())) + "\n") map_output = open(map_output_path, 'w') try: outputPrinter = OutputFacade.get_expanded_printer( map_output, verbose=verbose_param, beauty_nums=False, show_headers=True) outputPrinter.print_map(mapping_results.get_mapped(), map_config, multiple_param) except Exception as e: raise e finally: map_output.close() return
def __features_to_map_file(features, maps_path, map_config, map_output_path, verbose_param): multiple_param = True mapMarkers = MapMarkers(maps_path, map_config, verbose = verbose_param) unaligned = [] # Better this than None mapMarkers.create_map(features, unaligned, map_config.get_default_sort_by(), multiple_param) mapping_results = mapMarkers.get_mapping_results() sys.stderr.write("Mapped results "+str(len(mapping_results.get_mapped()))+"\n") map_output = open(map_output_path, 'w') try: outputPrinter = OutputFacade.get_expanded_printer(map_output, verbose = verbose_param, beauty_nums = False, show_headers = True) outputPrinter.print_map(mapping_results.get_mapped(), map_config, multiple_param) except Exception as e: raise e finally: map_output.close() return
datasets_facade = DatasetsFacade(datasets_config, datasets_path, maps_path, verbose = verbose_param) # GenesAnnotator if show_genes and load_annot: ## Load annotation config dsannot_conf_file = __app_path+DATASETS_ANNOTATION_CONF anntypes_conf_file = __app_path+ANNOTATION_TYPES_CONF annot_path = paths_config.get_annot_path() annotator = AnnotatorsFactory.get_annotator(dsannot_conf_file, anntypes_conf_file, annot_path, verbose_param) else: annotator = None # OutputFacade if collapsed_view: outputPrinter = OutputFacade.get_collapsed_printer(sys.stdout, verbose = verbose_param, beauty_nums = beauty_nums, show_headers = True) else: outputPrinter = OutputFacade.get_expanded_printer(sys.stdout, verbose = verbose_param, beauty_nums = beauty_nums, show_headers = True) # Temp directory tmp_files_dir = paths_config.get_tmp_files_path() ########### Create maps ########### for map_id in maps_ids: sys.stderr.write("bmap_align: Map "+map_id+"\n") map_config = maps_config.get_map_config(map_id) databases_ids = map_config.get_db_list() sort_by = map_config.check_sort_param(map_config, sort_param, DEFAULT_SORT_PARAM)
## Load annotation config dsannot_conf_file = __app_path + DATASETS_ANNOTATION_CONF anntypes_conf_file = __app_path + ANNOTATION_TYPES_CONF annot_path = paths_config.get_annot_path() annotator = AnnotatorsFactory.get_annotator(dsannot_conf_file, anntypes_conf_file, annot_path, verbose_param) else: annotator = None # OutputFacade if collapsed_view: outputPrinter = OutputFacade.get_collapsed_printer( sys.stdout, verbose=verbose_param, beauty_nums=beauty_nums, show_headers=True) else: outputPrinter = OutputFacade.get_expanded_printer( sys.stdout, verbose=verbose_param, beauty_nums=beauty_nums, show_headers=True) # Temp directory tmp_files_dir = paths_config.get_tmp_files_path() ########### Create maps ########### for map_id in maps_ids:
def output_maps(self, all_mapping_results, form): csv_files = CSVFiles() ## Obtain OutputPrinter: out file set to None. CSV file will be asigned later beauty_nums = True show_headers = True if form.get_collapsed_view(): output_printer = OutputFacade.get_collapsed_printer( None, self._verbose, beauty_nums, show_headers) else: output_printer = OutputFacade.get_expanded_printer( None, self._verbose, beauty_nums, show_headers) ## Output the different maps multiple_param = form.get_multiple() for mapping_results in all_mapping_results: map_config = mapping_results.get_map_config() map_id = map_config.get_id() map_csv_files = MapCSVFiles(map_id) csv_files.set_map_csv_files(map_id, map_csv_files) ## Map positions csv_file = self._output_map(mapping_results, output_printer, multiple_param) map_csv_files.set_mapped(csv_file) ## Enriched if form.get_show_markers( ) and mapping_results.get_map_with_markers(): csv_file = self._output_map_with_markers( mapping_results, output_printer, multiple_param) map_csv_files.set_map_with_markers(csv_file) if form.get_show_genes() and mapping_results.get_map_with_genes(): annotator = mapping_results.get_annotator() csv_file = self._output_map_with_genes(mapping_results, output_printer, multiple_param, annotator) map_csv_files.set_map_with_genes(csv_file) if form.get_show_anchored( ) and mapping_results.get_map_with_anchored(): csv_file = self._output_map_with_anchored( mapping_results, output_printer, multiple_param) map_csv_files.set_map_with_anchored(csv_file) ## Unmapped if mapping_results.get_unmapped(): csv_file = self._output_unmapped(mapping_results, output_printer) map_csv_files.set_unmapped(csv_file) ## Unaligned if mapping_results.get_unaligned(): csv_file = self._output_unaligned(mapping_results, output_printer) map_csv_files.set_unaligned(csv_file) return csv_files ## END
sys.stderr.write("\nWorking with map:"+map_id+"\n") map_config = maps_config.get_map_config(map_id) sys.stdout.write(">>"+map_config.get_name()+"\n") databases_ids = map_config.get_db_list() # Perform alignments alignment_results = facade.perform_alignment(query_fasta_path, databases_ids, databases_config, search_type, aligner_list, \ threshold_id, threshold_cov, n_threads) aligned = alignment_results.get_aligned() ########## Output alignments_printer = OutputFacade.get_alignments_printer(search_type, databases_config) alignments_printer.output_results(aligned, databases_ids) except m2pException as m2pe: sys.stderr.write("\nThere was an error.\n") sys.stderr.write(m2pe.msg+"\n") #traceback.print_exc(file=sys.stderr) except Exception as e: #traceback.print_exc(file=sys.stderr) sys.stderr.write("\nThere was an error.\n") sys.stderr.write(str(e)+"\n") sys.stderr.write('If you can not solve it please contact [email protected] ('+\ 'laboratory of computational biology at EEAD).\n') finally: pass