def linux_darwin_os_run(): # get the working directory path. working_dir = os.path.abspath(os.path.dirname(__file__)) file_desc = '' # if length of the argv is more than 1 then the argument is passed. if len(sys.argv) > 1: command_line_path = sys.argv[1] # path should be at 1 because .py is at 0 # check the file. # check_file will not assign a value unless it's correct. file_desc = check_file(command_line_path) elif local_file(): file_name = str(input("Specify the file name: ")) # check the file. file_desc = check_file_lin(working_dir, file_name) else: # executes when passing a full path. # get the file. file_name = find_file() while not check_file(file_name): # Try till we get it right. file_name = find_file() # Everything is fine. # Let's open the file. file_desc = file_name # set the starting time for the timer start_time = time.perf_counter() # create the object join_obj = JoinSequences(file_desc, working_dir) # lets join the sequences join_obj.join_seq() # now create sort object sort_obj = SortSequences(working_dir) # this will find the joined file and create a new file for output sort_obj.find_create_sort() # when that's done we need to clean up sort_obj.clean_up() # will delete joined file # create splitting object split_obj = SplitSequences() # first find the file and replace it split_obj.find_replace() # then split them split_obj.split_lines() # then remove the unnecessary file split_obj.clean_up() # and move the file in the new directory split_obj.move_file() # create stats object run_obj = RunStats(file_desc, split_obj.final_sorted_file) # get stats run_obj.get_seq_count() # set the stop time stop_time = time.perf_counter() time_used = abs(int(start_time - stop_time)) m, s = divmod(time_used, 60) h, m = divmod(m, 60) str_result = "Run time: %d:%02d:%02d" % (h, m, s) # get the run stats file. run_stats_file = run_obj.stats_file with open(run_stats_file, 'a') as result: result.write(str_result)
def win32_os_run(): # global variable for main object. global read_it # String variable to hold path/name of the input file file_desc = '' # if length of the argv is more than 1 then the argument is passed. if len(sys.argv) > 1: command_line_path = sys.argv[1] # path should be at 1 because .py is at 0 # check the file. # check_file will not assign a value unless it's correct. file_desc = check_file(command_line_path) elif local_file(): file_name = str(input("Specify the file name: ")) # check the file. file_desc = check_file(file_name) else: file_name = find_file() while not check_file(file_name): # Try till we get it right. file_name = find_file() # Everything is fine. # Let's open the file. file_desc = file_name # set the starting time for the timer start_time = time.perf_counter() # create the object read_it = LoadOnMemory(file_desc) # lets do it # check if user wants ordered or unordered. if len(sys.argv) == 3: if sys.argv[2] == '-o': read_it.ordered() else: read_it.unordered() else: # else unordered. read_it.unordered() # set the stop time stop_time = time.perf_counter() # get the time used time_used = abs(int(start_time - stop_time)) # convert to minutes and hours m, s = divmod(time_used, 60) h, m = divmod(m, 60) # create time string for output. str_result = "Run time: %d:%02d:%02d" % (h, m, s) # get the run stats file. run_stats_file = read_it.stats_file # write to the runstats file. with open(run_stats_file, 'a') as result: result.write(str_result)