Skip to content

Commit

Permalink
Update fix_relab_mpa4.py
Browse files Browse the repository at this point in the history
  • Loading branch information
abmiguez authored Mar 20, 2024
1 parent 87ce6b1 commit 739844e
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions metaphlan/utils/fix_relab_mpa4.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,22 @@ def fix_relab_mpa4(input, output):
with open(output, 'w') as wf:
for line in rf:
if line.startswith('#mpa_v'):
release = line.strip()[1:]
wf.write('{}_fixed\n'.format(line.strip()))
elif line.startswith('#'):
elif line.startswith('#') or line.startswith('UNCLASSIFIED'):
wf.write(line)
else:
if 't__' in line:
if 'p__Bacillota' in line:
line = line.replace('p__Bacillota', 'p__Firmicutes')
if release == 'mpa_vJun23_CHOCOPhlAnSGB_202307':
if 'p__Bacillota' in line:
line = line.replace('p__Bacillota', 'p__Firmicutes')
elif 'f__Saccharomycetales_unclassified' in line:
line = line.replace('f__Saccharomycetales_unclassified','f__Debaryomycetaceae')
elif release == 'mpa_vOct22_CHOCOPhlAnSGB_202212':
pass
line = line.strip().split('\t')
taxa_levs[-1][line[0]] = [line[1], float(line[2]), line[3] if len(line)==4 else '']
elif 's__' in line:
if 'p__Bacillota' in line:
line = line.replace('p__Bacillota', 'p__Firmicutes')
line = line.strip().split('\t')
taxa_levs[-2][line[0]] = [line[1], float(line[2]), '']
for i in range(2,8):
for i in range(1,8):
j = i+1
for ss in taxa_levs[-i]:
gg = ss.replace('|{}'.format(ss.split('|')[-1]), '')
Expand Down

0 comments on commit 739844e

Please sign in to comment.