Skip to content

Peak calling to dev #38

Merged
merged 4 commits into from
Jan 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions bin/1.1_footprint_extraction/footprints_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -96,6 +95,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)
Expand Down Expand Up @@ -315,6 +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 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"
Expand Down