From e9850e0a0c57de694e1e35d02c72de12df3c842e Mon Sep 17 00:00:00 2001 From: anastasiia Date: Fri, 4 Jan 2019 15:20:43 +0100 Subject: [PATCH 1/3] if there is no additional information provided by the original input bed file. the point will be printed to the last column in the output bed file --- bin/1.1_footprint_extraction/footprints_extraction.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/1.1_footprint_extraction/footprints_extraction.py b/bin/1.1_footprint_extraction/footprints_extraction.py index 47f8075..17345ed 100644 --- a/bin/1.1_footprint_extraction/footprints_extraction.py +++ b/bin/1.1_footprint_extraction/footprints_extraction.py @@ -96,6 +96,9 @@ def make_bed_dictionary(bed_file): for i in range(3, len(bed_line_array)): value.append(bed_line_array[i]) + if not value: #if there is no bonus information in the original bed file, add a "." to the coulmn in the output bed file + value = ["."] + bed_dictionary[key] = value else: #this is not a bed file, force exit logger.info('Error: please make sure the input bed file has a right format, the problem occured on the line ' + bed_line) From 2dfa50963a2a000ee67af76f4d68bad69274de79 Mon Sep 17 00:00:00 2001 From: anastasiia Date: Fri, 4 Jan 2019 15:26:46 +0100 Subject: [PATCH 2/3] checking for the directory the user wants to save the file in, and creating one if it does not exist --- bin/1.1_footprint_extraction/footprints_extraction.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/1.1_footprint_extraction/footprints_extraction.py b/bin/1.1_footprint_extraction/footprints_extraction.py index 17345ed..1ce0c9f 100644 --- a/bin/1.1_footprint_extraction/footprints_extraction.py +++ b/bin/1.1_footprint_extraction/footprints_extraction.py @@ -48,13 +48,12 @@ def parse_args(): return args -#this function is currently unused, but may be used in the future version -#if there are several files producing by this script, the directory containing these files is useful to have #this function checks if the directory for the output files exists and if not, the new directory with default name will be created +#the input for this function is a directory to check def check_directory(directory): if not os.path.exists(directory): os.makedirs(directory) - print('The new directory ' + directory + ' was created!') + logger.info('The new directory ' + directory + ' was created!') #check if the file to remove exists and if so, delete it #if the file does not exist, nothing happens @@ -318,6 +317,8 @@ def write_to_bed_file(all_footprints, 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) + #check if this directory exists, and if not, create one + check_directory(output_directory) #make sure the file is in .bed format output_name = "not_sorted_" + os.path.splitext(os.path.basename(sorted_output_file_name))[0] + ".bed" From 18a4fb5cfc61cdd0c3163c21558ab65cc2d27d4e Mon Sep 17 00:00:00 2001 From: anastasiia Date: Fri, 4 Jan 2019 15:30:37 +0100 Subject: [PATCH 3/3] adding a check if the directory was passed by the user --- bin/1.1_footprint_extraction/footprints_extraction.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/1.1_footprint_extraction/footprints_extraction.py b/bin/1.1_footprint_extraction/footprints_extraction.py index 1ce0c9f..fae040e 100644 --- a/bin/1.1_footprint_extraction/footprints_extraction.py +++ b/bin/1.1_footprint_extraction/footprints_extraction.py @@ -317,8 +317,9 @@ def write_to_bed_file(all_footprints, 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) - #check if this directory exists, and if not, create one - check_directory(output_directory) + #check if there is a directory provided + if output_directory: + check_directory(output_directory) #make sure the file is in .bed format output_name = "not_sorted_" + os.path.splitext(os.path.basename(sorted_output_file_name))[0] + ".bed"