Package htsjdk.samtools

# Class SAMLineParser

java.lang.Object
htsjdk.samtools.SAMLineParser

public class SAMLineParser extends Object
This class enables creation of a SAMRecord object from a String in SAM text format. The SAM flag field will be inferred for each record separately, unless the expected format is set using `withSamFlagField`.

## Constructor Summary

Constructors
Constructor
Description
`SAMLineParser(SAMFileHeader samFileHeader)`
Public constructor.
`SAMLineParser(SAMFileHeader samFileHeader, SamReader samFileReader, File samFile)`
Public constructor.
`SAMLineParser(SAMRecordFactory samRecordFactory, ValidationStringency validationStringency, SAMFileHeader samFileHeader, SamReader samFileReader, File samFile)`
Public constructor.

## Method Summary

Modifier and Type
Method
Description
`SAMFileHeader`
`getFileHeader()`
Get the File header.
`ValidationStringency`
`getValidationStringency()`
Get validation stringency.
`SAMRecord`
`parseLine(String line)`
Parse a SAM line.
`SAMRecord`
`parseLine(String line, int lineNumber)`
Parse a SAM line.
`SAMLineParser`
`withSamFlagField(SamFlagField samFlagField)`
Sets the expected SAM flag type expected for all records.

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

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

## Constructor Details

### SAMLineParser

public SAMLineParser(SAMFileHeader samFileHeader)
Public constructor. Use the default SAMRecordFactory and stringency.

Parameters:
  `samFileHeader` - SAM file header

### SAMLineParser

public SAMLineParser(SAMFileHeader samFileHeader, SamReader samFileReader, File samFile)
Public constructor. Use the default SAMRecordFactory and stringency.

Parameters:
  `samFileHeader` - SAM file header
  `samFileReader` - SAM file reader For passing to SAMRecord.setFileSource, may be null.
  `samFile` - SAM file being read (for error message only, may be null)

### SAMLineParser

public SAMLineParser(SAMRecordFactory samRecordFactory, ValidationStringency validationStringency, SAMFileHeader samFileHeader, SamReader samFileReader, File samFile)
Public constructor.

Parameters:
  `samRecordFactory` - SamRecord Factory
  `validationStringency` - validation stringency
  `samFileHeader` - SAM file header
  `samFileReader` - SAM file reader For passing to SAMRecord.setFileSource, may be null.
  `samFile` - SAM file being read (for error message only, may be null)

## Method Details

### getFileHeader

public SAMFileHeader getFileHeader()
Get the File header.

Returns:
  the SAM file header

### getValidationStringency

public ValidationStringency getValidationStringency()
Get validation stringency.

Returns:
  validation stringency

### withSamFlagField

public SAMLineParser withSamFlagField(SamFlagField samFlagField)
Sets the expected SAM flag type expected for all records.

### parseLine

public SAMRecord parseLine(String line)
Parse a SAM line.

Parameters:
  `line` - line to parse
Returns:
  a new SAMRecord object

### parseLine

public SAMRecord parseLine(String line, int lineNumber)
Parse a SAM line.

Parameters:
  `line` - line to parse
  `lineNumber` - line number in the file. If the line number is not known can be invalid input: '<'=0.
Returns:
  a new SAMRecord object