when I used minimap2 to map Illunima paired reads to assemebled contigs, the header of the sam file seems to be wrong.
my minimap2 code is : minimap2 -ax sr ../contigs.longer500.fasta ../../4PF-0-10_1_R1.fq ../../4PF-0-10_1_R2.fq > 4PF_mapping_aln.sam
the header of sam is:
[M::mm_idx_gen::4.2701.41] collected minimizers
[M::mm_idx_gen::4.8921.60] sorted minimizers
@SQ SN:NODE_1_length_85864_cov_10.921310 LN:85864
@SQ SN:NODE_2_length_74117_cov_12.025521 LN:74117
@SQ SN:NODE_3_length_71198_cov_10.602147 LN:71198
.......
after that, I convert .sam file to .bam file using samtools, there is an error like this:
[samopen] no @SQ lines in the header.
[sam_read1] missing header? Abort!
Did you use nohup with this alignment? Your stderr is mixed with your stdout (the sam file).
This is another example of why it is good for tools to have a -o FILE option to do built-in output redirection, rather than depending on shell redirections to do the simple expected thing in less simple circumstances like nohup.
Happily minimap2 has acquired such an option in 8b05880f73c76ccc00d2d1aa62eb3c999ca1c130.
As @wdecoster and @jmarshall said. Another solution is to use -v1 to disable messages and warnings. Nonetheless, it is still recommended to get familiar with piping. That way you can directly generate a BAM file, saving both disk space and wall-clock time.
@wdecoster @jmarshall @lh3 thanks a lot. But how can I generate a BAM file using minimap2 directly ?
By piping the output of minimap2 into samtools:
minimap2 -ax sr ../contigs.longer500.fasta ../../4PF-0-10_1_R1.fq ../../4PF-0-10_1_R2.fq | samtools sort -o 4PF_mapping_aln.bam
Note that this may not solve your issue if you use nohup.
Most helpful comment
This is another example of why it is good for tools to have a
-o FILEoption to do built-in output redirection, rather than depending on shell redirections to do the simple expected thing in less simple circumstances like nohup.Happily minimap2 has acquired such an option in 8b05880f73c76ccc00d2d1aa62eb3c999ca1c130.