graph

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package graph provides primitives for building and accessing OBO Graphs(graph oriented ontology). The OBO Graphs can be traversed through a standard graph oriented API using familiar OBO term and relationship concepts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NodeID

type NodeID string

NodeID is a custom type for holding a node id.

type OboGraph

type OboGraph interface {
	// IRI represents a stable URL for locating the source OWL formatted file
	IRI() string
	// ID is a short and unique name of the graph
	ID() string
	// Label is a short human readable description of the graph
	Label() string
	// Meta returns the associated Meta container
	Meta() *model.Meta
	// ExistsTerm checks for existence of a term
	ExistsTerm(NodeID) bool
	// GetTerm fetches an existing term
	GetTerm(NodeID) Term
	// GetRelationship fetches relationship(edge) between parent(object) and
	// children(subject)
	GetRelationship(NodeID, NodeID) Relationship
	// Relationships returns all relationships(edges) in the graph
	Relationships() []Relationship
	// Terms returns all terms(node/vertex) in the graph
	Terms() []Term
	// TermsByType provides a filtered list of specific terms
	TermsByType(string) []Term
	// Children returns all children terms(depth one)
	Children(NodeID) []Term
	// Parents returns all parent terms(depth one)
	Parents(NodeID) []Term
	// Ancestors returns all reachable(direct or indirect) parent terms. It uses
	// BFS algorithm
	Ancestors(NodeID) []Term
	// Descendents returns all reachable(direct or indirect) children terms. It uses
	// BFS algorithm
	Descendents(NodeID) []Term
	// DescendentsDFS returns all reachable(direct or indirect) children terms
	// using DFS algorithm.
	DescendentsDFS(NodeID) []Term
	// AddRelationship creates relationship between terms, it overrides the
	// existing terms and relationship
	AddRelationship(Term, Term, Term) error
	// AddRelationshipWithID creates relationship between existing terms
	AddRelationshipWithID(NodeID, NodeID, NodeID) error
	// AddTerm add a new Term to the graph overwriting any existing one
	AddTerm(Term)
}

OboGraph is an interface for accessing OBO Graphs.

func BuildGraph

func BuildGraph(r io.Reader) (OboGraph, error)

BuildGraph builds an in memory graph from JSON-encoded obograph reader.

type Relationship

type Relationship interface {
	// Object is the unique identifier for parent term
	Object() NodeID
	// Subject is the unique identifier for child term
	Subject() NodeID
	// Predicate is the unique identifier for term that describes the relationship
	Predicate() NodeID
	// Meta returns the relationship's Meta object
	Meta() *model.Meta
}

Relationship is an interface for representing relationship between terms.

func NewRelationship

func NewRelationship(obj, subj, pred NodeID) Relationship

NewRelationship is a constructor for Relationship.

func NewRelationshipWithMeta

func NewRelationshipWithMeta(obj, subj, pred NodeID, m *model.Meta) Relationship

NewRelationshipWithMeta is a constructor for Relationship that receives an additional Meta object.

type Term

type Term interface {
	// ID is the term's unique identifier
	ID() NodeID
	// HasMeta check for presence of any metadata
	HasMeta() bool
	// Meta returns the term's Meta object
	Meta() *model.Meta
	// RdfType is one defined rdf type, either of CLASS,
	// INDIVIDUAL OR PROPERTY
	RdfType() string
	// Label is a short human readable description of the term
	Label() string
	// IRI represents a stable URL for term's information
	IRI() string
	// IsDeprecated provides the current status of the term
	IsDeprecated() bool
}

Term is an interface for obo term(node).

func NewTerm

func NewTerm(id NodeID, rdfType, lbl, iri string) Term

NewTerm is the constructor for Term without metadata.

func NewTermWithMeta

func NewTermWithMeta(id NodeID, m *model.Meta, rdfType, lbl, iri string) Term

NewTermWithMeta is the constructor for Term with metadata.

Jump to

Keyboard shortcuts

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