Skip to content

Commit

Permalink
ENH include density in the percontigs output
Browse files Browse the repository at this point in the history
  • Loading branch information
celiosantosjr committed Jul 13, 2023
1 parent 60b2b47 commit d4d05da
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ fi
${CONDA_INSTALL_CMD} install -y \
--prefix $BASEDIR/envs/Macrel_env \
ngless \
pyrodigal>=0.7.3 \
"pyrodigal>=0.7.3" \
megahit \
paladin \
pandas \
scikit-learn \
"scikit-learn<1.2.2" \
atomicwrites \
tzlocal

Expand Down
7 changes: 4 additions & 3 deletions macrel/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,13 +294,14 @@ def do_density(args, clen, prediction):
clen = clen.merge(on='contig', right=tpred, how='outer').fillna(0)
clen[clen.columns[1:]] = clen[clen.columns[1:]].astype(int)
ofile = path.join(args.output, args.outtag + '.percontigs.gz')
sample = clen.set_index('contig').sum(axis=0).tolist()
sample_density = sample[-1] * 1e6 / sample[0]
with open_output(ofile, mode='wb') as raw_out:
with gzip.open(raw_out, 'wt') as out:
from macrel_version import __version__
from .macrel_version import __version__
out.write('# Prediction from macrel v{}\n'.format(__version__))
out.write(f'# Macrel calculated for the sample a density of {sample_density:.3f} AMPs / Mbp.\n')
clen.to_csv(out, sep='\t', index=False, float_format="%.3f")
sample = clen.set_index('contig').sum(axis=0).tolist()
sample_density = sample[-1] * 1e6 / sample[0]
print(f'Macrel processed the sample and verified a density of {sample_density:.3f} AMPs / Mbp.')

def do_get_examples(args):
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ nav:
- 'Macrel': index.md
- 'Install': install.md
- 'Usage': usage.md
- 'Tutorial': tutorial.md
- "What's New (history)": whatsnew.md
- 'Contacts': contact.md
- 'FAQ': faq.md
Expand Down
1 change: 1 addition & 0 deletions tests/contigs.nosmorfs/expected.percontigs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Prediction from macrel v1.2.0
# Macrel calculated for the sample a density of 0.000 AMPs / Mbp.
contig length ORFs smORFs AMPs
scaffold2530_2_MH0058 1324 1 0 0
1 change: 1 addition & 0 deletions tests/contigs/expected.percontigs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Prediction from macrel v1.2.0
# Macrel calculated for the sample a density of 45.062 AMPs / Mbp.
contig length ORFs smORFs AMPs
scaffold2530_2_MH0058 717 2 2 0
scaffold75334_1_MH0058 3424 1 1 1
Expand Down
1 change: 1 addition & 0 deletions tests/reads.se/expected.percontigs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Prediction from macrel v1.2.0
# Macrel calculated for the sample a density of 59.743 AMPs / Mbp.
contig length ORFs smORFs AMPs
k47_0 3379 4 2 0
k47_1 6046 9 4 0
Expand Down
1 change: 1 addition & 0 deletions tests/reads/expected.percontigs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Prediction from macrel v1.2.0
# Macrel calculated for the sample a density of 57.627 AMPs / Mbp.
contig length ORFs smORFs AMPs
k77_3 1270 1 0 0
k77_5 5202 6 3 0
Expand Down

0 comments on commit d4d05da

Please sign in to comment.