Documentation ¶
Index ¶
- func Build(sequence poly.Sequence) []byte
- func BuildFeatureString(feature poly.Feature) string
- func BuildLocationString(location poly.Location) string
- func Parse(file []byte) poly.Sequence
- func ParseFlat(file []byte) []poly.Sequence
- func ParseMulti(file []byte) []poly.Sequence
- func Read(path string) poly.Sequence
- func ReadFlat(path string) []poly.Sequence
- func ReadFlatGz(path string) []poly.Sequence
- func ReadMulti(path string) []poly.Sequence
- func Write(sequence poly.Sequence, path string)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
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 ¶
BuildFeatureString is a helper function to build gbk feature strings for Build()
func BuildLocationString ¶
BuildLocationString is a recursive function that takes a location object and creates a gbk location string for Build()
func Parse ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.