Package picard.sam

Class SortSam


  • @DocumentedFeature
    public class SortSam
    extends CommandLineProgram
    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, the tool orders records deterministically by queryname field followed by record strand orientation flag, primary record flag, and secondary alignment flag. (See SAMRecordQueryNameComparator.compare(SAMRecord, SAMRecord)} for details). This ordering may change in the future.

    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
     
    • Field Detail

      • INPUT

        @Argument(doc="Input BAM or SAM file to sort.",
                  shortName="I")
        public File INPUT
      • OUTPUT

        @Argument(doc="Sorted BAM or SAM output file.",
                  shortName="O")
        public File OUTPUT
      • SORT_ORDER

        @Argument(shortName="SO",
                  doc="Sort order of output file. ")
        public picard.sam.SortSam.SortOrder SORT_ORDER
    • Constructor Detail

      • SortSam

        public SortSam()
    • Method Detail

      • doWork

        protected int doWork()
        Description copied from class: CommandLineProgram
        Do the work after command line has been parsed. RuntimeException may be thrown by this method, and are reported appropriately.
        Specified by:
        doWork in class CommandLineProgram
        Returns:
        program exit status.