sam

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 17, 2025 License: MIT Imports: 12 Imported by: 4

Documentation

Overview

Package sam decodes and encodes SAM files.

This package uses the format described in: https://en.wikipedia.org/wiki/SAM_(file_format)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func File added in v1.0.0

func File(file string) iter.Seq2[*SAM, error]

File iterates over SAM entries in a file.

func FileHeader added in v1.0.0

func FileHeader(file string) iter.Seq2[SAMOrHeader, error]

FileHeader iterates over SAM or header entries in a file.

func Reader

func Reader(r io.Reader) iter.Seq2[*SAM, error]

Reader iterates over SAM entries in a reader.

func ReaderHeader added in v1.0.0

func ReaderHeader(r io.Reader) iter.Seq2[SAMOrHeader, error]

ReaderHeader iterates over SAM or header entries in a reader.

Types

type Flag added in v1.0.0

type Flag int

Flag is the bitwise flag field in a SAM entry.

const (
	FlagMultiple           Flag = 1 << iota // Template having multiple segments in sequencing
	FlagEach                                // Each segment properly aligned according to the aligner
	FlagUnmapped                            // Segment unmapped
	FlagUnmapped2                           // Next segment in the template unmapped
	FlagReverseComplement                   // SEQ being reverse complemented
	FlagReverseComplement2                  // SEQ of the next segment in the template being reverse complemented
	FlagFirst                               // The first segment in the template
	FlagLast                                // The last segment in the template
	FlagSecondary                           // Secondary alignment
	FlagNotPassing                          // Not passing filters, such as platform/vendor quality controls
	FlagDuplicate                           // PCR or optical duplicate
	FlagSupplementary                       // Supplementary alignment
)

Bit values of the flag field.

func (Flag) Duplicate added in v1.0.0

func (f Flag) Duplicate() bool

Duplicate returns the FlagDuplicate bit value of this flag.

func (Flag) Each added in v1.0.0

func (f Flag) Each() bool

Each returns the FlagEach bit value of this flag.

func (Flag) First added in v1.0.0

func (f Flag) First() bool

First returns the FlagFirst bit value of this flag.

func (Flag) Last added in v1.0.0

func (f Flag) Last() bool

Last returns the FlagLast bit value of this flag.

func (Flag) Multiple added in v1.0.0

func (f Flag) Multiple() bool

Multiple returns the FlagMultiple bit value of this flag.

func (Flag) NotPassing added in v1.0.0

func (f Flag) NotPassing() bool

NotPassing returns the FlagNotPassing bit value of this flag.

func (Flag) ReverseComplement added in v1.0.0

func (f Flag) ReverseComplement() bool

ReverseComplement returns the FlagReverseComplement bit value of this flag.

func (Flag) ReverseComplement2 added in v1.0.0

func (f Flag) ReverseComplement2() bool

ReverseComplement2 returns the FlagReverseComplement2 bit value of this flag.

func (Flag) Secondary added in v1.0.0

func (f Flag) Secondary() bool

Secondary returns the FlagSecondary bit value of this flag.

func (*Flag) SetDuplicate added in v1.0.0

func (f *Flag) SetDuplicate(value bool)

func (*Flag) SetEach added in v1.0.0

func (f *Flag) SetEach(value bool)

func (*Flag) SetFirst added in v1.0.0

func (f *Flag) SetFirst(value bool)

func (*Flag) SetLast added in v1.0.0

func (f *Flag) SetLast(value bool)

func (*Flag) SetMultiple added in v1.0.0

func (f *Flag) SetMultiple(value bool)

SetMultiple sets the FlagMultiple bit value for this flag.

func (*Flag) SetNotPassing added in v1.0.0

func (f *Flag) SetNotPassing(value bool)

func (*Flag) SetReverseComplement added in v1.0.0

func (f *Flag) SetReverseComplement(value bool)

func (*Flag) SetReverseComplement2 added in v1.0.0

func (f *Flag) SetReverseComplement2(value bool)

func (*Flag) SetSecondary added in v1.0.0

func (f *Flag) SetSecondary(value bool)

func (*Flag) SetSupplementary added in v1.0.0

func (f *Flag) SetSupplementary(value bool)

func (*Flag) SetUnmapped added in v1.0.0

func (f *Flag) SetUnmapped(value bool)

func (*Flag) SetUnmapped2 added in v1.0.0

func (f *Flag) SetUnmapped2(value bool)

func (Flag) Supplementary added in v1.0.0

func (f Flag) Supplementary() bool

Supplementary returns the FlagSupplementary bit value of this flag.

func (Flag) Unmapped added in v1.0.0

func (f Flag) Unmapped() bool

Unmapped returns the FlagUnmapped bit value of this flag.

func (Flag) Unmapped2 added in v1.0.0

func (f Flag) Unmapped2() bool

Unmapped2 returns the FlagUnmapped2 bit value of this flag.

type SAM

type SAM struct {
	Qname string         // Query name
	Flag  Flag           // Bitwise flag
	Rname string         // Reference sequence name
	Pos   int            // Mapping position (1-based)
	Mapq  int            // Mapping quality
	Cigar string         // CIGAR string
	Rnext string         // Ref. name of the mate/next read
	Pnext int            // Position of the mate/next read
	Tlen  int            // Observed template length
	Seq   string         // Sequence
	Qual  string         // Phred qualities (ASCII)
	Tags  map[string]any // Typed optional tags.
}

SAM is a single line (alignment) in a SAM file.

func (*SAM) MarshalText added in v0.1.17

func (s *SAM) MarshalText() ([]byte, error)

MarshalText returns the textual representation of s in SAM format. Includes a trailing new line.

func (*SAM) Write added in v1.0.0

func (s *SAM) Write(w io.Writer) error

Write writes this entry in textual SAM format to the given writer. Includes a trailing new line.

type SAMOrHeader added in v1.0.0

type SAMOrHeader struct {
	H *string // Header line, including the '@' sign.
	S *SAM    // SAM entry.
}

SAMOrHeader holds either a SAM or a header entry from a SAM-formatted input. If there is no error, exactly one of the fields will be non-nil.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL