jtamames / SqueezeMeta

A complete pipeline for metagenomic analysis
GNU General Public License v3.0
346 stars 81 forks source link

Illegal division by zero in step 18.getbins.pl #836

Closed mradz19 closed 1 month ago

mradz19 commented 2 months ago

My project is stopping at step 18 with the error:

[0 seconds]: STEP18 -> CREATING BIN TABLE: 18.getbins.pl
  Method:DAS
  Reading checkM results in /data/full_project_2/intermediate/17.full_project_2.checkM
  Looking for bins in /data/full_project_2/results/bins
  Reading data for bin concoct.386.fa_sub.contigs           
  Calculating coverages
Illegal division by zero at /data/anaconda3/envs/SqueezeMeta/SqueezeMeta/scripts/18.getbins.pl line 168.
Stopping in STEP18 -> 18.getbins.pl
Died at /kusers/ancillary/anaconda3/envs/SqueezeMeta/bin/SqueezeMeta.pl line 831.

I saw that #815 had the same issue but I r syslog.txt eally don't want to start the binning again is this is a very large project. I have confirmed that none of the bins in results/bins are 0 bytes in size, they are all at least 1MB.

I have also attached the syslog file

fpusan commented 2 months ago

Can you go to the results/bins directory and run the following code?

python3 -c """
from glob import glob
fs = glob('*tax')
for f in fs:
    for line in open(f):
         if line.startswith('Consensus'):
             print(f, line.split('\t')[1])
             break
    else:
        print(f, 'NO RESULT')
"""

You should get the size for each bin. Let me know if some bin shows NO RESULT instead of the size.

mradz19 commented 2 months ago

Thanks for your help! The very last bin says no result:

concoct.386.fa_sub.contigs.fa.tax NO RESULT
fpusan commented 2 months ago

Can you share that file with us?

mradz19 commented 2 months ago

Sure here is a link to the file:

https://we.tl/t-8KInNTDveF

fpusan commented 2 months ago

Any chance that step 16 (16.addtax2.pl) died midway? Can you check whether all the fasta files for the bins in /data/full_project_2/results/bins have an associated *.fa.tax file?

mradz19 commented 2 months ago

Most don't have an associated tax file, about 25% of them do. Will I have to repeat from step 16?

fpusan commented 2 months ago

Try running step 16 alone (16.addtax2.pl /path/to/project) then we double check whether everything looks correct and, if so, restart from step 17.

mradz19 commented 2 months ago

Ok I will run that and update when it is finished

mradz19 commented 1 month ago

Ok it ran for a little while and stopped part way through:

  Adding SqueezeMeta taxonomy for concoct.381.fa.contigs.fa
  Calculating consensus taxonomy using mode s
  Adding SqueezeMeta taxonomy for concoct.382.fa_sub.contigs.fa
  Calculating consensus taxonomy using mode s
  Adding SqueezeMeta taxonomy for concoct.383.fa_sub.contigs.fa
  Calculating consensus taxonomy using mode s
  Adding SqueezeMeta taxonomy for concoct.386.fa_sub.contigs.fa
Killed

It seems to be stopping at the same bin:

concoct.386.fa_sub.contigs.fa.tax NO RESULT
fpusan commented 1 month ago

How many contigs are there in that Bin?

mradz19 commented 1 month ago

Nevermind I believe it is 176004

grep -c "^>" concoct.386.fa_sub.contigs.fa
176004
mradz19 commented 1 month ago

It seems the tax file for this bin is predominantly chordata, could I try just deleting this bin then re-running step 16 or would that cause issues?

fpusan commented 1 month ago

Not 100% sure but will probably work. The error happens because the Bin is too large for our disparity calculation algorithm. We actually added a check for this a while ago, but the fix hasn't made an official release yet. https://raw.githubusercontent.com/jtamames/SqueezeMeta/binonly/scripts/16.addtax2.pl This would be the link to the updated code, in case you want to replace your script by the fixed one.

mradz19 commented 1 month ago

Just an update. I used the new code you attached and step 16 completed successfully, it just skipped the larger bin. I then restarted from step 18 and the run finished without issue. Thanks for your help.

fpusan commented 1 month ago

Glad to hear, closing issue!