Replaces the SAMFileHeader in a SAM or BAM file. This tool makes it possible to replace the header of a SAM or BAM file with the header of anotherfile, or a header block that has been edited manually (in a stub SAM file). The sort order (@SO) of the two input files must be the same.Note that validation is minimal, so it is up to the user to ensure that all the elements referred to in the SAMRecords are present in the new header.
java -jar picard.jar ReplaceSamHeader I=input_1.bam HEADER=input_2.bam O=bam_with_new_head.bam
INPUT (File) SAM file from which SAMRecords will be read. Required.
HEADER (File) SAM file from which SAMFileHeader will be read. Required.
OUTPUT (File) SAMFileHeader from HEADER file will be written to this file, followed by SAMRecords from INPUT file Required.