Package picard.sam

# Class SplitSamByLibrary

java.lang.Object
picard.cmdline.CommandLineProgram
picard.sam.SplitSamByLibrary

@DocumentedFeature public class SplitSamByLibrary extends CommandLineProgram
Command-line program to split a SAM/BAM/CRAM file into separate files based on library name.

This tool takes a SAM or BAM file and separates all the reads into one SAM or BAM file per library name. Reads that do not have a read group specified or whose read group does not have a library name are written to a file called 'unknown.' The format (SAM or BAM) of the output files matches that of the input file.

### Inputs

- The BAM or SAM file to be split
- The directory where the library SAM or BAM files should be written

### Output/h3>

- One SAM or BAM file per library name

#### Usage example:

         java -jar picard.jar SplitSamByLibrary \
              I=input_reads.bam \
              O=/output/directory/

## Field Summary

Fields
Modifier and Type
Field
Description
`File`
`INPUT`
`static final int`
`NO_LIBRARIES_SPECIFIED_IN_HEADER`
`File`
`OUTPUT`

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

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

## Constructor Summary

Constructors
Constructor
Description
`SplitSamByLibrary()`

## Method Summary

Modifier and Type
Method
Description
`protected int`
`doWork()`
Do the work after command line has been parsed.

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

`checkRInstallation, customCommandLineValidation, getCommandLine, getCommandLineParser, getCommandLineParserForArgs, getDefaultHeaders, getFaqLink, getMetricsFile, getPGRecord, 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 Details

### INPUT

@Argument(shortName="I", doc="The SAM, BAM of CRAM file to be split. ") public File INPUT

### OUTPUT

@Argument(shortName="O", doc="The directory where the per-library output files should be written (defaults to the current directory). ", optional=true) public File OUTPUT

### NO_LIBRARIES_SPECIFIED_IN_HEADER

public static final int NO_LIBRARIES_SPECIFIED_IN_HEADER

See Also:
  - Constant Field Values

## Constructor Details

### SplitSamByLibrary

public SplitSamByLibrary()

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