From 56ab43a1aa3b49e4aafcc100e04025972185a7d0 Mon Sep 17 00:00:00 2001 From: Marta Lopez Balastegui Date: Mon, 18 Oct 2021 13:27:00 +0200 Subject: [PATCH] closing files --- XICRA_pip/XICRA/modules/biotype.py | 10 +++++----- XICRA_pip/XICRA/scripts/RNAbiotype.py | 15 +++++++++------ XICRA_pip/XICRA/scripts/fastqc_caller.py | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/XICRA_pip/XICRA/modules/biotype.py b/XICRA_pip/XICRA/modules/biotype.py index 789a61c..3b98e6b 100644 --- a/XICRA_pip/XICRA/modules/biotype.py +++ b/XICRA_pip/XICRA/modules/biotype.py @@ -141,20 +141,20 @@ def run_biotype(options): ## debug message if (Debug): - print (colored("**DEBUG: mapping_results **", 'yellow')) - print (mapping_results) + print (colored("**DEBUG: mapping_results **", 'yellow')) + print (mapping_results) # time stamp start_time_partial = time_functions.timestamp(start_time_partial) - + ## for samples biotype_outdir_dict = files_functions.outdir_project(outdir, options.project, pd_samples_retrieved, "biotype", options.debug) - + ## debug message if (Debug): print (colored("**DEBUG: biotype_outdir_dict **", 'yellow')) print (biotype_outdir_dict) - + ## multimapping: if options.no_multiMapping: multimapping = False diff --git a/XICRA_pip/XICRA/scripts/RNAbiotype.py b/XICRA_pip/XICRA/scripts/RNAbiotype.py index 8a45d19..3ed8fbb 100644 --- a/XICRA_pip/XICRA/scripts/RNAbiotype.py +++ b/XICRA_pip/XICRA/scripts/RNAbiotype.py @@ -57,7 +57,7 @@ def biotype_all(featureCount_exe, path, gtf_file, bam_file, name, threads, Debug stamp = time_functions.read_time_stamp(filename_stamp_featureCounts) print (colored("\tA previous command generated results on: %s [%s -- %s]" %(stamp, name, 'featureCounts'), 'yellow')) else: - + ## debugging messages if Debug: print ("** DEBUG:") @@ -160,7 +160,7 @@ def parse_featureCount(out_file, path, name, bam_file, Debug): string2write = "tRNA\t%s\n" %tRNA_count RNA_biotypes_file.write(string2write) RNA_biotypes_file.close() - + ########################################## ### read summary count file ########################################## @@ -265,7 +265,9 @@ def parse_featureCount(out_file, path, name, bam_file, Debug): ## close files out_tsv_file.close() - + summary_count_file.close() + mapping_stats_file.close() + count_file.close() ## print timestamp time_functions.print_time_stamp(filename_stamp_parse) @@ -345,7 +347,7 @@ def pie_plot_results(RNAbiotypes_stats_file, name, folder, Debug): stamp = time_functions.read_time_stamp(filename_stamp_plot) print (colored("\tA previous command generated results on: %s [%s -- %s]" %(stamp, name, 'plot results'), 'yellow')) else: - + # PLOT and SHOW results RNAbiotypes_stats = main_functions.get_data(RNAbiotypes_stats_file, '\t', 'header=None') @@ -397,9 +399,10 @@ def pie_plot_results(RNAbiotypes_stats_file, name, folder, Debug): name_figure = os.path.join(folder, name + '_RNAbiotypes.pdf') ## generate image - plt.savefig(name_figure) + plt.savefig(name_figure) plt.close(name_figure) - + plt.close() + ## print time stamps time_functions.print_time_stamp(filename_stamp_plot) filename_stamp_all = folder + '/.success_all' diff --git a/XICRA_pip/XICRA/scripts/fastqc_caller.py b/XICRA_pip/XICRA/scripts/fastqc_caller.py index 4379aa0..1bfcacf 100644 --- a/XICRA_pip/XICRA/scripts/fastqc_caller.py +++ b/XICRA_pip/XICRA/scripts/fastqc_caller.py @@ -14,6 +14,7 @@ import sys from sys import argv from io import open +from termcolor import colored ## import my modules from HCGB import functions