Documentation
¶
Overview ¶
Package polyjson provides utilities to read and write poly.Sequence structs as JSON.
Poly's JSON schema is still in flux so be on the lookout for breaking changes as we approach the 1.0 release.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Parse ¶
Parse parses a poly.Sequence JSON file and adds appropriate pointers to struct.
Example ¶
package main
import (
"fmt"
"io/ioutil"
"github.com/TimothyStiles/poly/io/polyjson"
)
func main() {
file, _ := ioutil.ReadFile("../../data/sample.json")
sequence := polyjson.Parse(file)
fmt.Println(sequence.Meta.Source)
}
Output: Saccharomyces cerevisiae (baker's yeast)
func Read ¶
Read reads a poly.Sequence JSON file.
Example ¶
package main
import (
"fmt"
"github.com/TimothyStiles/poly/io/polyjson"
)
func main() {
sequence := polyjson.Read("../../data/sample.json")
fmt.Println(sequence.Meta.Source)
}
Output: Saccharomyces cerevisiae (baker's yeast)
func Write ¶
Write writes a poly.Sequence struct out to json.
Example ¶
package main
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
"github.com/TimothyStiles/poly/io/polyjson"
)
func main() {
tmpDataDir, err := ioutil.TempDir("", "data-*")
if err != nil {
fmt.Println(err.Error())
}
defer os.RemoveAll(tmpDataDir)
sequence := polyjson.Read("../../data/sample.json")
tmpJSONFilePath := filepath.Join(tmpDataDir, "sample.json")
polyjson.Write(sequence, tmpJSONFilePath)
testSequence := polyjson.Read(tmpJSONFilePath)
fmt.Println(testSequence.Meta.Source)
}
Output: Saccharomyces cerevisiae (baker's yeast)
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.