Package htsjdk.samtools

# Class SamFileValidator

java.lang.Object
htsjdk.samtools.SamFileValidator

public class SamFileValidator extends Object
Validates SAM files as follows:

- checks sam file header for sequence dictionary
- checks sam file header for read groups
- for each sam record
  - reports error detected by SAMRecord.isValid()
  - validates NM (nucleotide differences) exists and matches reality
  - validates mate fields agree with data in the mate record

See Also:
  - `SAMRecord.isValid()`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`SamFileValidator.ValidationMetrics`

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`MAX_QUALITY_NOT_STORED_ERRORS`

## Constructor Summary

Constructors
Constructor
Description
`SamFileValidator(PrintWriter out, int maxTempFiles)`

## Method Summary

Modifier and Type
Method
Description
`int`
`getNumErrors()`
Number of errors during SAM file validation
`int`
`getNumWarnings()`
Number of warnings during SAM file validation
`boolean`
`getSkipMateValidation()`
`boolean`
`isBisulfiteSequenced()`
`void`
`setBisulfiteSequenced(boolean bisulfiteSequenced)`
`void`
`setErrorsToIgnore(Collection<SAMValidationError.Type> types)`
Sets one or more error types that should not be reported on.
`void`
`setIgnoreWarnings(boolean ignoreWarnings)`
`SamFileValidator`
`setIndexValidationStringency(BamIndexValidator.IndexValidationStringency stringency)`
`void`
`setSkipMateValidation(boolean skipMateValidation)`
Sets whether or not we should run mate validation beyond the mate cigar check, which is useful in extreme edge cases that would require a lot of memory to do the validation.
`SamFileValidator`
`setValidateIndex(boolean validateIndex)`
Deprecated.
use `setIndexValidationStringency(htsjdk.samtools.BamIndexValidator.IndexValidationStringency)` instead
`void`
`setVerbose(boolean verbose, int maxVerboseOutput)`
Control verbosity
`void`
`validateBamFileTermination(File inputFile)`
`void`
`validateBamFileTermination(Path inputFile)`
`boolean`
`validateSamFileSummary(SamReader samReader, ReferenceSequenceFile reference)`
Outputs validation summary report to out.
`boolean`
`validateSamFileVerbose(SamReader samReader, ReferenceSequenceFile reference)`
Outputs validation error details to out.

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

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

## Field Details

### MAX_QUALITY_NOT_STORED_ERRORS

public static final int MAX_QUALITY_NOT_STORED_ERRORS

See Also:
  - Constant Field Values

## Constructor Details

### SamFileValidator

public SamFileValidator(PrintWriter out, int maxTempFiles)

## Method Details

### setErrorsToIgnore

public void setErrorsToIgnore(Collection<SAMValidationError.Type> types)
Sets one or more error types that should not be reported on.

### setIgnoreWarnings

public void setIgnoreWarnings(boolean ignoreWarnings)

### setSkipMateValidation

public void setSkipMateValidation(boolean skipMateValidation)
Sets whether or not we should run mate validation beyond the mate cigar check, which is useful in extreme edge cases that would require a lot of memory to do the validation.

Parameters:
  `skipMateValidation` - should this tool skip mate validation

### getSkipMateValidation

public boolean getSkipMateValidation()

Returns:
  true if the validator will skip mate validation, otherwise false

### validateSamFileSummary

public boolean validateSamFileSummary(SamReader samReader, ReferenceSequenceFile reference)
Outputs validation summary report to out.

Parameters:
  `samReader` - records to validate
  `reference` - if null, NM tag validation is skipped
Returns:
  boolean true if there are no validation errors, otherwise false

### validateSamFileVerbose

public boolean validateSamFileVerbose(SamReader samReader, ReferenceSequenceFile reference)
Outputs validation error details to out.

Parameters:
  `samReader` - records to validate
  `reference` - if null, NM tag validation is skipped processing will stop after this threshold has been reached
Returns:
  boolean true if there are no validation errors, otherwise false

### validateBamFileTermination

public void validateBamFileTermination(File inputFile)

### validateBamFileTermination

public void validateBamFileTermination(Path inputFile)

### getNumWarnings

public int getNumWarnings()
Number of warnings during SAM file validation

Returns:
  number of warnings

### getNumErrors

public int getNumErrors()
Number of errors during SAM file validation

Returns:
  number of errors

### setVerbose

public void setVerbose(boolean verbose, int maxVerboseOutput)
Control verbosity

Parameters:
  `verbose` - True in order to emit a message per error or warning.
  `maxVerboseOutput` - If verbose, emit no more than this many messages. Ignored if !verbose.

### isBisulfiteSequenced

public boolean isBisulfiteSequenced()

### setBisulfiteSequenced

public void setBisulfiteSequenced(boolean bisulfiteSequenced)

### setValidateIndex

@Deprecated public SamFileValidator setValidateIndex(boolean validateIndex)
Deprecated.
use `setIndexValidationStringency(htsjdk.samtools.BamIndexValidator.IndexValidationStringency)` instead

### setIndexValidationStringency

public SamFileValidator setIndexValidationStringency(BamIndexValidator.IndexValidationStringency stringency)