lh3 / bwa

Burrow-Wheeler Aligner for short-read alignment (see minimap2 for long-read alignment)
GNU General Public License v3.0
1.54k stars 556 forks source link

bugfix: HD line should be printed before SQ #345

Closed nh13 closed 2 years ago

nh13 commented 2 years ago

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
    ...
  2. 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
    ...
  3. 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
jmarshall commented 2 years ago

Superceded by #348, which completely refactors this function.

nh13 commented 2 years ago

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