Skip to content

Commit

Permalink
updating time.clock() to time.time() for Python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
transcript committed May 11, 2021
1 parent a79f5ea commit baa352c
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 53 deletions.
12 changes: 6 additions & 6 deletions python_scripts/DIAMOND_COG_analysis_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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.")
Expand All @@ -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 = {}
Expand All @@ -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.")
Expand Down
12 changes: 6 additions & 6 deletions python_scripts/DIAMOND_analysis_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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:
Expand Down Expand Up @@ -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.")
Expand Down
12 changes: 6 additions & 6 deletions python_scripts/DIAMOND_general_RefSeq_analysis_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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))
Expand All @@ -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:
Expand Down Expand Up @@ -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.")
Expand Down
10 changes: 5 additions & 5 deletions python_scripts/DIAMOND_results_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ 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:
db_line_counter += 1

# 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:
Expand Down Expand Up @@ -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:
Expand All @@ -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.")
Expand Down
10 changes: 5 additions & 5 deletions python_scripts/DIAMOND_specific_organism_retriever.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,15 @@ 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:
db_line_counter += 1

# 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:
Expand Down Expand Up @@ -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:
Expand All @@ -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.")
Expand Down
12 changes: 6 additions & 6 deletions python_scripts/DIAMOND_subsystems_analysis_counter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Expand All @@ -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.")
Expand Down Expand Up @@ -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 = {}
Expand Down Expand Up @@ -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.")
Expand Down
24 changes: 12 additions & 12 deletions python_scripts/db_results_swapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@
# Sam Westreich, [email protected], 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)
Expand All @@ -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:
Expand All @@ -69,20 +69,20 @@ 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."
print "Number of IDs found: " + str(len(id_list))
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")
Expand All @@ -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
Expand All @@ -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."
Expand Down
Loading

0 comments on commit baa352c

Please sign in to comment.