Skip to content

Commit

Permalink
BUG fix no norm when generating single feature
Browse files Browse the repository at this point in the history
  • Loading branch information
psj1997 committed Nov 5, 2023
1 parent 7525011 commit 90ad861
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions SemiBin/generate_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,20 @@ def generate_cov(bam_file, bam_index, out, threshold,
raise OSError(f"Running bedtools returned an empty file ({bam_file})")

contig_cov += 1e-5
with atomic_write(os.path.join(out, '{}_data_cov.csv'.format(bam_name)), overwrite=True) as ofile:
contig_cov.to_csv(ofile)
if not is_combined:
with atomic_write(os.path.join(out, '{}_data_cov.csv'.format(bam_name)), overwrite=True) as ofile:
contig_cov.to_csv(ofile)
else:
if sep is None:
abun_scale = (contig_cov.mean() / 100).apply(np.ceil) * 100
contig_cov = contig_cov.div(abun_scale)
with atomic_write(os.path.join(out, '{}_data_cov.csv'.format(bam_name)), overwrite=True) as ofile:
contig_cov.to_csv(ofile)

if is_combined:
must_link_contig_cov = must_link_contig_cov.apply(lambda x: x + 1e-5)
if sep is None:
abun_scale = (contig_cov.mean() / 100).apply(np.ceil) * 100
abun_split_scale = (must_link_contig_cov.mean() / 100).apply(np.ceil) * 100
contig_cov = contig_cov.div(abun_scale)
must_link_contig_cov = must_link_contig_cov.div(abun_split_scale)

with atomic_write(os.path.join(out, '{}_data_split_cov.csv'.format(bam_name)), overwrite=True) as ofile:
Expand Down

0 comments on commit 90ad861

Please sign in to comment.