interop

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2025 License: GPL-3.0 Imports: 15 Imported by: 0

README

Interop parsing library in Go

Supported versions

The support is entirely based on what data I have been able to get my hands on. If I see new versions, I will add support for those.

Type Filename(s) Versions
Run info RunInfo.xml 2, 4, 6
Run parameters RunParameters.xml MiSeq, NextSeq 550, NovaSeq X Plus
Tile metrics TileMetricsOut.bin, TileMetrics.bin 2, 3
Extended tile metrics ExtendedTileMetricsOut.bin, ExtendedTileMetrics.bin 1, 3
Quality metrics QMetricsOut.bin, QMetrics.bin 4, 6, 7
Error metrics ErrorMetricsOut.bin, ErrorMetrics.bin 3, 6
Index metrics IndexMetricsOut.bin, `` 1, 2

Documentation

Index

Constants

View Source
const (
	TileClusterCountOccupied = 0
	TileClusterDensity       = 100
	TileClusterDensityPf     = 101
	TileClusterCount         = 102
	TileClusterCountPf       = 103
	TilePhasing              = 200
	TilePrephasing           = 201
	TilePercentAligned       = 300
	TileControlLane          = 400
)

Variables

This section is empty.

Functions

func IdentifyFlowcell

func IdentifyFlowcell(fcid string) string

Get the flowcell name from the flowcell ID.

func IdentifyPlatform

func IdentifyPlatform(iid string) string

Get the platform name from the sequencer ID.

func PlatformReadyMarker

func PlatformReadyMarker(platform string) string

Types

type BinDefinition

type BinDefinition struct {
	Low   uint8
	High  uint8
	Value uint8
}

type Consumable

type Consumable struct {
	Type           string    `bson:"type" json:"type"`
	Name           string    `bson:"name,omitzero" json:"name,omitzero"`
	Version        string    `bson:"version,omitzero" json:"version,omitzero"`
	Mode           string    `bson:"mode,omitzero" json:"mode,omitzero"`
	SerialNumber   string    `bson:"serial_number" json:"serial_number"`
	PartNumber     string    `bson:"part_number" json:"part_number"`
	LotNumber      string    `bson:"lot_number" json:"lot_number"`
	ExpirationDate time.Time `bson:"expiration_date" json:"expiration_date"`
}

type CorrectedIntensity

type CorrectedIntensity struct {
	Header
	Records []TileCycle
}

func ParseCorrectedIntensity

func ParseCorrectedIntensity(r io.Reader) (CorrectedIntensity, error)

func ReadCorrectedIntensity

func ReadCorrectedIntensity(filename string) (CorrectedIntensity, error)

type ErrorMetricRecord

type ErrorMetricRecord struct {
	LTC
	ErrorRate float64
}

type ErrorMetrics

type ErrorMetrics struct {
	Header
	Records []ErrorMetricRecord
}

func ReadErrorMetrics

func ReadErrorMetrics(path string) (ErrorMetrics, error)

type ExtTileMetricRecord

type ExtTileMetricRecord struct {
	LT
	OccupiedClusters int
}

type ExtTileMetrics

type ExtTileMetrics struct {
	Header
	Records []ExtTileMetricRecord
}

func ReadExtendedTileMetrics

func ReadExtendedTileMetrics(filename string) (ExtTileMetrics, error)

func (ExtTileMetrics) LaneOccupiedClusters

func (m ExtTileMetrics) LaneOccupiedClusters() map[int]int

func (ExtTileMetrics) OccupiedClusters

func (m ExtTileMetrics) OccupiedClusters() int

type FlowcellInfo

type FlowcellInfo struct {
	Lanes          int `xml:"LaneCount,attr" bson:"lanes" json:"lanes"`
	Swaths         int `xml:"SwathCount,attr" bson:"swaths" json:"swaths"`
	Tiles          int `xml:"TileCount,attr" bson:"tiles" json:"tiles"`
	Surfaces       int `xml:"SurfaceCount,attr" bson:"surfaces" json:"surfaces"`
	SectionPerLane int `xml:"SectionPerLane,attr,omitempty" bson:"section_per_lane,omitzero" json:"section_per_lane,omitzero"`
}
type Header struct {
	Version    uint8
	RecordSize uint8
}

