Hi,
If you make chr22 the first SQ record in the new header it should be okay.
@HD VN:1.0
@SQ SN:chr22 LN:51304566
@SQ SN:chr1 LN:249250621
@SQ SN:chr2 LN:243199373
@SQ SN:chr3 LN:198022430
@SQ SN:chr4 LN:191154276
@PG ID:segemehl VN:0.1.7-$Rev: 411 $ ($Date: 2014-06-18 ...
You could also do this using samtools view to convert to SAM without the
header and then use cat to add the new header and convert back to bam.
samtools view s1_chr22.bam > s1_chr22.sam
cat new_header.sam s1_chr22.sam | samtools view -Sb - > new.bam
Kind Regards,
Colin
Colin Hercus,
*Novocraft Technologies Sdn Bhd* <http://www.novocraft.com/>
C-23A-05, 3 Two Square, Jalan 19/1, Section 19,
46300 Petaling Jaya, Selangor Darul Ehsan, Malaysia
Tel: +6016 2482 668 Fax: +603 7960 0540
www.novocraft.com
On 27 August 2014 13:21, [email protected] <[email protected]> wrote:
> Dear Mr.samtools,
>
> I'm Jiessie, a bioinformatic beginner from China, very sorry to
> disturb you!
> I've used the "samtools reheader " command to replace the header of my
> bam files, but the output file showed a small error as follows:
>
> *[my command] : *samtools reheader new.header.sam s1_chr22.bam >
> reheader.s1_chr22.bam
>
> *[the original header of bam file]:*
> @HD VN:1.0
> @SQ SN:chr22 LN:51304566
> @PG ID:segemehl VN:0.1.7-$Rev: 411 $ ($Date: 2014-06-18 ...
>
> *[the content of new.head.sam]:*
> @HD VN:1.0
> @SQ SN:chr1 LN:249250621
> @SQ SN:chr2 LN:243199373
> @SQ SN:chr3 LN:198022430
> @SQ SN:chr4 LN:191154276
> @SQ SN:chr22 LN:51304566
> @PG ID:segemehl VN:0.1.7-$Rev: 411 $ ($Date: 2014-06-18 ...
>
> *[the original bam file (brief view)]:*
> HWI-ST1269:287:H9BA4ADXX:1:1101:3481:1993 1:N:0 99 chr22 22890685 255 99M
> = 22890824 233 NGGGGG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3481:1993 2:N:0 147 chr22 22890824 255
> 94M = 22890685 -233 GGAGGG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3516:1883 2:N:0 145 chr22 29695606 255
> 94M * 0 0 GGTGGCCCTGGTGG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3516:1883 1:N:0 321 chr22 29694857 255
> 29M * 0 0 CGAGCTGGAGACTG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3516:1883 1:N:0 321 chr22 29695224 255
> 69M * 0 0 GGGTTGTGGAAACC
> HWI-ST1269:287:H9BA4ADXX:1:1101:3778:1975 1:N:0 83 chr22 29678425 255 99M
> = 29674081 -4250
>
> *[bam file after replacing its header(brief view)]:*
> HWI-ST1269:287:H9BA4ADXX:1:1101:3481:1993 1:N:0 99 chr1 22890685 255 99M
> = 22890824 233 NGGGGG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3481:1993 2:N:0 147 chr1 22890824 255 94M
> = 22890685 -233 GGAGGG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3516:1883 2:N:0 145 chr1 29695606 255 94M
> * 0 0 GGTGGCCCTGGTGG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3516:1883 1:N:0 321 chr1 29694857 255 29M
> * 0 0 CGAGCTGGAGACTG
> HWI-ST1269:287:H9BA4ADXX:1:1101:3516:1883 1:N:0 321 chr1 29695224 255 69M
> * 0 0 GGGTTGTGGAAACC
> HWI-ST1269:287:H9BA4ADXX:1:1101:3778:1975 1:N:0 83 chr1 29678425 255 99M
> = 29674081 -4250
>
>
> The header of the output bam file has been changed successfully, but the
> column related to chrmosome_id has been converted into *chr1*, it's not
> the fruit I want.
> Samtools-Version: 0.1.19-44428cd
>
> I don't know why it comes and how to solve it.
>
> Best regards,
>
> Jessie
>
> ------------------------------
> Jessie Yang
> Bioinformatic Research
> Annoroad Gene Technology, China
> Building B2, Yizhuang Biomedical Park, Kechuang 6 Rd,
> Beijing Economic-Technologic al Development Area ,Beijing, China, 100176
> Email:[email protected]
> Tel: +86 15311439112
> Website: www.annoroad.com
>
>
> ------------------------------------------------------------------------------
> Slashdot TV.
> Video for Nerds. Stuff that matters.
> http://tv.slashdot.org/
> _______________________________________________
> Samtools-help mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/samtools-help
>
>
------------------------------------------------------------------------------
Slashdot TV.
Video for Nerds. Stuff that matters.
http://tv.slashdot.org/
_______________________________________________
Samtools-help mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/samtools-help