Skip to content

Commit

Permalink
fix warning bug in paired subsample
Browse files Browse the repository at this point in the history
  • Loading branch information
Cengoni committed Jul 3, 2024
1 parent 6570549 commit f624cc5
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions metaphlan/metaphlan.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,10 @@ def subsample_reads(inp, subsampling, subsampling_seed, subsampling_output, tmp_
n_metagenome_reads = execute_pool(((rawpycount, inp_f) for inp_f in inp.split(',')), 2)
n_metagenome_reads = [int(n/4) for n in n_metagenome_reads]

if subsampling >= sum(n_metagenome_reads):
sys.stderr.write("WARNING: The specified subsampling ({}) is equal or higher than the original number of reads ({}). Subsampling will be skipped.\n".format(subsampling, sum(n_metagenome_reads)))
return inp, None

if paired:
subsampling //= 2
if n_metagenome_reads[0] != n_metagenome_reads[1]:
Expand All @@ -1199,9 +1203,6 @@ def subsample_reads(inp, subsampling, subsampling_seed, subsampling_output, tmp_
else:
n_metagenome_reads = sum(n_metagenome_reads)

if subsampling >= n_metagenome_reads:
sys.stderr.write("WARNING: The specified subsampling ({}) is equal or higher than the original number of reads ({}). Subsampling will be skipped.\n".format(subsampling, sum(n_metagenome_reads)))
return inp, None

if subsampling_seed.lower() != 'random':
random.seed(int(subsampling_seed))
Expand Down Expand Up @@ -1238,7 +1239,9 @@ def subsample_reads(inp, subsampling, subsampling_seed, subsampling_output, tmp_

if isinstance(subsampling_output, list):
subsampling_output = ','.join(subsampling_output)

subsampling = subsampling*2


return subsampling_output, subsampling

def main():
Expand Down

0 comments on commit f624cc5

Please sign in to comment.