gff

package
v0.13.5 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package gff provides gff parsers and writers.

GFF stands for "general feature format". It is an alternative to GenBank for storing data about genomic sequences. While not often used in synthetic biology research, it is more commonly used in bioinformatics for digesting features of genomic sequences.

This package provides a parser and writer to convert between the gff file format and the more general poly.Sequence struct.

Example (Basic)

This example shows how to open a gff file and search for a gene given its locus tag. We then display the EC number of that particular gene.

package main

import (
	"fmt"
	"github.com/TimothyStiles/poly/io/gff"
)

func main() {
	sequence := gff.Read("../../data/ecoli-mg1655-short.gff")
	for _, feature := range sequence.Features {
		if feature.Attributes["locus_tag"] == "b0003" {
			fmt.Println(feature.Attributes["EC_number"])
		}
	}
}
Output:

2.7.1.39

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(sequence poly.Sequence) []byte

Build takes an Annotated sequence and returns a byte array representing a gff to be written out.

Example
sequence := Read("../../data/ecoli-mg1655-short.gff")
gffBytes := Build(sequence)
reparsedSequence := Parse(gffBytes)

fmt.Println(reparsedSequence.Meta.Name)
Output:

U00096.3

func Parse

func Parse(file []byte) poly.Sequence

Parse Takes in a string representing a gffv3 file and parses it into an Sequence object.

Example
file, _ := ioutil.ReadFile("../../data/ecoli-mg1655-short.gff")
sequence := Parse(file)

fmt.Println(sequence.Meta.Name)
Output:

U00096.3

func Read

func Read(path string) poly.Sequence

Read takes in a filepath for a .gffv3 file and parses it into an Annotated poly.Sequence struct.

Example
sequence := Read("../../data/ecoli-mg1655-short.gff")
fmt.Println(sequence.Meta.Name)
Output:

U00096.3

func Write

func Write(sequence poly.Sequence, path string)

Write takes an poly.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/ecoli-mg1655-short.gff")

tmpGffFilePath := filepath.Join(tmpDataDir, "ecoli-mg1655-short.gff")
Write(sequence, tmpGffFilePath)

testSequence := Read(tmpGffFilePath)

fmt.Println(testSequence.Meta.Name)
Output:

U00096.3

Types

This section is empty.

Jump to

Keyboard shortcuts

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