type IndexMetricRecord

type IndexMetricRecord struct {
	LT
	Read         int
	IndexName    string
	SampleName   string
	ProjectName  string
	ClusterCount int
}

type IndexMetrics

type IndexMetrics struct {
	Version uint8
	Records []IndexMetricRecord
}

func ReadIndexMetrics

func ReadIndexMetrics(path string) (IndexMetrics, error)

func (IndexMetrics) SampleYield

func (m IndexMetrics) SampleYield() map[string]int

func (IndexMetrics) TotalYield

func (m IndexMetrics) TotalYield() int

type IndexSummary

type IndexSummary struct {
	TotalReads          int                  `bson:"total_reads" json:"total_reads"`
	PfReads             int                  `bson:"pf_reads" json:"pf_reads"`
	IdReads             int                  `bson:"id_reads" json:"id_reads"`
	UndeterminedReads   int                  `bson:"undetermined_reads" json:"undetermined_reads"`
	PercentId           OptionalFloat        `bson:"percent_id" json:"percent_id"`
	PercentUndetermined OptionalFloat        `bson:"percent_undetermined" json:"percent_undetermined"`
	Indexes             []IndexSummaryRecord `bson:"indexes" json:"indexes"`
}

type IndexSummaryRecord

type IndexSummaryRecord struct {
	Sample       string  `bson:"sample" json:"sample"`
	Index        string  `bson:"index" json:"index"`
	ReadCount    int     `bson:"read_count" json:"read_count"`
	PercentReads float64 `bson:"percent_reads" json:"percent_reads"`
}

type Interop

type Interop struct {
	RunParameters RunParameters

	RunInfo RunInfo

	QMetrics QMetrics

	TileMetrics TileMetrics

	ExtendedTileMetrics ExtTileMetrics

	ErrorMetrics ErrorMetrics

	IndexMetrics IndexMetrics
	// contains filtered or unexported fields
}

Interop is the representation of Illumina Interop data.

func InteropFromDir

func InteropFromDir(rundir string) (Interop, error)

InteropFromDir creates an Interop object from an Illumina run directory. This makes some assumptions when it comes to the paths of individual files.

func (Interop) IndexSummary

func (i Interop) IndexSummary() IndexSummary

func (Interop) LaneErrorRate

func (i Interop) LaneErrorRate() map[int]float64

LaneErrorRate calculates the average error rate for each lane of the flow cell. It is calculated from the lane averages produced by `Interop.ReadErrorRate`.

func (Interop) LaneFracOccupied

func (i Interop) LaneFracOccupied() map[int]float64

TotalFracOccupied returns the fraction of occupied clusters per lane.

func (Interop) LanePercentQ30

func (i Interop) LanePercentQ30() map[int]float64

LanePercentQ30 calculates the fraction of passing filter clusters with a Q score >= 30 for each lane on the flowcell. It is calculated by first getting the Q30 fraction for each read in each lane and then averaging these for each lane.

func (Interop) LaneSummary

func (i Interop) LaneSummary() []LaneSummary

func (Interop) LaneYield

func (i Interop) LaneYield() map[int]int

LaneYield returns the yield per lane in bases for the sequencing run.

func (Interop) ReadErrorRate

func (i Interop) ReadErrorRate() map[int]map[int]float64

ReadErrorRate calculates the average error rate for reads, on a per lane basis. It works by first calculating the average error rate across all usable cycles for each tile. These are then averaged for each tile for a given lane. The return value is a nested map where the first key is the read number and the second key is the lane number.

func (Interop) ReadPercentQ30

func (i Interop) ReadPercentQ30() map[int]map[int]float64

ReadPercentQ30 calculates the fraction of passing filter clusters with a Q score >= 30 for each lane on the flowcell. It is calculated by first getting the Q30 fraction for each read in each lane and then averaging these for each lane.

