From 36d775627b7028e56d509198c0feeb90c8b256f6 Mon Sep 17 00:00:00 2001 From: anastasiia Date: Wed, 2 Jan 2019 23:24:29 +0100 Subject: [PATCH] fixing the bug with the output directory name --- bin/footprints_extraction.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/bin/footprints_extraction.py b/bin/footprints_extraction.py index 415e589..47f8075 100644 --- a/bin/footprints_extraction.py +++ b/bin/footprints_extraction.py @@ -312,8 +312,15 @@ def find_peaks_from_bw(bed_dictionary, bw_file, window_length, step, percentage) #as input the dictionary with all footprints and the name for the output file are needed #the function outputs first an unsorted file and finally sorts it, removing the unsorted one def write_to_bed_file(all_footprints, sorted_output_file_name): - #save the output file in the working directory - output_file_name = "not_sorted_" + sorted_output_file_name + + #extract the name of directory where we want to save the file + output_directory = os.path.dirname(sorted_output_file_name) + + #make sure the file is in .bed format + output_name = "not_sorted_" + os.path.splitext(os.path.basename(sorted_output_file_name))[0] + ".bed" + + #save the output file in the working directory or in the directory provided by the user + output_file_name = (os.path.join(output_directory, output_name)) #a header to know what is in the columns header = ["#chr", "start", "end", "name", "score", "strand", "len", "max_pos", "bonus_info"]