Documentation ¶
Overview ¶
Package fastq provides code for working with FASTQ format data. https://en.wikipedia.org/wiki/FASTQ_format.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrShort is returned when a truncated FASTQ file is encountered. ErrShort = errors.New("short FASTQ file") // ErrInvalid is returned when an invalid FASTQ file is encountered. ErrInvalid = errors.New("invalid FASTQ file") // ErrDiscordant is returned when two underlying FASTQ files are discordant. ErrDiscordant = errors.New("discordant FASTQ pairs") )
Functions ¶
func Downsample ¶
func Downsample(ctx context.Context, rate float64, r1Path, r2Path string, r1Out, r2Out io.Writer) error
Downsample writes read pairs from the two files to r1Out and r2Out. Read pairs will be randomly selected for inclusion in the output at the given sampling rate.
func DownsampleToCount ¶
func DownsampleToCount(ctx context.Context, count int64, r1Path, r2Path string, r1Out, r2Out io.Writer) (err error)
DownsampleToCount writes read pairs from the two files to r1Out and r2Out. Read pairs will be randomly selected for inclusion in the output to downsample to the given count, approximately.
Types ¶
type Field ¶
type Field uint
Field enumerates FASTQ fields. It is used to specify fields to read in NewScanner.
type PairScanner ¶
type PairScanner struct {
// contains filtered or unexported fields
}
PairScanner composes a pair of scanners to scan a pair of FASTQ streams.
func NewPairScanner ¶
func NewPairScanner(r1, r2 io.Reader, fields Field) *PairScanner
NewPairScanner creates a new FASTQ pair scanner from the provided R1 and R2 readers.
func (*PairScanner) Err ¶
func (p *PairScanner) Err() error
Err returns the scanning error, if any. It should be checked after Scan returns false.
func (*PairScanner) Scan ¶
func (p *PairScanner) Scan(r1, r2 *Read) bool
Scan scans the next read pair into r1, r2. Scan returns a boolean indicating whether the scan succeeded. Once Scan returns false, it never returns true again. Upon completion, the user should check the Err method to determine whether scanning stopped because of an error or because the end of the stream was reached.
type Read ¶
type Read struct {
ID, Seq, Unk, Qual string
}
A Read is a FASTQ read, comprising an ID, sequence, line 3 ("unknown"), and a quality string.
type Scanner ¶
type Scanner struct {
// contains filtered or unexported fields
}
Scanner provides a convenient interface for reading FASTQ read data. The Scan method returns the next read, returning a boolean indicating whether the read succeeded. Scanners are not threadsafe.
Scanner performs some validation: it requires ID lines to begin with "@" and that line 3 begins with "+", but does not perform further validation (e.g., seq/qual being of equal length, containing only data in range, etc.)
func NewScanner ¶
NewScanner constructs a new Scanner that reads raw FASTQ data from the provided reader. Fields is a bitset of the fields to read. A typical value would be All or ID|Seq|Qual.
func (*Scanner) Scan ¶
Scan the next read into the provided read. Scan returns a boolean indicating whether the scan succeeded. Once Scan returns false, it never returns true again. Upon completion, the user should check the Err method to determine whether scanning stopped because of an error or because the end of the stream was reached.