Documentation ¶
Overview ¶
Package htsdb wraps a database connection to provide a convenient loop interface for reading database records. Successive calls to the Next method will step through the records of the database. Iteration stops unrecoverably when records are exhausted or at the first error.
type Record struct { Strand int `db:"strand_field"` Start int }
db, err := sql.Open("foo", "bar")
r, err := NewReader(db, "foo", &Record{}, "SELECT * FROM FOO")
for r.Next() { rec, ok := r.Record().(*Record) fmt.Println(rec) }
if r.Error() != nil { panic(r.Error) }
Index ¶
Constants ¶
This section is empty.
Variables ¶
var CountBuilder = squirrel.Select(). Column(squirrel.Alias(squirrel.Expr("COUNT(*)"), "count"))
CountBuilder is a squirrel select builder to count entries.
var FeatureBuilder = RangeBuilder.Column("rname")
FeatureBuilder is a squirrel select builder whose columns match Feature fields.
var OrientedFeatureBuilder = FeatureBuilder.Column("strand")
OrientedFeatureBuilder is a squirrel select builder whose columns match OrientedFeature fields.
var RangeBuilder = squirrel.Select("start", "stop", "copy_number")
RangeBuilder is a squirrel select builder whose columns match Range fields.
var ReferenceBuilder = squirrel.Select("rname"). Column(squirrel.Alias(squirrel.Expr("MAX(stop)+1"), "length")). GroupBy("rname")
ReferenceBuilder is a squirrel select builder whose structure matches that of Reference and that knows how to properly extract references from htsdb.
var SamRecordBuilder = squirrel.Select("qname", "flag", "rname", "pos",
"mapq", "cigar", "rnext", "pnext", "tlen", "seq", "qual", "tags")
SamRecordBuilder is a squirrel select builder whose columns match SamRecord fields.
Functions ¶
Types ¶
type Feature ¶
Feature is part of an htsdb record that wraps Range and the name of the reference.
func (*Feature) Description ¶
Description returns an empty string.
type OrientedFeature ¶
type OrientedFeature struct { Orient feat.Orientation `db:"strand"` Feature }
OrientedFeature is part of an htsdb record that wraps Feature and has orientation.
func (*OrientedFeature) Orientation ¶
func (e *OrientedFeature) Orientation() feat.Orientation
Orientation returns the orientation of OrientedFeature.
type Range ¶
type Range struct { StartPos int `db:"start"` StopPos int `db:"stop"` CopyNumber int `db:"copy_number"` }
Range is part of an htsdb record that wraps the alignment coordinates.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader encapsulates a connection to a database and acts as an iterator for the records. Internally the reader maps each database row to dest.
func NewReader ¶
NewReader returns a new reader that reads from db by runs the given query and maps rows into dest.
func (*Reader) Next ¶
Next advances the iterator past the next record, which will then be available through Record(). It returns false when the iteration stops, either by reaching the end of the input or an error. After Next returns false, the Error method will return any error that occurred during iteration.
type Reference ¶
Reference is a reference feature on which reads align.
func SelectReferences ¶
SelectReferences selects the reference sequences from db using squirrel.SelectBuilder. It will return an error if it encounters one.
e.g. refs, err := SelectReferences(db, ReferenceBuilder)
func (*Reference) Description ¶
Description returns the description of the reference.