picard.sam

## Class SamToFastq

- java.lang.Object
- - picard.cmdline.CommandLineProgram
  - - picard.sam.SamToFastq

-     public class SamToFastq
      extends CommandLineProgram

  Extracts read sequences and qualities from the input SAM/BAM file and writes them into the output file in Sanger fastq format. See MAQ FastQ specification for details. In the RC mode (default is True), if the read is aligned and the alignment is to the reverse strand on the genome, the read's sequence from input sam file will be reverse-complemented prior to writing it to fastq in order restore correctly the original read sequence as it was generated by the sequencer.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `String` | `CLIPPING_ACTION`
    `String` | `CLIPPING_ATTRIBUTE`
    `int` | `CLIPPING_MIN_LENGTH`
    `File` | `FASTQ`
    `boolean` | `INCLUDE_NON_PF_READS`
    `boolean` | `INCLUDE_NON_PRIMARY_ALIGNMENTS`
    `File` | `INPUT`
    `boolean` | `INTERLEAVE`
    `File` | `OUTPUT_DIR`
    `boolean` | `OUTPUT_PER_RG`
    `Integer` | `QUALITY`
    `boolean` | `RE_REVERSE`
    `Integer` | `READ1_MAX_BASES_TO_WRITE`
    `int` | `READ1_TRIM`
    `Integer` | `READ2_MAX_BASES_TO_WRITE`
    `int` | `READ2_TRIM`
    `String` | `RG_TAG`
    `File` | `SECOND_END_FASTQ`
    `File` | `UNPAIRED_FASTQ`

    - ### Fields inherited from class picard.cmdline.CommandLineProgram

      `COMPRESSION_LEVEL, CREATE_INDEX, CREATE_MD5_FILE, GA4GH_CLIENT_SECRETS, MAX_RECORDS_IN_RAM, QUIET, REFERENCE_SEQUENCE, TMP_DIR, VALIDATION_STRINGENCY, VERBOSITY`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SamToFastq()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected String[]` | `customCommandLineValidation()` Put any custom command-line validation in an override of this method.
    `protected int` | `doWork()` Do the work after command line has been parsed.
    `static void` | `main(String[] argv)`

    - ### Methods inherited from class picard.cmdline.CommandLineProgram

      `getCommandLine, getCommandLineParser, getDefaultHeaders, getMetricsFile, getNestedOptions, getNestedOptionsForHelp, getStandardUsagePreamble, getVersion, instanceMain, instanceMainWithExit, parseArgs, setDefaultHeaders`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INPUT

          @Option(doc="Input SAM/BAM file to extract reads from",
                  shortName="I")
          public File INPUT

    - #### FASTQ

          @Option(shortName="F",
                  doc="Output FASTQ file (single-end fastq or, if paired, first end of the pair FASTQ).",
                  mutex="OUTPUT_PER_RG")
          public File FASTQ

    - #### SECOND_END_FASTQ

          @Option(shortName="F2",
                  doc="Output FASTQ file (if paired, second end of the pair FASTQ).",
                  optional=true,
                  mutex="OUTPUT_PER_RG")
          public File SECOND_END_FASTQ

    - #### UNPAIRED_FASTQ

          @Option(shortName="FU",
                  doc="Output FASTQ file for unpaired reads; may only be provided in paired-FASTQ mode",
                  optional=true,
                  mutex="OUTPUT_PER_RG")
          public File UNPAIRED_FASTQ

    - #### OUTPUT_PER_RG

          @Option(shortName="OPRG",
                  doc="Output a FASTQ file per read group (two FASTQ files per read group if the group is paired).",
                  optional=true,
                  mutex={"FASTQ","SECOND_END_FASTQ","UNPAIRED_FASTQ"})
          public boolean OUTPUT_PER_RG

    - #### RG_TAG

          @Option(shortName="RGT",
                  doc="The read group tag (PU or ID) to be used to output a FASTQ file per read group.")
          public String RG_TAG

    - #### OUTPUT_DIR

          @Option(shortName="ODIR",
                  doc="Directory in which to output the FASTQ file(s).  Used only when OUTPUT_PER_RG is true.",
                  optional=true)
          public File OUTPUT_DIR

    - #### RE_REVERSE

          @Option(shortName="RC",
                  doc="Re-reverse bases and qualities of reads with negative strand flag set before writing them to FASTQ",
                  optional=true)
          public boolean RE_REVERSE

    - #### INTERLEAVE

          @Option(shortName="INTER",
                  doc="Will generate an interleaved fastq if paired, each line will have /1 or /2 to describe which end it came from")
          public boolean INTERLEAVE

    - #### INCLUDE_NON_PF_READS

          @Option(shortName="NON_PF",
                  doc="Include non-PF reads from the SAM file into the output FASTQ files. PF means \'passes filtering\'. Reads whose \'not passing quality controls\' flag is set are non-PF reads. See GATK Dictionary for more info.")
          public boolean INCLUDE_NON_PF_READS

    - #### CLIPPING_ATTRIBUTE

          @Option(shortName="CLIP_ATTR",
                  doc="The attribute that stores the position at which the SAM record should be clipped",
                  optional=true)
          public String CLIPPING_ATTRIBUTE

    - #### CLIPPING_ACTION

          @Option(shortName="CLIP_ACT",
                  doc="The action that should be taken with clipped reads: \'X\' means the reads and qualities should be trimmed at the clipped position; \'N\' means the bases should be changed to Ns in the clipped region; and any integer means that the base qualities should be set to that value in the clipped region.",
                  optional=true)
          public String CLIPPING_ACTION

    - #### CLIPPING_MIN_LENGTH

          @Option(shortName="CLIP_MIN",
                  doc="When performing clipping with the CLIPPING_ATTRIBUTE and CLIPPING_ACTION parameters, ensure that the resulting reads after clipping are at least CLIPPING_MIN_LENGTH bases long. If the original read is shorter than CLIPPING_MIN_LENGTH then the original read length will be maintained.")
          public int CLIPPING_MIN_LENGTH

    - #### READ1_TRIM

          @Option(shortName="R1_TRIM",
                  doc="The number of bases to trim from the beginning of read 1.")
          public int READ1_TRIM

    - #### READ1_MAX_BASES_TO_WRITE

          @Option(shortName="R1_MAX_BASES",
                  doc="The maximum number of bases to write from read 1 after trimming. If there are fewer than this many bases left after trimming, all will be written.  If this value is null then all bases left after trimming will be written.",
                  optional=true)
          public Integer READ1_MAX_BASES_TO_WRITE

    - #### READ2_TRIM

          @Option(shortName="R2_TRIM",
                  doc="The number of bases to trim from the beginning of read 2.")
          public int READ2_TRIM

    - #### READ2_MAX_BASES_TO_WRITE

          @Option(shortName="R2_MAX_BASES",
                  doc="The maximum number of bases to write from read 2 after trimming. If there are fewer than this many bases left after trimming, all will be written.  If this value is null then all bases left after trimming will be written.",
                  optional=true)
          public Integer READ2_MAX_BASES_TO_WRITE

    - #### QUALITY

          @Option(shortName="Q",
                  doc="End-trim reads using the phred/bwa quality trimming algorithm and this quality.",
                  optional=true)
          public Integer QUALITY

    - #### INCLUDE_NON_PRIMARY_ALIGNMENTS

          @Option(doc="If true, include non-primary alignments in the output.  Support of non-primary alignments in SamToFastq is not comprehensive, so there may be exceptions if this is set to true and there are paired reads with non-primary alignments.")
          public boolean INCLUDE_NON_PRIMARY_ALIGNMENTS

  - ### Constructor Detail

    - #### SamToFastq

          public SamToFastq()

  - ### Method Detail

    - #### main

          public static void main(String[] argv)

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

    - #### customCommandLineValidation

          protected String[] customCommandLineValidation()

      Put any custom command-line validation in an override of this method. clp is initialized at this point and can be used to print usage and access argv. Any options set by command-line parser can be validated.
      Overrides:
        `customCommandLineValidation` in class `CommandLineProgram`
      Returns:
        null if command line is valid. If command line is invalid, returns an array of error messages to be written to the appropriate place.