This is a test version of Biostars. For the public version, visit https://www.biostars.org.
I made an error when using metawrap to binning

my code

metawrap binning -o bin_out -t 24 -m 200 -a all_contig/all_merge.fasta --metabat2 --maxbin2 --concoct all_fastq/*fastq

Error reported as follows

sorting the SRR10492802 alignment file
[bam_sort_core] merging from 24 files and 24 in-memory blocks...
[E::sam_hdr_sanitise] Malformed SAM header at line 2
samtools sort: failed to read header from "bin_out/work_files/tmp-samtools.0000.bam"
somthing  went wrong with sortin the alignments
Exiging

There is the header of sam file.

$samtools view -H SRR10492802.sam|head -10
@SQ SN:k141_390421 LN:651
@SQ SN:k141_39985 LN:538
@SQ SN:k141_334641 LN:682
@SQ SN:k141_55776 LN:692
@SQ SN:k141_39781 LN:589
@SQ SN:k141_450722 LN:843
@SQ SN:k141_563831 LN:707
@SQ SN:k141_350441 LN:651
@SQ SN:k141_270821 LN:1427
@SQ SN:k141_111552 LN:779

Request answers for me how to solve the problem. Thank you very much.

metagenome binning metawrap

2 answers

It appears that the file "bin_out/work_files/tmp-samtools.0000.bam" is broked or empty. You should use ls -lh to check the file size, not "SRR10492802.sam".

Additionally, you can try rerunning the command without the "--concoct" option, because concoct often performs poorly.

Thanks for the suggestion, but removing -concoct doesn't seem to solve the problem

You should post some log file to help me understand your situation. By the way, have you checked the size of "bin_out/work_files/tmp-samtools.0000.bam"? If the binning process has stopped, you should remove the tmp file before start a new mission.

The paragraph at the end of the log file may be the problem

[M::mem_pestat] skip orientation RR as there are not enough pairs
[M::mem_pestat]skip orientation FF
[M::mem_pestat]skip orientation RF
[main] Version:0.7.17-r1188
[main] CMD : bwa mem -v 1 -t 24 bin_out/work_files/assembly.fa all_fastq/SRR10492802_1.fastq all_fastq/SRR10492802_2.fastq
[main]Real time:6587.072 sec; CPU: 143464.657 sec
sorting the SRR10492802 alignment file
[bam_sort_core] merging from 24 files and 24 in-memory blocks...
[E::sam_hdr_sanitise] Malformed SAM header at line 2
samtools sort: failed to read header from "bin_out/work_files/tmp-samtools.0000.bam"
somthing  went wrong with sortin the alignments
Exiging

Also, I checked the output file and did not find the presence of the tmp-samtools.0000.bam file, which appears to be a temporary file that seems to have been cleaned after the software interruption

Check that the bam file exists at

bin_out/work_files/tmp-samtools.0000.bam

Also check the file has a header

samtools view -H bin_out/work_files/tmp-samtools.0000.bam

And it looks ok - you'll need to read the package docs there.

Also, I checked the output file and did not find the presence of the tmp-samtools.0000.bam file, which appears to be a temporary file that seems to have been cleaned after the software interruption

Log in to answer this question.