Hi,
I hope you are doing well, Thank you fro your work on metaphan3. I think I found a bug
I use metaphan3 with the --nreads, --unknown_estimation and --input_type sam, I have the following error message:
fraction_mapped_reads = min(tot_nreads/float(n_metagenome_reads), 1.0) if ESTIMATE_UNK else 1.0
TypeError: float() argument must be a string or a number, not 'NoneType'
I did a bit of digging in the code and found that the
-
n_metagenome_readsvariable is instantiated by themap2bbhfunction - this function instantiate an internal
n_metagenome_readsvariable with None (https://github.com/biobakery/MetaPhlAn/blob/446ee61b05a5063365a315ddba8c54bf45fcae66/metaphlan/metaphlan.py#L796) but doesn’t change the at any point wheninput_type == 'sam'https://github.com/biobakery/MetaPhlAn/blob/446ee61b05a5063365a315ddba8c54bf45fcae66/metaphlan/metaphlan.py#L804-L813. So the returned value is indeedNone. - later here https://github.com/biobakery/MetaPhlAn/blob/446ee61b05a5063365a315ddba8c54bf45fcae66/metaphlan/metaphlan.py#L1003-L1009 there is a check on
n_metagenome_reads(None) andpars['nreads'](the value I gave via the command line) but it only exit with an error (which is doesn’t because ars[‘nreads’]` has a value - Come https://github.com/biobakery/MetaPhlAn/blob/446ee61b05a5063365a315ddba8c54bf45fcae66/metaphlan/metaphlan.py#L1059-L1060, where the error happens,
n_metagenome_readsis still None, then it fails
Maybe pars[‘nreads’] should be used instead. This issue doesn’t occur when I omit the --unknown_estimation tag