func (Interop) ReadSummary

func (i Interop) ReadSummary() []ReadSummary

func (Interop) RunErrorRate

func (i Interop) RunErrorRate() float64

RunErrorRate calculates the average error rate for each lane of the flow cell. It is the average of the lane error rates from `Interop.LaneErrorRate`.

func (Interop) RunPercentOccupied

func (i Interop) RunPercentOccupied() float64

func (Interop) RunPercentQ30

func (i Interop) RunPercentQ30() float64

RunPercentQ30 returns the fraction of clusters with a Q score >= 30 for all passing filter clusters for a flow cell. It is calculated by summing up the number of clusters with a Q score >= 30 across all tiles.

func (Interop) RunSummary

func (i Interop) RunSummary() (rs RunSummary)

func (Interop) Summarise

func (i Interop) Summarise() InteropSummary

func (Interop) TileErrorRate

func (i Interop) TileErrorRate() map[string]float64

TileErrorRate calculates the average error for all tiles over usable cycles for the whole flow cell.

func (Interop) TilePercentQ30

func (i Interop) TilePercentQ30() map[string]float64

TilePercentQ30 calculates the Q30 across all usable cycles for each tile on the flow cell. The return value is a map with tile names as keys and the percent Q30 as values. If Q30 is not represented in the bin definitions, nil will be returned.

func (Interop) TileSummary

func (i Interop) TileSummary() []TileSummaryRecord

func (Interop) TotalFracOccupied

func (i Interop) TotalFracOccupied() float64

TotalFracOccupied returns the fraction of occupied clusters across the whole flow cell.

func (Interop) TotalYield

func (i Interop) TotalYield() int

TotalYield returns the total yield for the sequencing run in bases.

type InteropSummary

type InteropSummary struct {
	RunId        string              `bson:"run_id" json:"run_id"`
	Platform     string              `bson:"platform" json:"platform"`
	Flowcell     string              `bson:"flowcell" json:"flowcell"`
	Date         time.Time           `bson:"date" json:"date"`
	RunSummary   RunSummary          `bson:"run_summary" json:"run_summary"`
	TileSummary  []TileSummaryRecord `bson:"tile_summary" json:"tile_summary"`
	LaneSummary  []LaneSummary       `bson:"lane_summary" json:"lane_summary"`
	IndexSummary IndexSummary        `bson:"index_summary" json:"index_summary"`
	ReadSummary  []ReadSummary       `bson:"read_summary" json:"read_summary"`
}

type LT

type LT struct {
	Lane int
	Tile int
}

func (LT) TileName

func (lt LT) TileName() string

type LTC

type LTC struct {
	LT
	Cycle int
}

type LaneSummary

type LaneSummary struct {
	Lane      int           `bson:"lane" json:"lane"`
	Yield     int           `bson:"yield" json:"yield"`
	ErrorRate OptionalFloat `bson:"error_rate" json:"error_rate"`
	Density   OptionalFloat `bson:"density" json:"density"`
}

type OptionalFloat

type OptionalFloat float64

func (OptionalFloat) IsNaN

func (f OptionalFloat) IsNaN() bool

func (OptionalFloat) MarshalJSON

func (f OptionalFloat) MarshalJSON() ([]byte, error)

type QMetricRecord

type QMetricRecord struct {
	LTC
	Histogram []int
}

func (QMetricRecord) BaseCount

func (qmr QMetricRecord) BaseCount() int

type QMetricRecordV4

type QMetricRecordV4 = QMetricRecordV6

type QMetricRecordV6

type QMetricRecordV6 struct {
	Histogram []uint32
	// contains filtered or unexported fields
}

type QMetricRecordV7

type QMetricRecordV7 struct {
	Histogram []uint32
	// contains filtered or unexported fields
}

type QMetrics

type QMetrics struct {
	Header
	HasBins bool
	Bins    uint8
	BinDefs []BinDefinition
	Records []QMetricRecord
}

func ReadQMetrics

