bwa icon indicating copy to clipboard operation
bwa copied to clipboard

bugfix: HD line should be printed before SQ

Open nh13 opened this issue 2 years ago • 1 comments

Fixes a long standing bug, but made more apparent in https://github.com/lh3/bwa/pull/336. Thank @jmarshall for pointing this out.

I tested this by on my local machine three ways.

  1. Not specifying -H, so the default header line should be emitted at the start of the SAM:
./bwa mem phix.fasta phix.fastq 
[M::bwa_idx_load_from_disk] read 0 ALT contigs
@HD VN:1.5  SO:unsorted GO:query
@SQ SN:gi|9626372|ref|NC_001422.1|  LN:5386
...
  1. Specifying -H with @HD, so the user provided header line should be emitted at the start of the SAM:
./bwa mem -H '@HD  VN:1.4  SO:unsorted     GO:query'  phix.fasta phix.fastq 
[M::bwa_idx_load_from_disk] read 0 ALT contigs
@HD VN:1.4  SO:unsorted GO:query
@SQ SN:gi|9626372|ref|NC_001422.1|  LN:5386
...
  1. Specifying -H with @CO, so the default header line should be emitted at the start of the SAM, while the CO line should be after the SQ lines.
./bwa mem -H '@CO  ID:id' phix.fasta phix.fastq 
[M::bwa_idx_load_from_disk] read 0 ALT contigs
@HD	VN:1.5	SO:unsorted	GO:query
@SQ	SN:gi|9626372|ref|NC_001422.1|	LN:5386
@CO	ID:id

nh13 avatar Mar 07 '22 16:03 nh13

Superceded by #348, which completely refactors this function.

jmarshall avatar Mar 18 '22 23:03 jmarshall

Closing in favor of #348 (more flexible) and in the hopes that this increases the chances the latter is merged!

nh13 avatar Aug 31 '22 17:08 nh13