https://github.com/brentp/vcfgo

a golang library to read, write and manipulate files in the variant call format.

https://github.com/brentp/vcfgo

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.0%) to scientific vocabulary
Last synced: 11 months ago · JSON representation

Repository

a golang library to read, write and manipulate files in the variant call format.

Basic Info
  • Host: GitHub
  • Owner: brentp
  • License: mit
  • Language: Go
  • Default Branch: master
  • Size: 565 KB
Statistics
  • Stars: 71
  • Watchers: 7
  • Forks: 20
  • Open Issues: 7
  • Releases: 0
Created over 11 years ago · Last pushed 11 months ago
Metadata Files
Readme License

README.md

GoDoc Go Tests Coverage Status

vcfgo is a golang library to read, write and manipulate files in the variant call format.

vcfgo

-- import "github.com/brentp/vcfgo"

Package vcfgo implements a Reader and Writer for variant call format. It eases reading, filtering modifying VCF's even if they are not to spec. Example:

Usage

```go f, _ := os.Open("examples/test.autodom.noparents.vcf") rdr, err := vcfgo.NewReader(f, false) if err != nil { panic(err) } for { variant := rdr.Read() if variant == nil { break } fmt.Printf("%s\t%d\t%s\t%v\n", variant.Chromosome, variant.Pos, variant.Ref(), variant.Alt()) dp, err := variant.Info().Get("DP") fmt.Printf("depth: %v\n", dp.(int)) sample := variant.Samples[0] // we can get the PL field as a list (-1 is default in case of missing value) PL, err := variant.GetGenotypeField(sample, "PL", -1) if err != nil { panic(err) } fmt.Printf("%v\n", PL) _ = sample.DP } fmt.Fprintln(os.Stderr, rdr.Error())

```

Status

vcfgo is well-tested, but still in development. It tries to tolerate, but report errors; after every rdr.Read() call, the caller can check rdr.Error() and get feedback on the errors without stopping execution unless it is explicitly requested to do so.

Info and sample fields are pre-parsed and stored as map[string]interface{} so callers will have to cast to the appropriate type upon retrieval.

type Header

go type Header struct { SampleNames []string Infos map[string]*Info SampleFormats map[string]*SampleFormat Filters map[string]string Extras map[string]string FileFormat string // contid id maps to a map of length, URL, etc. Contigs map[string]map[string]string }

Header holds all the type and format information for the variants.

func NewHeader

go func NewHeader() *Header NewHeader returns a Header with the requisite allocations.

type Info

go type Info struct { Id string Description string Number string // A G R . '' Type string // STRING INTEGER FLOAT FLAG CHARACTER UNKONWN }

Info holds the Info and Format fields

func (*Info) String

go func (i *Info) String() string String returns a string representation.

type InfoMap

go type InfoMap map[string]interface{}

InfoMap holds the parsed Info field which can contain floats, ints and lists thereof.

func (InfoMap) String

go func (m InfoMap) String() string String returns a string that matches the original info field.

type Reader

```go type Reader struct { Header *Header

LineNumber int64

} ```

Reader holds information about the current line number (for errors) and The VCF header that indicates the structure of records.

func NewReader

go func NewReader(r io.Reader, lazySamples bool) (*Reader, error) NewReader returns a Reader.

func (*Reader) Clear

go func (vr *Reader) Clear() Clear empties the cache of errors.

func (*Reader) Error

go func (vr *Reader) Error() error Error() aggregates the multiple errors that can occur into a single object.

func (*Reader) Read

go func (vr *Reader) Read() *Variant Read returns a pointer to a Variant. Upon reading the caller is assumed to check Reader.Err()

type SampleFormat

go type SampleFormat Info

SampleFormat holds the type info for Format fields.

func (*SampleFormat) String

go func (i *SampleFormat) String() string String returns a string representation.

type SampleGenotype

go type SampleGenotype struct { Phased bool GT []int DP int GL []float32 GQ int MQ int Fields map[string]string }

SampleGenotype holds the information about a sample. Several fields are pre-parsed, but all fields are kept in Fields as well.

func NewSampleGenotype

go func NewSampleGenotype() *SampleGenotype NewSampleGenotype allocates the internals and returns a SampleGenotype

func (*SampleGenotype) String

go func (sg *SampleGenotype) String(fields []string) string String returns the string representation of the sample field.

type VCFError

go type VCFError struct { Msgs []string Lines []int64 }

VCFError satisfies the error interface and allows multiple errors. This is useful because, for example, on a single line, every sample may have a field that doesn't match the description in the header. We want to keep parsing but also let the caller know about the error.

func NewVCFError

go func NewVCFError() *VCFError NewVCFError allocates the needed ingredients.

func (*VCFError) Add

go func (e *VCFError) Add(err error, line int64) Add adds an error and the line number within the vcf where the error took place.

func (*VCFError) Clear

go func (e *VCFError) Clear() Clear empties the Messages

func (*VCFError) Error

go func (e *VCFError) Error() string Error returns a string with all errors delimited by newlines.

func (*VCFError) IsEmpty

go func (e *VCFError) IsEmpty() bool IsEmpty returns true if there no errors stored.

type Variant

go type Variant struct { Chromosome string Pos uint64 Id string Ref string Alt []string Quality float32 Filter string Info InfoMap Format []string Samples []*SampleGenotype Header *Header LineNumber int64 }

Variant holds the information about a single site. It is analagous to a row in a VCF file.

func (*Variant) GetGenotypeField

go func (v *Variant) GetGenotypeField(g *SampleGenotype, field string, missing interface{}) (interface{}, error) GetGenotypeField uses the information from the header to parse the correct time from a genotype field. It returns an interface that can be asserted to the expected type.

func (*Variant) String

go func (v *Variant) String() string String gives a string representation of a variant

type Writer

go type Writer struct { io.Writer Header *Header }

Writer allows writing VCF files.

func NewWriter

go func NewWriter(w io.Writer, h *Header) (*Writer, error) NewWriter returns a writer after writing the header.

func (*Writer) WriteVariant

go func (w *Writer) WriteVariant(v *Variant) WriteVariant writes a single variant

Owner

  • Name: Brent Pedersen
  • Login: brentp
  • Kind: user
  • Location: Oregon, USA

Doing genomics

GitHub Events

Total
  • Watch event: 3
  • Issue comment event: 2
  • Push event: 1
  • Pull request review comment event: 1
  • Pull request review event: 2
  • Pull request event: 2
  • Fork event: 3
Last Year
  • Watch event: 3
  • Issue comment event: 2
  • Push event: 1
  • Pull request review comment event: 1
  • Pull request review event: 2
  • Pull request event: 2
  • Fork event: 3

Committers

Last synced: over 1 year ago

All Time
  • Total Commits: 132
  • Total Committers: 5
  • Avg Commits per committer: 26.4
  • Development Distribution Score (DDS): 0.038
Past Year
  • Commits: 6
  • Committers: 1
  • Avg Commits per committer: 6.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Brent Pedersen (brentp) b****e@g****m 127
Tyler Hullinger t****r@g****m 2
chapmanb c****b@5****m 1
Damon Revoe h****m@r****g 1
CodeLingo Bot b****t@c****o 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 13
  • Total pull requests: 9
  • Average time to close issues: 30 days
  • Average time to close pull requests: 1 day
  • Total issue authors: 7
  • Total pull request authors: 7
  • Average comments per issue: 3.38
  • Average comments per pull request: 3.33
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 2
  • Pull requests: 2
  • Average time to close issues: 2 days
  • Average time to close pull requests: 8 days
  • Issue authors: 1
  • Pull request authors: 2
  • Average comments per issue: 5.5
  • Average comments per pull request: 1.5
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • carbocation (4)
  • akotlar (2)
  • matthdsm (2)
  • brentp (2)
  • tylerwmarrs (1)
  • liserjrqlxue (1)
  • tmc (1)
Pull Request Authors
  • carbocation (3)
  • matthdsm (2)
  • chapmanb (1)
  • tylerwmarrs (1)
  • revl (1)
  • ToonRosseel (1)
  • CodeLingoTeam (1)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads: unknown
  • Total docker downloads: 3,969
  • Total dependent packages: 20
  • Total dependent repositories: 15
  • Total versions: 2
proxy.golang.org: github.com/brentp/vcfgo

Package vcfgo implements a Reader and Writer for variant call format. It eases reading, filtering modifying VCF's even if they are not to spec. Example:

  • Versions: 2
  • Dependent Packages: 20
  • Dependent Repositories: 15
  • Docker Downloads: 3,969
Rankings
Docker downloads count: 1.0%
Dependent packages count: 1.3%
Dependent repos count: 1.4%
Average: 2.9%
Forks count: 5.1%
Stargazers count: 5.6%
Last synced: 11 months ago

Dependencies

.github/workflows/tests.yml actions
  • actions/checkout v4 composite
  • actions/setup-go v5 composite
go.mod go
  • github.com/brentp/irelate v0.0.1
  • github.com/kr/pretty v0.2.1
  • github.com/kr/text v0.1.0
  • gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c
go.sum go
  • github.com/brentp/irelate v0.0.1
  • github.com/kr/pretty v0.2.1
  • github.com/kr/pty v1.1.1
  • github.com/kr/text v0.1.0
  • gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c