Package picard.analysis

## Class SinglePassSamProgram

- java.lang.Object
- - picard.cmdline.CommandLineProgram
  - - picard.analysis.SinglePassSamProgram

- Direct Known Subclasses:
    `CollectAlignmentSummaryMetrics`, `CollectBaseDistributionByCycle`, `CollectGcBiasMetrics`, `CollectInsertSizeMetrics`, `CollectQualityYieldMetrics`, `CollectRnaSeqMetrics`, `CollectSequencingArtifactMetrics`, `MeanQualityByCycle`, `QualityScoreDistribution`

      public abstract class SinglePassSamProgram
      extends CommandLineProgram

  Super class that is designed to provide some consistent structure between subclasses that simply iterate once over a coordinate sorted BAM and collect information from the records as the go in order to produce some kind of output.

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `boolean` | `ASSUME_SORTED` |
    `File` | `INPUT` |
    `File` | `OUTPUT` |
    `long` | `STOP_AFTER` |

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

      `COMPRESSION_LEVEL, CREATE_INDEX, CREATE_MD5_FILE, GA4GH_CLIENT_SECRETS, MAX_RECORDS_IN_RAM, QUIET, REFERENCE_SEQUENCE, referenceSequence, specialArgumentsCollection, TMP_DIR, USE_JDK_DEFLATER, USE_JDK_INFLATER, VALIDATION_STRINGENCY, VERBOSITY`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `SinglePassSamProgram()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected abstract void` | `acceptRead​(htsjdk.samtools.SAMRecord rec, htsjdk.samtools.reference.ReferenceSequence ref)` | Should be implemented by subclasses to accept SAMRecords one at a time.
    `protected int` | `doWork()` | Final implementation of doWork() that checks and loads the input and optionally reference sequence files and the runs the sublcass through the setup() acceptRead() and finish() steps.
    `protected abstract void` | `finish()` | Should be implemented by subclasses to do one-time finalization work.
    `static void` | `makeItSo​(File input, File referenceSequence, boolean assumeSorted, long stopAfter, Collection<SinglePassSamProgram> programs)` |
    `void` | `setReferenceSequence​(File referenceFile)` | Set the reference File.
    `protected abstract void` | `setup​(htsjdk.samtools.SAMFileHeader header, File samFile)` | Should be implemented by subclasses to do one-time initialization work.
    `protected boolean` | `usesNoRefReads()` | Can be overridden and set to false if the section of unmapped reads at the end of the file isn't needed.

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

      `customCommandLineValidation, getCommandLine, getCommandLineParser, getDefaultHeaders, getFaqLink, getMetricsFile, getStandardUsagePreamble, getStandardUsagePreamble, getVersion, hasWebDocumentation, instanceMain, instanceMainWithExit, makeReferenceArgumentCollection, parseArgs, requiresReference, setDefaultHeaders, useLegacyParser`

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

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

- - ### Field Detail

    - #### INPUT

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

    - #### OUTPUT

          @Argument(shortName="O",
                    doc="File to write the output to.")
          public File OUTPUT

    - #### ASSUME_SORTED

          @Argument(doc="If true (default), then the sort order in the header file will be ignored.",
                    shortName="AS")
          public boolean ASSUME_SORTED

    - #### STOP_AFTER

          @Argument(doc="Stop after processing N reads, mainly for debugging.")
          public long STOP_AFTER

  - ### Constructor Detail

    - #### SinglePassSamProgram

          public SinglePassSamProgram()

  - ### Method Detail

    - #### setReferenceSequence

          public void setReferenceSequence​(File referenceFile)

      Set the reference File.

    - #### doWork

          protected final int doWork()

      Final implementation of doWork() that checks and loads the input and optionally reference sequence files and the runs the sublcass through the setup() acceptRead() and finish() steps.
      Specified by:
        `doWork` in class `CommandLineProgram`
      Returns:
        program exit status.

    - #### makeItSo

          public static void makeItSo​(File input,
                                      File referenceSequence,
                                      boolean assumeSorted,
                                      long stopAfter,
                                      Collection<SinglePassSamProgram> programs)

    - #### usesNoRefReads

          protected boolean usesNoRefReads()

      Can be overridden and set to false if the section of unmapped reads at the end of the file isn't needed.

    - #### setup

          protected abstract void setup​(htsjdk.samtools.SAMFileHeader header,
                                        File samFile)

      Should be implemented by subclasses to do one-time initialization work.

    - #### acceptRead

          protected abstract void acceptRead​(htsjdk.samtools.SAMRecord rec,
                                             htsjdk.samtools.reference.ReferenceSequence ref)

      Should be implemented by subclasses to accept SAMRecords one at a time. If the read has a reference sequence and a reference sequence file was supplied to the program it will be passed as 'ref'. Otherwise 'ref' may be null.

    - #### finish

          protected abstract void finish()

      Should be implemented by subclasses to do one-time finalization work.