1samtools-reheader(1)         Bioinformatics tools         samtools-reheader(1)
2
3
4

NAME

6       samtools reheader - replaces the header in the input file
7

SYNOPSIS

9       samtools reheader [-iP] [-c CMD | in.header.sam ] in.bam
10
11

DESCRIPTION

13       Replace  the  header  in in.bam with the header in in.header.sam.  This
14       command is much faster than replacing the  header  with  a  BAM→SAM→BAM
15       conversion.
16
17       By default this command outputs the BAM or CRAM file to standard output
18       (stdout), but for CRAM format files it has the option to perform an in-
19       place  edit,  both  reading  and writing to the same file.  No validity
20       checking is performed on the header, nor that it  is  suitable  to  use
21       with the sequence data itself.
22
23

OPTIONS

25       -P, --no-PG
26               Do not add a @PG line to the header of the output file.
27
28       -i, --in-place
29               Perform the header edit in-place, if possible.  This only works
30               on CRAM files and only if there is sufficient room to store the
31               new header.  The amount of space available will differ for each
32               CRAM file.
33
34       -c, --command CMD
35               Allow the header from in.bam to be processed  by  external  CMD
36               and  read back the result. When used in this manner, the exter‐
37               nal header file in.header.sam has to be omitted.
38
39               CMD must take the original header through stdin in  SAM  format
40               and output the modified header to stdout.  CMD is passed to the
41               system's command shell.  Care should be  taken  to  ensure  the
42               command  is quoted correctly to avoid unwanted shell expansions
43               (for example of $ variables).
44
45               CMD must return an exit status of zero.
46
47

EXAMPLES

49       • Remove comment lines
50
51           samtools reheader -c 'grep -v ^@CO' in.bam
52
53
54       • Add “Chr” prefix to chromosome names.  Note extra backslashes  before
55         dollar signs to prevent unwanted shell variable expansion.
56
57           samtools reheader -c 'perl -pe "s/^(@SQ.*)(\tSN:)(\d+|X|Y|MT)(\s|\$)/\$1Chr\$2\$3/"' in.bam
58
59
60       • Remove “Chr” prefix
61
62           samtools reheader -c 'perl -pe "s/^(@SQ.*)(\tSN:)Chr/\$1\$2/"' in.bam
63
64
65

AUTHOR

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

SEE ALSO

72       samtools(1)
73
74       Samtools website: <http://www.htslib.org/>
75
76
77
78samtools-1.13                     7 July 2021             samtools-reheader(1)
Impressum