logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

samtools-reheader - replaces the header in the input file

Author

       Written by Heng Li with modifications by James Bonfield and Valeriu Ohan, all from the Sanger Institute.

Description

       Replace  the  header  in  in.bam  with  the  header  in  in.header.sam.  This command is much faster than
       replacing the header with a BAM→SAM→BAM conversion.

       By default this command outputs the BAM or CRAM file to standard output (stdout),  but  for  CRAM  format
       files  it  has  the  option  to  perform an in-place edit, both reading and writing to the same file.  No
       validity checking is performed on the header, nor that it is suitable  to  use  with  the  sequence  data
       itself.

Examples

       • Remove comment lines

           samtools reheader -c 'grep -v ^@CO' in.bam

       • Add  “Chr”  prefix to chromosome names.  Note extra backslashes before dollar signs to prevent unwanted
         shell variable expansion.

           samtools reheader -c 'perl -pe "s/^(@SQ.*)(\tSN:)(\d+|X|Y|MT)(\s|\$)/\$1Chr\$2\$3/"' in.bam

       • Remove “Chr” prefix

           samtools reheader -c 'perl -pe "s/^(@SQ.*)(\tSN:)Chr/\$1\$2/"' in.bam

Name

       samtools-reheader - replaces the header in the input file

Options

-P,--no-PG
               Do not add a @PG line to the header of the output file.

       -i,--in-place
               Perform  the  header edit in-place, if possible.  This only works on CRAM files and only if there
               is sufficient room to store the new header.  The amount of space available will differ  for  each
               CRAM file.

       -c,--commandCMD
               Allow  the header from in.bam to be processed by external CMD and read back the result. When used
               in this manner, the external header file in.header.sam has to be omitted.

               CMD must take the original header through stdin in SAM format and output the modified  header  to
               stdout.  CMD is passed to the system's command shell.  Care should be taken to ensure the command
               is quoted correctly to avoid unwanted shell expansions (for example of $ variables).

               CMD must return an exit status of zero.

See Also

samtools(1)

       Samtools website: <http://www.htslib.org/>

samtools-1.21                                   12 September 2024                           samtools-reheader(1)

Synopsis

       samtools reheader [-iP] [-cCMD | in.header.sam] in.bam

See Also