Package picard.sam

Class ReorderSam


@DocumentedFeature public class ReorderSam extends CommandLineProgram
Reorders a SAM/BAM input file according to the order of contigs in a second reference file.

Summary

Not to be confused with SortSam which sorts a SAM or BAM file with a valid sequence dictionary, ReorderSam reorders reads in a SAM/BAM file to match the contig ordering in a provided reference file, as determined by exact name matching of contigs. Reads mapped to contigs absent in the new reference are unmapped. Runs substantially faster if the input is an indexed BAM file.

Example

     java -jar picard.jar ReorderSam \
          INPUT=sample.bam \
          OUTPUT=reordered.bam \
          SEQUENCE_DICTIONARY=reference_with_different_order.dict
 

Caveats

Note that REFERENCE_SEQUENCE is used for reading the INPUT, (e.g. when reading cram files) not for determining the order of the OUTPUT. For that you must specify the SEQUENCE_DICTIONARY argument.
  • Field Details

    • INPUT

      @Argument(shortName="I", doc="Input file (SAM/BAM/CRAM) to extract reads from.") public File INPUT
    • OUTPUT

      @Argument(shortName="O", doc="Output file (SAM/BAM/CRAM) to write extracted reads to.") public File OUTPUT
    • SEQUENCE_DICTIONARY

      @Argument(shortName="SD", doc="A Sequence Dictionary for the OUTPUT file (can be read from one of the following file types (SAM, BAM, CRAM, VCF, BCF, Interval List, Fasta, or Dict)") public File SEQUENCE_DICTIONARY
    • ALLOW_INCOMPLETE_DICT_CONCORDANCE

      @Argument(shortName="S", doc="If true, allows only a partial overlap of the original contigs with the new reference sequence contigs. By default, this tool requires a corresponding contig in the new reference for each read contig") public boolean ALLOW_INCOMPLETE_DICT_CONCORDANCE
    • ALLOW_CONTIG_LENGTH_DISCORDANCE

      @Argument(shortName="U", doc="If true, then permits mapping from a read contig to a new reference contig with the same name but a different length. Highly dangerous, only use if you know what you are doing.") public boolean ALLOW_CONTIG_LENGTH_DISCORDANCE
  • Constructor Details

    • ReorderSam

      public ReorderSam()
  • Method Details

    • 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.