genbank

package
v0.15.5 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(sequence poly.Sequence) []byte

Build builds a GBK string to be written out to db or file.

Example
sequence := Read("../../data/puc19.gbk")
gbkBytes := Build(sequence)
testSequence := Parse(gbkBytes)

fmt.Println(testSequence.Meta.Locus.ModificationDate)
Output:

22-OCT-2019

func BuildFeatureString

func BuildFeatureString(feature poly.Feature) string

BuildFeatureString is a helper function to build gbk feature strings for Build()

func BuildLocationString

func BuildLocationString(location poly.Location) string

BuildLocationString is a recursive function that takes a location object and creates a gbk location string for Build()

func Parse

func Parse(file []byte) poly.Sequence

Parse takes in a string representing a gbk/gb/genbank file and parses it into an Sequence object.

Example
file, _ := ioutil.ReadFile("../../data/puc19.gbk")
sequence := Parse(file)

fmt.Println(sequence.Meta.Locus.ModificationDate)
Output:

22-OCT-2019

func ParseFlat

func ParseFlat(file []byte) []poly.Sequence

ParseFlat specifically takes the output of a Genbank Flat file that from the genbank ftp dumps. These files have 10 line headers, which are entirely removed

Example
file, _ := ioutil.ReadFile("../../data/flatGbk_test.seq")
sequences := ParseFlat(file)
var locus []string
for _, sequence := range sequences {
	locus = append(locus, sequence.Meta.Locus.Name)
}

fmt.Println(strings.Join(locus, ", "))
Output:

AB000100, AB000106

func ParseMulti

func ParseMulti(file []byte) []poly.Sequence

ParseMulti parses multiple Genbank files in a byte array to multiple sequences

Example
file, _ := ioutil.ReadFile("../../data/multiGbk_test.seq")
sequences := ParseMulti(file)
var locus []string
for _, sequence := range sequences {
	locus = append(locus, sequence.Meta.Locus.Name)
}

fmt.Println(strings.Join(locus, ", "))
Output:

AB000100, AB000106

func Read

func Read(path string) poly.Sequence

Read reads a Gbk from path and parses into an Annotated sequence struct.

Example
sequence := Read("../../data/puc19.gbk")
fmt.Println(sequence.Meta.Locus.ModificationDate)
Output:

22-OCT-2019

func ReadFlat

func ReadFlat(path string) []poly.Sequence

ReadFlat reads flat genbank files, like the ones provided by the NCBI FTP server (after decompression)

Example
sequences := ReadFlat("../../data/long_comment.seq")
var locus []string
for _, sequence := range sequences {
	locus = append(locus, sequence.Meta.Locus.Name)
}

fmt.Println(strings.Join(locus, ", "))
Output:

AB000100, AB000106

func ReadFlatGz

func ReadFlatGz(path string) []poly.Sequence

ReadFlatGz reads flat gzip'd genbank files, like the ones provided by the NCBI FTP server

Example
sequences := ReadFlatGz("../../data/flatGbk_test.seq.gz")
//sequences := ReadFlatGz("../../data/gbbct358.seq.gz")
var locus []string
for _, sequence := range sequences {
	locus = append(locus, sequence.Meta.Locus.Name)
}
fmt.Println(strings.Join(locus, ", "))
Output:

AB000100, AB000106

func ReadMulti

func ReadMulti(path string) []poly.Sequence

ReadMulti reads multiple genbank files from a single file

Example
sequences := ReadMulti("../../data/multiGbk_test.seq")
var locus []string
for _, sequence := range sequences {
	locus = append(locus, sequence.Meta.Locus.Name)
}

fmt.Println(strings.Join(locus, ", "))
Output:

AB000100, AB000106

func Write

func Write(sequence poly.Sequence, path string)

Write takes an Sequence struct and a path string and writes out a gff to that path.

Example
tmpDataDir, err := ioutil.TempDir("", "data-*")
if err != nil {
	fmt.Println(err.Error())
}
defer os.RemoveAll(tmpDataDir)

sequence := Read("../../data/puc19.gbk")

tmpGbkFilePath := filepath.Join(tmpDataDir, "puc19.gbk")
Write(sequence, tmpGbkFilePath)

testSequence := Read(tmpGbkFilePath)

fmt.Println(testSequence.Meta.Locus.ModificationDate)
Output:

22-OCT-2019

Types

This section is empty.

Jump to

Keyboard shortcuts

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