Sorts a SAM or BAM file.
Summary
This tool sorts the input SAM or BAM file by coordinate, queryname (QNAME), or some other property of the SAM
record. The SortOrder of a SAM/BAM file is found in the SAM file header tag labeled SO.
For a coordinate sorted SAM/BAM file, read alignments are sorted first by the reference sequence name (RNAME)
field using the reference sequence dictionary tag labeled SQ.
Alignments within these subgroups are secondarily sorted using the left-most mapping position of the read (POS).
Subsequent to this sorting scheme, alignments are listed arbitrarily.
For queryname-sorted alignments, all
alignments are grouped using the queryname field but the alignments are not necessarily sorted within these groups.
Reads having the same queryname are derived from the same template.
Inputs
- Input BAM or SAM file to sort
- Sorted BAM or SAM output file
- Sort order of output file
Usage example:
java -jar picard.jar SortSam \
INPUT=input.bam \
OUTPUT=sorted.bam \
SORT_ORDER=coordinate