Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions scripts/add_tax.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,17 @@
"genus"
]

print('\t'.join(map(str,titles)))
print('\t'.join(map(str, titles)))

# iterate over file
for row in checkm_file:
# split on whitespace
arr = row.split()

# only consider data lines
if (len(arr) > 1):
if len(arr) > 1:
# get taxonomy free of the k__ bit
if (arr[1] == "root"):
if arr[1] == "root":
tax = "root"
else:
tax = arr[1].split("__")[1]
Expand All @@ -65,12 +65,12 @@

# empty variables unless we change them
sk = ''
k = ''
p = ''
c = ''
o = ''
f = ''
g = ''
k = ''
p = ''
c = ''
o = ''
f = ''
g = ''

# check we got what we asked for
if tax in name2taxid.keys():
Expand All @@ -92,26 +92,26 @@
sk = names[l]

if rank[l] == 'kingdom':
k = names[l]
k = names[l]

if rank[l] == 'phylum':
if rank[l] == 'phylum':
p = names[l]

if rank[l] == 'class':
if rank[l] == 'class':
c = names[l]

if rank[l] == 'order':
if rank[l] == 'order':
o = names[l]

if rank[l] == 'family':
if rank[l] == 'family':
f = names[l]

if rank[l] == 'genus':
if rank[l] == 'genus':
g = names[l]

# print it all out
print('\t'.join(map(str,arr)),'\t',end='')
print("%s\t%s\t%s\t%s\t%s\t%s\t%s" % (sk,k,p,c,o,f,g))
print('\t'.join(map(str, arr)), '\t', end='')
print("%s\t%s\t%s\t%s\t%s\t%s\t%s" % (sk, k, p, c, o, f, g))

# close file
checkm_file.close()