func ReadQMetrics(filename string) (QMetrics, error)

func (QMetrics) TotalYield

func (qm QMetrics) TotalYield() int

type ReadInfo

type ReadInfo struct {
	Name      string `bson:"name,omitzero" json:"name,omitzero"`
	Number    int    `xml:"Number,attr" bson:"number,omitzero" json:"number,omitzero"`
	Cycles    int    `xml:"NumCycles,attr" bson:"cycles" json:"cycles"`
	IsIndex   bool   `xml:"IsIndexedRead,attr" bson:"is_index" json:"is_index"`
	IsRevComp bool   `xml:"IsReverseComplemented,attr" bson:"is_revcomp" json:"is_revcomp"`
}

type ReadSummary

type ReadSummary struct {
	Read           int           `bson:"read" json:"read"`
	Lane           int           `bson:"lane" json:"lane"`
	PercentQ30     float64       `bson:"percent_q30" json:"percent_q30"`
	PercentAligned OptionalFloat `bson:"percent_aligned" json:"percent_aligned"`
	ErrorRate      OptionalFloat `bson:"error_rate" json:"error_rate"`
}

type RunInfo

type RunInfo struct {
	Version      int          `bson:"version" json:"version"`
	RunId        string       `bson:"run_id" json:"run_id"`
	RunNumber    int          `bson:"run_number" json:"run_number"`
	Date         time.Time    `bson:"date" json:"date"`
	Platform     string       `bson:"platform" json:"platform"`
	FlowcellName string       `bson:"flowcell_name" json:"flowcell_name"`
	InstrumentId string       `bson:"instrument_id" json:"instrument_id"`
	FlowcellId   string       `bson:"flowcell_id" json:"flowcell_id"`
	Reads        []ReadInfo   `bson:"reads" json:"reads"`
	Flowcell     FlowcellInfo `bson:"flowcell" json:"flowcell"`
}

RunInfo is the representation of an Illumina RunInfo.xml file.

func ParseRunInfo

func ParseRunInfo(r io.Reader) (ri RunInfo, err error)

func ReadRunInfo

func ReadRunInfo(filename string) (ri RunInfo, err error)

ReadRunInfo reads an Illumina RunInfo.xml file.

func (RunInfo) NonIndexReadCount

func (ri RunInfo) NonIndexReadCount() int

NonIndexReadCount returns the number of non-index reads configured for the run.

func (RunInfo) ReadCount

func (ri RunInfo) ReadCount() int

ReadCount returns the total number reads configured for the run.

func (RunInfo) TileCount

func (i RunInfo) TileCount() int

TileCount returns the number of tiles represented on the flow cell.

type RunParameters

type RunParameters struct {
	ExperimentName string       `bson:"experiment_name" json:"experiment_name"`
	Side           string       `bson:"side,omitzero" json:"side,omitzero"`
	Flowcell       Consumable   `bson:"flowcell" json:"flowcell"`
	Consumables    []Consumable `bson:"consumables" json:"consumables"`
}

func ParseRunParameters

func ParseRunParameters(r io.Reader) (RunParameters, error)

func ReadRunParameters

func ReadRunParameters(filename string) (RunParameters, error)

type RunSummary

type RunSummary struct {
	Yield           int           `bson:"yield" json:"yield"`
	Density         OptionalFloat `bson:"density" json:"density"`
	PercentQ30      OptionalFloat `bson:"percent_q30,omitempty" json:"percent_q30,omitempty"`
	ClusterCount    int           `bson:"cluster_count" json:"cluster_count"`
	PfClusterCount  int           `bson:"pf_cluster_count" json:"pf_cluster_count"`
	PercentPf       OptionalFloat `bson:"percent_pf" json:"percent_pf"`
	PercentAligned  OptionalFloat `bson:"percent_aligned,omitempty" json:"percent_aligned"`
	ErrorRate       OptionalFloat `bson:"error_rate,omitempty" json:"error_rate,omitempty"`
	PercentOccupied OptionalFloat `bson:"percent_occupied,omitempty" json:"percent_occupied,omitempty"`
}

