From baa352ccfaf71c8d49fc560fccf2ed4bd55062a3 Mon Sep 17 00:00:00 2001 From: Sam Westreich Date: Tue, 11 May 2021 15:42:37 -0700 Subject: [PATCH] updating time.clock() to time.time() for Python 3.8 --- .../DIAMOND_COG_analysis_counter.py | 12 +++++----- python_scripts/DIAMOND_analysis_counter.py | 12 +++++----- ...DIAMOND_general_RefSeq_analysis_counter.py | 12 +++++----- python_scripts/DIAMOND_results_filter.py | 10 ++++---- .../DIAMOND_specific_organism_retriever.py | 10 ++++---- .../DIAMOND_subsystems_analysis_counter.py | 12 +++++----- python_scripts/db_results_swapper.py | 24 +++++++++---------- .../standardized_DIAMOND_analysis_counter.py | 12 +++++----- python_scripts/subsystems_hier_condenser.py | 2 +- 9 files changed, 53 insertions(+), 53 deletions(-) diff --git a/python_scripts/DIAMOND_COG_analysis_counter.py b/python_scripts/DIAMOND_COG_analysis_counter.py index eceb024..d21ab3b 100644 --- a/python_scripts/DIAMOND_COG_analysis_counter.py +++ b/python_scripts/DIAMOND_COG_analysis_counter.py @@ -50,7 +50,7 @@ def string_find(usage_term): if elem == usage_term: return next_elem -t0 = time.clock() +t0 = time.time() # loading starting file if "-I" in sys.argv: @@ -71,7 +71,7 @@ def string_find(usage_term): line_counter += 1 splitline = line.split("\t") if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print (str(line_counter)[:-6] + "M lines processed so far in " + str(t99-t0) + " seconds.") unique_seq_db[splitline[0]] = 1 @@ -85,7 +85,7 @@ def string_find(usage_term): hit_count_db[splitline[1]] = 1 continue -t1 = time.clock() +t1 = time.time() # results reporting print ("\nAnalysis of " + infile_name + " complete.") @@ -109,7 +109,7 @@ def string_find(usage_term): print ("\nStarting database analysis now.") -t2 = time.clock() +t2 = time.time() # building a dictionary of the reference database db_hier_dictionary = {} @@ -136,10 +136,10 @@ def string_find(usage_term): # line counter to show progress if db_line_counter % 1000000 == 0: # each million - t95 = time.clock() + t95 = time.time() print (str(db_line_counter) + " lines processed so far in " + str(t95-t2) + " seconds.") -t3 = time.clock() +t3 = time.time() print ("\nSuccess!") print ("Time elapsed: " + str(t3-t2) + " seconds.") diff --git a/python_scripts/DIAMOND_analysis_counter.py b/python_scripts/DIAMOND_analysis_counter.py index 18016fc..1c760b1 100644 --- a/python_scripts/DIAMOND_analysis_counter.py +++ b/python_scripts/DIAMOND_analysis_counter.py @@ -51,7 +51,7 @@ def string_find(usage_term): if elem == usage_term: return next_elem -t0 = time.clock() +t0 = time.time() # checking for an option (organism or function) to be specified if "-O" not in sys.argv: @@ -86,7 +86,7 @@ def string_find(usage_term): line_counter += 1 splitline = line.split("\t") if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print (str(line_counter)[:-6] + "M lines processed so far in " + str(t99-t0) + " seconds.") unique_seq_db[splitline[0]] = 1 @@ -97,7 +97,7 @@ def string_find(usage_term): RefSeq_hit_count_db[splitline[1]] = 1 continue -t1 = time.clock() +t1 = time.time() print ("\nAnalysis of " + infile_name + " complete.") print ("Number of total lines: " + str(line_counter)) @@ -111,7 +111,7 @@ def string_find(usage_term): print ("\nStarting database analysis now.") -t2 = time.clock() +t2 = time.time() # optional outfile of specific organism results if "-SO" in sys.argv: @@ -185,10 +185,10 @@ def string_find(usage_term): # line counter to show progress if db_line_counter % 1000000 == 0: # each million - t95 = time.clock() + t95 = time.time() print (str(db_line_counter)[:-6] + "M lines processed so far in " + str(t95-t2) + " seconds.") -t3 = time.clock() +t3 = time.time() print ("\nSuccess!") print ("Time elapsed: " + str(t3-t2) + " seconds.") diff --git a/python_scripts/DIAMOND_general_RefSeq_analysis_counter.py b/python_scripts/DIAMOND_general_RefSeq_analysis_counter.py index d58517e..604ba61 100644 --- a/python_scripts/DIAMOND_general_RefSeq_analysis_counter.py +++ b/python_scripts/DIAMOND_general_RefSeq_analysis_counter.py @@ -51,7 +51,7 @@ def string_find(usage_term): if elem == usage_term: return next_elem -t0 = time.clock() +t0 = time.time() # checking for an option (organism or function) to be specified if "-O" not in sys.argv: @@ -85,7 +85,7 @@ def string_find(usage_term): line_counter += 1 splitline = line.split("\t") if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print str(line_counter)[:-6] + "M lines processed so far in " + str(t99-t0) + " seconds." unique_seq_db[splitline[0]] = 1 @@ -96,7 +96,7 @@ def string_find(usage_term): RefSeq_hit_count_db[splitline[1]] = 1 continue -t1 = time.clock() +t1 = time.time() print ("\nAnalysis of " + infile_name + " complete.") print ("Number of total lines: " + str(line_counter)) @@ -110,7 +110,7 @@ def string_find(usage_term): print ("\nReading in reference database...") -t2 = time.clock() +t2 = time.time() # optional outfile of specific organism results if "-SO" in sys.argv: @@ -187,11 +187,11 @@ def string_find(usage_term): # line counter to show progress if db_line_counter % 1000000 == 0: # each million - t95 = time.clock() + t95 = time.time() print (str(db_line_counter)[:-6] + "M lines processed so far in " + str(t95-t2) + " seconds.") db.close() -t3 = time.clock() +t3 = time.time() print ("Database read successfully.\n") print ("Time elapsed: " + str(t3-t2) + " seconds.") diff --git a/python_scripts/DIAMOND_results_filter.py b/python_scripts/DIAMOND_results_filter.py index 9c70111..e823733 100644 --- a/python_scripts/DIAMOND_results_filter.py +++ b/python_scripts/DIAMOND_results_filter.py @@ -86,7 +86,7 @@ def string_find(usage_term): db_line_counter = 0 db_error_counter = 0 -t0 = time.clock() +t0 = time.time() for line in db: if line.startswith(">") == True: @@ -94,7 +94,7 @@ def string_find(usage_term): # line counter to show progress if db_line_counter % 1000000 == 0: # each million - t95 = time.clock() + t95 = time.time() print (str(db_line_counter) + " lines processed so far in " + str(t95-t0) + " seconds.") if target_org in line: @@ -153,7 +153,7 @@ def string_find(usage_term): line_counter = 0 hit_counter = 0 -t1 = time.clock() +t1 = time.time() # reading through the infile for line in infile: @@ -167,11 +167,11 @@ def string_find(usage_term): continue if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print (str(line_counter)[:-6] + "M lines processed so far in " + str(t99-t1) + " seconds.") # results stats -t100 = time.clock() +t100 = time.time() print ("Run complete!") print ("Number of sequences found matching target query, " + target_org + ":\t" + str(hit_counter)) print ("Time elapsed: " + str(t100-t0) + " seconds.") diff --git a/python_scripts/DIAMOND_specific_organism_retriever.py b/python_scripts/DIAMOND_specific_organism_retriever.py index b1ce559..9bb9178 100644 --- a/python_scripts/DIAMOND_specific_organism_retriever.py +++ b/python_scripts/DIAMOND_specific_organism_retriever.py @@ -85,7 +85,7 @@ def string_find(usage_term): db_line_counter = 0 db_error_counter = 0 -t0 = time.clock() +t0 = time.time() for line in db: if line.startswith(">") == True: @@ -93,7 +93,7 @@ def string_find(usage_term): # line counter to show progress if db_line_counter % 1000000 == 0: # each million - t95 = time.clock() + t95 = time.time() print (str(db_line_counter) + " lines processed so far in " + str(t95-t0) + " seconds.") if target_org not in line: @@ -153,7 +153,7 @@ def string_find(usage_term): line_counter = 0 hit_counter = 0 -t1 = time.clock() +t1 = time.time() # reading through the infile for line in infile: @@ -167,11 +167,11 @@ def string_find(usage_term): continue if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print (str(line_counter)[:-6] + "M lines processed so far in " + str(t99-t1) + " seconds.") # results stats -t100 = time.clock() +t100 = time.time() print ("Run complete!") print ("Number of sequences found matching target organism, " + target_org + ": " + str(hit_counter)) print ("Time elapsed: " + str(t100-t0) + " seconds.") diff --git a/python_scripts/DIAMOND_subsystems_analysis_counter.py b/python_scripts/DIAMOND_subsystems_analysis_counter.py index ae3b85d..b4460b2 100644 --- a/python_scripts/DIAMOND_subsystems_analysis_counter.py +++ b/python_scripts/DIAMOND_subsystems_analysis_counter.py @@ -50,7 +50,7 @@ def string_find(usage_term): if elem == usage_term: return next_elem -t0 = time.clock() +t0 = time.time() # loading starting file if "-I" in sys.argv: @@ -71,7 +71,7 @@ def string_find(usage_term): line_counter += 1 splitline = line.split("\t") if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print (str(line_counter)[:-6] + "M lines processed so far in " + str(t99-t0) + " seconds.") unique_seq_db[splitline[0]] = 1 @@ -85,7 +85,7 @@ def string_find(usage_term): hit_count_db[splitline[1]] = 1 continue -t1 = time.clock() +t1 = time.time() # results reporting print ("\nAnalysis of " + infile_name + " complete.") @@ -114,7 +114,7 @@ def string_find(usage_term): print ("\nStarting database analysis now.") -t2 = time.clock() +t2 = time.time() # building a dictionary of the reference database db_hier_dictionary = {} @@ -144,10 +144,10 @@ def string_find(usage_term): # line counter to show progress if db_line_counter % 1000000 == 0: # each million - t95 = time.clock() + t95 = time.time() print (str(db_line_counter) + " lines processed so far in " + str(t95-t2) + " seconds.") -t3 = time.clock() +t3 = time.time() print ("\nSuccess!") print ("Time elapsed: " + str(t3-t2) + " seconds.") diff --git a/python_scripts/db_results_swapper.py b/python_scripts/db_results_swapper.py index 39c0a7f..52cbf28 100644 --- a/python_scripts/db_results_swapper.py +++ b/python_scripts/db_results_swapper.py @@ -23,16 +23,16 @@ # Sam Westreich, stwestreich@ucdavis.edu, github.com/transcript # # This program takes a list of IDs from one database, such as the RefSeq -# database, and gets all IDs for those entries retrieved against another +# database, and gets all IDs for those entries retrieved against another # database, such as Subsystems. # -# Usage: +# Usage: # -# -I infile specifies the infile (a DIAMOND results file +# -I infile specifies the infile (a DIAMOND results file # in m8 format) -# -A annotation specifies annotated results to search against +# -A annotation specifies annotated results to search against # -# -O outfile specifies a name for the outfile (otherwise defaults +# -O outfile specifies a name for the outfile (otherwise defaults # to $name_hierarchy.tsv) # -P partial partial outfile; a list of all reads with their # hierarchy results (OPTIONAL) @@ -50,7 +50,7 @@ def string_find(usage_term): if elem == usage_term: return next_elem -t0 = time.clock() +t0 = time.time() # loading starting file if "-I" in sys.argv: @@ -69,12 +69,12 @@ def string_find(usage_term): line_counter += 1 splitline = line.split("\t") if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print str(line_counter)[:-6] + "MM lines processed so far in " + str(t99-t0) + " seconds." - + id_list.append(splitline[0]) -t1 = time.clock() +t1 = time.time() # results reporting print "\nAnalysis of " + infile_name + " complete." @@ -82,7 +82,7 @@ def string_find(usage_term): print "Time elapsed: " + str(t1-t0) + " seconds." infile.close() - + # time to search for these in the annotated file if "-A" in sys.argv: af_name = string_find("-A") @@ -100,7 +100,7 @@ def string_find(usage_term): print "\nStarting annotation filtering now." -t2 = time.clock() +t2 = time.time() # data storage af_line_counter = 0 @@ -112,7 +112,7 @@ def string_find(usage_term): splitline = line.split("\t", 1) af_dic[splitline[0]] = splitline[1] if af_line_counter % 1000000 == 0: - t3 = time.clock() + t3 = time.time() print str(af_line_counter)[:-6] + "MM lines processed so far in " + str(t3-t2) + " seconds." print "Annotation file read in." diff --git a/python_scripts/standardized_DIAMOND_analysis_counter.py b/python_scripts/standardized_DIAMOND_analysis_counter.py index a1d1ab4..b2925b9 100755 --- a/python_scripts/standardized_DIAMOND_analysis_counter.py +++ b/python_scripts/standardized_DIAMOND_analysis_counter.py @@ -50,7 +50,7 @@ def string_find(usage_term): if elem == usage_term: return next_elem -t0 = time.clock() +t0 = time.time() # checking for an option (organism or function) to be specified if "-O" not in sys.argv: @@ -84,7 +84,7 @@ def string_find(usage_term): line_counter += 1 splitline = line.split("\t") if line_counter % 1000000 == 0: - t99 = time.clock() + t99 = time.time() print (str(line_counter)[:-6] + "M lines processed so far in " + str(t99-t0) + " seconds.") unique_seq_db[splitline[0]] = 1 @@ -95,7 +95,7 @@ def string_find(usage_term): RefSeq_hit_count_db[splitline[1]] = 1 continue -t1 = time.clock() +t1 = time.time() print ("\nAnalysis of " + infile_name + " complete.") print ("Number of total lines: " + str(line_counter)) @@ -109,7 +109,7 @@ def string_find(usage_term): print ("\nStarting database analysis now.") -t2 = time.clock() +t2 = time.time() # optional outfile of specific organism results # if "-SO" in sys.argv: @@ -180,10 +180,10 @@ def string_find(usage_term): # line counter to show progress if db_line_counter % 1000000 == 0: # each million - t95 = time.clock() + t95 = time.time() print (str(db_line_counter)[:-6] + "M lines processed so far in " + str(t95-t2) + " seconds.") -t3 = time.clock() +t3 = time.time() print ("\nSuccess!") print ("Time elapsed: " + str(t3-t2) + " seconds.") diff --git a/python_scripts/subsystems_hier_condenser.py b/python_scripts/subsystems_hier_condenser.py index 595b76d..49bacbe 100644 --- a/python_scripts/subsystems_hier_condenser.py +++ b/python_scripts/subsystems_hier_condenser.py @@ -45,7 +45,7 @@ def string_find(usage_term): if elem == usage_term: return next_elem -t0 = time.clock() +t0 = time.time() # loading starting file, hierarchy level if "-I" in sys.argv: