Peter

Thanks for your help. Long explanation below, but for those of you trying to 
fix a lexicographically ordered BAM so that it can be used by GATK, here's the 
bottom line:
- samtools reheader just changes the names of the contigs (bobschr1 becomes 
bigDNApieceA) in the header and in the reads
- picard tools ReorderSam will rearrange the reads according to a reference 
genome; as long as the reference is numerically ordered, you'll get the BAM you 
need.

Long explaination:
When I used samtools reheader to try to fix my BAM, the command line below gave 
me a non-nonsensical (i.e. usable) output:
$ samtools reheader reheader.sam accepted_hits.bam > accepted_hits_reheader2.bam
# reheader.sam is a SAM/TXT file with the 
#     desired numerically sorted header
# accepted_hits.bam is the BAM file with 
#     the problematic lexicographically 
#     sorted header
# accepted_hits_reorder2.bam is the output
#     BAM with the "fixed" header

Unfortunately, this process not only relabeled the header, but also renamed 
each of the reads:
Thus, this:
HWI-ST976:117:C00CUACXX:6:2207:15663:154327     0       chr1    15659   255     
51M     *       0       0...
Became this:
HWI-ST976:117:C00CUACXX:6:2207:15663:154327     0       chrM    15659   255     
51M     *       0       0...

Which is not helpful.



Joshua Theisen, MD-PhD
Pediatric Resident Physician, PGY-3
St. Louis Children's Hospital


-----Original Message-----
From: Peter Cock [mailto:p.j.a.c...@googlemail.com] 
Sent: Tuesday, October 14, 2014 11:12
To: Joshua Theisen
Cc: samtools-help@lists.sourceforge.net
Subject: Re: [Samtools-help] samtools reheader causes terminal to flicker

On Tue, Oct 14, 2014 at 5:03 PM, Joshua Theisen <joshua.thei...@gmail.com> 
wrote:
> I have a BAM with the @SQ lines of the header in lexigraphical order 
> instead of numerical order:
>
> ***Have:
> @HD     VN:1.0  SO:coordinate
> @SQ     SN:chr1 LN:249250621
> @SQ     SN:chr10        LN:135534747
> @SQ     SN:chr11        LN:135006516
> @SQ     SN:chr12        LN:133851895
> |       |               |
> @SQ     SN:chr19        LN:59128983
> @SQ     SN:chr2 LN:243199373
> @SQ     SN:chr20        LN:63025520
> @SQ     SN:chr21        LN:48129895
> @SQ     SN:chr22        LN:51304566
> @SQ     SN:chr3 LN:198022430
> |       |       |
> @SQ     SN:chrM LN:16571
> @SQ     SN:chrX LN:155270560
> @SQ     SN:chrY LN:59373566
> @PG     ID:TopHat       VN:2.0.0
>
> ***Want:
> @HD     VN:1.0  SO:coordinate
> @SQ     SN:chr1 LN:249250621
> @SQ     SN:chr2 LN:243199373
> |       |       |
> @SQ     SN:chr9 LN:141213431
> @SQ     SN:chr10        LN:135534747
> @SQ     SN:chr11        LN:135006516
> |       |               |
> @SQ     SN:chr22        LN:51304566
> @SQ     SN:chrX LN:155270560
> @SQ     SN:chrY LN:59373566
> @SQ     SN:chrM LN:16571
> @PG     ID:TopHat       VN:2.0.0
>
>
> I'm trying to use samtools reheader using this pipeline:
>
> # extract header from BAM to SAM
> $ samtools view -H accepted_hits.bam > header.sam
>
> # manually edit header using vi, save as reheader.sam
>
> # replace header in orginal BAM file
> $ samtools reheader reheader.sam accepted_hits.bam
>
> When I do this I get flickering symbols in the PuTTY terminal and no 
> change to the BAM. Any ideas?

Those flickering symbols are the output BAM file, like most samtools command 
the output defaults to stdout, so pipe it:

samtools reheader reheader.sam > accepted_hits.bam

I'm not sure what reheader did with the extra argument - if it was simply 
ignored that is probably a bug.

Note this will not actually sort the records in the order you want.
Why are you trying to do this anyway?

Peter


------------------------------------------------------------------------------
Comprehensive Server Monitoring with Site24x7.
Monitor 10 servers for $9/Month.
Get alerted through email, SMS, voice calls or mobile push notifications.
Take corrective actions from your mobile device.
http://p.sf.net/sfu/Zoho
_______________________________________________
Samtools-help mailing list
Samtools-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/samtools-help

Reply via email to