obo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package obo provides functions for reading, writing, and manipulating Open Biomedical Ontologies (obo) format files. This package follows the OBO Flat File Format 1.4, as specified here: http://owlcollab.github.io/oboformat/doc/obo-syntax.html

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllAreEqual

func AllAreEqual(a map[string]*Obo, b map[string]*Obo) bool

AllAreEqual returns true if two input slices of Obo structs are identical.

func Equal

func Equal(a Obo, b Obo) bool

Equal returns true if two input Obo entries have the same struct contents.

func EqualHeader

func EqualHeader(a Header, b Header) bool

EqualHeader returns true if two input Header structs have the same data.

func IsADescriptionToString

func IsADescriptionToString(d IsADescription) string

IsADescriptionToString converts an IsADescription struct into a string.

func NumberOfDescendents

func NumberOfDescendents(termMap map[string]*Obo)

NumberOfDescendents edits the field SubTreeSize of input Obo structs to the number of descendent nodes in a subtree rooted on a particular node.

func SubTreeReport

func SubTreeReport(outFile string, records map[string]*Obo)

SubTreeReport writes out the number of descendent nodes for each node in an Obo tree. This is used for debugging, and for picking subtrees to visualize based on size.

func SubtreeToDot

func SubtreeToDot(outFile string, nodeId string, termMap map[string]*Obo)

SubtreeToDot makes a DOT format tree for the subtree rooted at the input nodeId. BuildTree must have been run on this tree already, as termMap is an argument.

func ToDot

func ToDot(outFile string, terms map[string]*Obo)

ToDot formats an input Obo slice as a tree and writes the resulting tree to a file in DOT format. If "force" is true, we will build a tree from the Obo even in the case of a nil parent pointer for an individual Obo element.

func ToString

func ToString(o Obo) string

ToString converts an Obo struct into an OBO file format string. Used for writing to files or printing.

func Write

func Write(filename string, records map[string]*Obo, header Header)

Write writes a slice of Obo structs to a specified filename.

func WriteHeaderToFileHandle

func WriteHeaderToFileHandle(file io.Writer, header Header)

WriteHeaderToFileHandle writes an Obo header to an io.Writer.

func WriteObo

func WriteObo(file io.Writer, input Obo)

WriteObo writes an input Bed struct to an io.Writer.

Types

type Header struct {
	Text []string
}

Header encodes the header of an Obo file. Header lines are not marked by a leading character, but are defined as lines preceding the first instance of '[Term]'.

func Read

func Read(filename string, force bool) (map[string]*Obo, Header)

Read creates a slice of Obo structs and a Header struct from an input filename.

func ReadHeader

func ReadHeader(file *fileio.EasyReader) Header

ReadHeader processes the contiguous header from an EasyReader and advances the Reader past the header lines. Note that Header lines are not marked by a leading\ character, but are defined as lines preceding the first instance of '[Term]'.

type IsADescription

type IsADescription struct {
	ParentId   string
	ParentInfo []string
}

IsADescription contains the information in the "IsA" field of an Obo record.

func (IsADescription) String

func (d IsADescription) String() string

String is a method for IsADescription which formats an input struct as a string.

type Obo

type Obo struct {
	Id            string              // Required, can only appear once. GO ID. Ex. GO:0000001
	Name          string              // Required, can only appear once. GO Name. Ex. http://owlcollab.github.io/oboformat/doc/obo-syntax.html
	NameSpace     string              // Required, can only appear once. The category or domain of the term. Ex. biological_process
	Def           string              // Required, can only appear once. Sentence definition of the term.
	IsObsolete    bool                // Optional. Can only appear once. Specifies obsolete ontology labels, which can be filtered downstream.
	IsA           []IsADescription    // Optional. Can appear multiple times in an entry. Specifies parent nodes. Ex. is_a: GO:0048308 ! organelle inheritance // is_a: GO:0048311 ! mitochondrion distribution
	Synonyms      []string            // Optional. Can appear multiple times in an entry. Specifies alternative names for term.
	XRefs         []string            // Optional. Can appear multiple times in an entry. Specifies an external reference about the term. Ex. Wikipedia:Reproduction
	AltIds        []string            // Optional. Can appear multiple times in an entry. Specify an alternative GO ID that also points to this entry.
	Relationships []string            // Optional. Can appear multiple times in an entry. Specifies relationships between ontologies other than 'is_a'.
	Comments      []string            // Optional. Can appear multiple times in an entry. Stores additional comments about an ontology.
	OtherFields   map[string][]string // Catch all for other field names.
	Parents       []*Obo              // Parent nodes of this ontology.
	Children      []*Obo              // Child nodes of this ontology.
	SubTreeSize   int                 //Total number of descendents.
}

Obo is a struct representing one node in an Obo format file, or one ontology term. Required and relevant fields are parsed. As this format is quite flexible and permissive, all other fields will be added to 'OtherFields'. Go:0000001 from the GO Catalog is used for examples of each field.

func FindTreeRoots added in v1.0.1

func FindTreeRoots(records map[string]*Obo) []*Obo

FindTreeRoots takes a map[string]*Obo and returns a slice of pointers to all root nodes. This function assumes BuildTree has already been called.

func NextObo

func NextObo(reader *fileio.EasyReader, force bool) (*Obo, bool)

NextObo is a helper function of Read. NextObo checks a reader for additional lines of data and returns an Obo struct and a bool telling the caller if it is done reading from the file.

func (Obo) String

func (o Obo) String() string

Jump to

Keyboard shortcuts

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