Skip site navigation (1)Skip section navigation (2)

FreeBSD Manual Pages

  
 
  

home | help
samtools-reheader(1)	      Bioinformatics tools	    samtools-reheader(1)

NAME
     samtools reheader - replaces the header in the input file

SYNOPSIS
     samtools reheader [-iP] [-c CMD | in.header.sam] in.bam

DESCRIPTION
     Replace  the  header in in.bam with the header in in.header.sam.  This com-
     mand is much faster than replacing the header with a BAM->SAM->BAM  conver-
     sion.

     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 check-
     ing is performed on the header, nor that it is suitable to use with the se-
     quence data itself.

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, --command CMD
	     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 sys-
	     tem'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.

EXAMPLES
     * Remove comment lines

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

     * Add "Chr" prefix to chromosome names.  Note extra backslashes before dol-
       lar 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

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

SEE ALSO
     samtools(1)

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

samtools-1.23.1 		  18 March 2026 	    samtools-reheader(1)

Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=samtools-reheader&sektion=1&manpath=FreeBSD+Ports+15.1.quarterly>

home | help