type RunningAverage

type RunningAverage struct {
	Average float64
	// contains filtered or unexported fields
}

func NewRunningAverage

func NewRunningAverage() RunningAverage

func (*RunningAverage) Add

func (r *RunningAverage) Add(val float64)

type TileCode

type TileCode int

type TileCycle

type TileCycle interface {
	NBases() int
}

type TileCycleV2

type TileCycleV2 struct {
	AveIntensity      uint16
	AChannelIntensity uint16
	CChannelIntensity uint16
	GChannelIntensity uint16
	TChannelIntensity uint16
	AClusterIntensity uint16
	CClusterIntensity uint16
	GClusterIntensity uint16
	TClusterIntensity uint16
	NCount            uint32
	ACount            uint32
	CCount            uint32
	GCount            uint32
	TCount            uint32
	SNRatio           float32
	// contains filtered or unexported fields
}

func (TileCycleV2) NBases

func (r TileCycleV2) NBases() int

type TileCycleV3

type TileCycleV3 struct {
	AIntensity uint16
	CIntensity uint16
	GIntensity uint16
	TIntensity uint16
	NCount     uint32
	ACount     uint32
	CCount     uint32
	GCount     uint32
	TCount     uint32
	// contains filtered or unexported fields
}

func (TileCycleV3) NBases

func (r TileCycleV3) NBases() int

type TileCycleV4

type TileCycleV4 struct {
	NCount uint32
	ACount uint32
	CCount uint32
	GCount uint32
	TCount uint32
	// contains filtered or unexported fields
}

func (TileCycleV4) NBases

func (r TileCycleV4) NBases() int

type TileMetrics

type TileMetrics struct {
	Header
	LaneCount int
	Density   float64
	Records   []TileRecord
}

func ReadTileMetrics

func ReadTileMetrics(filename string) (tm TileMetrics, err error)

func (TileMetrics) Clusters

func (m TileMetrics) Clusters() int

Clusters returns the total number of clusters.

func (TileMetrics) FractionPassingFilter

func (m TileMetrics) FractionPassingFilter() float64

FractionPassingFilter returns the fraction of clusters passing filters.

func (TileMetrics) LaneClusters

func (m TileMetrics) LaneClusters() map[int]int

func (TileMetrics) LaneDensity

func (m TileMetrics) LaneDensity() map[int]float64

func (TileMetrics) LanePercentAligned

func (m TileMetrics) LanePercentAligned() map[int]float64

func (TileMetrics) LanePfClusters

func (m TileMetrics) LanePfClusters() map[int]int

func (TileMetrics) PercentAligned

func (m TileMetrics) PercentAligned() float64

func (TileMetrics) PfClusters

func (m TileMetrics) PfClusters() int

PfClusters returns the number of passing filter clusters.

func (TileMetrics) ReadPercentAligned

func (m TileMetrics) ReadPercentAligned() map[int]map[int]float64

func (TileMetrics) RunDensity

func (m TileMetrics) RunDensity() float64

type TileRecord

type TileRecord struct {
	LT
	ClusterCount   int
	PfClusterCount int
	Density        float64
	PercentAligned map[int]float64 // Percent aligned to PhiX for each read
}

type TileSummaryRecord

type TileSummaryRecord struct {
	LT
	Name            string
	ClusterCount    int           `bson:"cluster_count" json:"cluster_count"`
	PFClusterCount  int           `bson:"pf_cluster_count" json:"pf_cluster_count"`
	PercentOccupied OptionalFloat `bson:"percent_occupied" json:"percent_occupied"`
	PercentPF       OptionalFloat `bson:"percent_pf" json:"percent_pf"`
	PercentQ30      OptionalFloat `bson:"percent_q30" json:"percent_q30"`
	PercentAligned  OptionalFloat `bson:"percent_aligned" json:"percent_aligned"`
	ErrorRate       OptionalFloat `bson:"error_rate" json:"error_rate"`
}

Jump to

Keyboard shortcuts

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