Thursday, May 3, 2012

How can i edit some rows in .bam header file? - BioStar

How can i edit some rows in .bam header file? - BioStar


Question: How can i edit some rows in .bam header file?

 
2
 
 

For example i have the following already in the bam header:

@RG ID:110131_SN107_0398_A81DDCABXX_LANE2   PL:ILLUMINA LB:P0007    SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE4 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE6 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE8 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE2 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE4 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE6 PL:ILLUMINA LB:P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE8 PL:ILLUMINA LB:P0007 SM:tumor

i want to make it:

@RG ID:110131_SN107_0398_A81DDCABXX_LANE2   PL:ILLUMINA LB:tumor_P0007  SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE4 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE6 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0398_A81DDCABXX_LANE8 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE2 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE4 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE6 PL:ILLUMINA LB:tumor_P0007 SM:tumor
@RG ID:110131_SN107_0399_B81CYUABXX_LANE8 PL:ILLUMINA LB:tumor_P0007 SM:tumor

Thanks.

 
 

1 answer



 
12
 
 
 

samtools view -H mybamfile.bam | sed -e 's/LB:/LB:tumor_/' | samtools reheader - mybamfile.bam > mybamfile.reheadered.bam

No comments:

Post a Comment