bioportal

package module
v0.0.0-...-c1ba692 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2017 License: BSD-2-Clause Imports: 10 Imported by: 0

README

Go-Bioportal

Go client for the Bioontology Bioportal API.

Tools

Bioportal to Neo4j

Takes a standard Bioportal-based CSV file of a vocabulary and generates CSV files and a script to import using the neo4j-import tool. Child-parent relationships are related using subClassOf and class-vocabulary relationship is modeled as classOf.

Install

Requires Go to install, however if you want pre-built binaries please request it!

go get github.com/chop-dbhi/go-bioportal/cmd/bioportal-to-neo4j
Usage

The command takes a vocab ID, label, and the file. It will output a set of files and print a script to standard out. The paths in the script will likely need to be adjusted, but it should serve as a template.

bioportal-to-neo4j <vocab-id> <vocab-label> <vocab-file>
Example
  • Download the ICD10-CM vocabulary
  • Run the tool
  • Show the output
$ curl -L http://data.bioontology.org/ontologies/ICD10CM/download?apikey=8b5b7825-538d-40e0-9e9e-5ab9274a9aeb&download_format=csv > icd10cm.csv

$ bioportal-to-neo4j \
  icd10cm \
  "International Classification of Diseases, Version 10 - Clinical Modification" \
  icd10cm.csv > icd10cm_load.sh

$ cat icd10cm_load.sh
./neo4j/bin/neo4j-import \
  --into ./neo4j/data/databases/graph.db \
  --delimiter ',' \
  --array-delimiter '|' \
  --quote '"' \
  --nodes:Vocabulary "icd10cm_nodes_vocabulary.csv" \
  --nodes:Class "icd10cm_nodes_class.csv" \
  --relationships "icd10cm_rels_subclassof.csv" \
  --relationships "icd10cm_rels_classof.csv"

$ ls
icd10cm_nodes_class.csv      icd10cm_rels_classof.csv     icd10cm_load.sh
icd10cm_nodes_vocabulary.csv icd10cm_rels_subclassof.csv

$ bash icd10cm_load.sh  # assuming the paths are correct

This will populate the database which and would look something like this in the interface.

icd10cm-graph

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTimeout = 10 * time.Second
	BaseURL        = "https://data.bioontology.org"
)

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Status int      `json:"status"`
	Errors []string `json:"errors"`
}

func (*APIError) Error

func (e *APIError) Error() string

type AnnotateOptions

type AnnotateOptions struct {
	BaseOptions

	Text                         string   `url:"text"`
	Ontologies                   []string `url:"ontologies,omitempty"`
	SemanticTypes                []string `url:"semantic_types,omitempty"`
	ExpandSemanticTypesHierarchy bool     `url:"expand_semantic_types_hierarchy"`
	ExpandClassHierarchy         bool     `url:"expand_class_hierarchy"`
	ClassHierarchyMaxLevel       uint     `url:"class_hierarchy_max"`
	ExpandMappings               bool     `url:"expand_mappings"`
	StopWords                    []string `url:"stop_words,omitempty"`
	MinimumMatchLength           uint     `url:"minimum_match_length"`
	ExcludeNumbers               bool     `url:"exclude_numbers"`
	WholeWordOnly                bool     `url:"whole_word_only"`
	ExcludeSynonyms              bool     `url:"exclude_synonyms"`
	LongestOnly                  bool     `url:"longest_only"`
}

func DefaultAnnotateOptions

func DefaultAnnotateOptions() *AnnotateOptions

type AnnotationResult

type AnnotationResult struct {
	AnnotatedClass struct {
		ID    string `json:"@id"`
		Type  string `json:"@type"`
		Links struct {
			Self        string `json:"self"`
			Ontology    string `json:"ontology"`
			Children    string `json:"children"`
			Parents     string `json:"parents"`
			Descendants string `json:"descendants"`
			Ancestors   string `json:"ancestors"`
			Instances   string `json:"instances"`
			Tree        string `json:"tree"`
			Notes       string `json:"notes"`
			Mappings    string `json:"mappings"`
			UI          string `json:"ui"`
			Context     struct {
				Self        string `json:"self"`
				Ontology    string `json:"ontology"`
				Children    string `json:"children"`
				Parents     string `json:"parents"`
				Descendants string `json:"descendants"`
				Ancestors   string `json:"ancestors"`
				Instances   string `json:"instances"`
				Tree        string `json:"tree"`
				Notes       string `json:"notes"`
				Mappings    string `json:"mappings"`
				UI          string `json:"ui"`
			} `json:"@context"`
		} `json:"links"`
		Context struct {
			Vocab string `json:"@vocab"`
		} `json:"@context"`
	} `json:"annotatedClass"`
	Hierarchy   []interface{} `json:"hierarchy"`
	Annotations []struct {
		From      int    `json:"from"`
		To        int    `json:"to"`
		MatchType string `json:"matchType"`
		Text      string `json:"text"`
	} `json:"annotations"`
	Mappings []interface{} `json:"mappings"`
}

type BaseOptions

type BaseOptions struct {
	// Format string `url:"format"`
	Include        string `url:"include,omitempty"`
	Pagesize       int    `url:"pagesize,omitempty"`
	Page           int    `url:"page,omitempty"`
	IncludeViews   bool   `url:"include_views"`
	DisplayContext bool   `url:"display_context"`
	DisplayLinks   bool   `url:"display_links"`
}

func DefaultBaseOptions

func DefaultBaseOptions() *BaseOptions

type Class

type Class struct {
	PrefLabel    string        `json:"prefLabel"`
	Synonym      []string      `json:"synonym"`
	Definition   []string      `json:"definition"`
	Cui          []interface{} `json:"cui"`
	SemanticType []interface{} `json:"semanticType"`
	Obsolete     interface{}   `json:"obsolete"`
	ID           string        `json:"@id"`
	Type         string        `json:"@type"`
	Links        struct {
		Self        string `json:"self"`
		Ontology    string `json:"ontology"`
		Children    string `json:"children"`
		Parents     string `json:"parents"`
		Descendants string `json:"descendants"`
		Ancestors   string `json:"ancestors"`
		Instances   string `json:"instances"`
		Tree        string `json:"tree"`
		Notes       string `json:"notes"`
		Mappings    string `json:"mappings"`
		UI          string `json:"ui"`
		Context     struct {
			Self        string `json:"self"`
			Ontology    string `json:"ontology"`
			Children    string `json:"children"`
			Parents     string `json:"parents"`
			Descendants string `json:"descendants"`
			Ancestors   string `json:"ancestors"`
			Instances   string `json:"instances"`
			Tree        string `json:"tree"`
			Notes       string `json:"notes"`
			Mappings    string `json:"mappings"`
			UI          string `json:"ui"`
		} `json:"@context"`
	} `json:"links"`
	Context struct {
		Vocab        string `json:"@vocab"`
		PrefLabel    string `json:"prefLabel"`
		Synonym      string `json:"synonym"`
		Definition   string `json:"definition"`
		Obsolete     string `json:"obsolete"`
		SemanticType string `json:"semanticType"`
		Cui          string `json:"cui"`
	} `json:"@context"`
}

type ClassesPaginated

type ClassesPaginated struct {
	Page      int         `json:"page"`
	PageCount int         `json:"pageCount"`
	PrevPage  interface{} `json:"prevPage"`
	NextPage  interface{} `json:"nextPage"`
	Links     struct {
		NextPage interface{} `json:"nextPage"`
		PrevPage interface{} `json:"prevPage"`
	} `json:"links"`
	Collection Class `json:"collection"`
}

type Client

type Client struct {
	APIKey string
	HTTP   *http.Client
}

func NewClient

func NewClient(apiKey string) *Client

func (*Client) Annotate

func (c *Client) Annotate(opts AnnotateOptions) ([]*AnnotationResult, error)

func (*Client) AnnotateRead

func (c *Client) AnnotateRead(w io.Writer, opts AnnotateOptions) (int64, error)

func (*Client) Class

func (c *Client) Class(ontology, class string) (*Class, error)

func (*Client) Recommend

func (c *Client) Recommend(opts RecommendOptions) ([]*RecommendResult, error)

func (*Client) RecommendRead

func (c *Client) RecommendRead(w io.Writer, opts RecommendOptions) (int64, error)

func (*Client) Search

func (c *Client) Search(opts SearchOptions) (*SearchResult, error)

func (*Client) SearchRead

func (c *Client) SearchRead(w io.Writer, opts SearchOptions) (int64, error)

func (*Client) Send

func (c *Client) Send(path string, params interface{}) (io.ReadCloser, error)

type Mapping

type Mapping struct {
	MappingID interface{} `json:"id"`
	Source    string      `json:"source"`
	Classes   []Class     `json:"classes"`
	Process   interface{} `json:"process"`
	ID        string      `json:"@id"`
	Type      string      `json:"@type"`
}

type Ontology

type Ontology struct {
	AdministeredBy []string `json:"administeredBy"`
	Acronym        string   `json:"acronym"`
	Name           string   `json:"name"`
	SummaryOnly    bool     `json:"summaryOnly"`
	OntologyType   string   `json:"ontologyType"`
	ID             string   `json:"@id"`
	Type           string   `json:"@type"`
	Links          struct {
		Submissions      string `json:"submissions"`
		Properties       string `json:"properties"`
		Classes          string `json:"classes"`
		SingleClass      string `json:"single_class"`
		Roots            string `json:"roots"`
		Instances        string `json:"instances"`
		Metrics          string `json:"metrics"`
		Reviews          string `json:"reviews"`
		Notes            string `json:"notes"`
		Groups           string `json:"groups"`
		Categories       string `json:"categories"`
		LatestSubmission string `json:"latest_submission"`
		Projects         string `json:"projects"`
		Download         string `json:"download"`
		Views            string `json:"views"`
		Analytics        string `json:"analytics"`
		UI               string `json:"ui"`
		Context          struct {
			Submissions      string `json:"submissions"`
			Properties       string `json:"properties"`
			Classes          string `json:"classes"`
			SingleClass      string `json:"single_class"`
			Roots            string `json:"roots"`
			Instances        string `json:"instances"`
			Metrics          string `json:"metrics"`
			Reviews          string `json:"reviews"`
			Notes            string `json:"notes"`
			Groups           string `json:"groups"`
			Categories       string `json:"categories"`
			LatestSubmission string `json:"latest_submission"`
			Projects         string `json:"projects"`
			Download         string `json:"download"`
			Views            string `json:"views"`
			Analytics        string `json:"analytics"`
			UI               string `json:"ui"`
		} `json:"@context"`
	} `json:"links"`
	Context struct {
		Vocab          string `json:"@vocab"`
		Acronym        string `json:"acronym"`
		Name           string `json:"name"`
		AdministeredBy struct {
			ID   string `json:"@id"`
			Type string `json:"@type"`
		} `json:"administeredBy"`
		OntologyType struct {
			ID   string `json:"@id"`
			Type string `json:"@type"`
		} `json:"ontologyType"`
	} `json:"@context"`
}

type RecommendOptions

type RecommendOptions struct {
	BaseOptions

	Terms                []string `url:"input"`
	Ontologies           []string `url:"ontologies,omitempty"`
	InputType            int      `url:"input_type,omitempty"`
	OutputType           int      `url:"output_type,omitempty"`
	MaxElementsSet       int      `url:"max_elements_set,omitempty"`
	CoverageWeight       float32  `url:"wc,omitempty"`
	SpecializationWeight float32  `url:"ws,omitempty"`
	AcceptanceWeight     float32  `url:"wa,omitempty"`
	DetailWeight         float32  `url:"wd,omitempty"`
}

func DefaultRecommendOptions

func DefaultRecommendOptions() *RecommendOptions

type RecommendResult

type RecommendResult struct {
	EvaluationScore float64 `json:"evaluationScore"`
	Ontologies      []struct {
		Acronym string `json:"acronym"`
		ID      string `json:"@id"`
		Type    string `json:"@type"`
	} `json:"ontologies"`
	CoverageResult struct {
		Score              int `json:"score"`
		NormalizedScore    int `json:"normalizedScore"`
		NumberTermsCovered int `json:"numberTermsCovered"`
		NumberWordsCovered int `json:"numberWordsCovered"`
		Annotations        []struct {
			From           int    `json:"from"`
			To             int    `json:"to"`
			MatchType      string `json:"matchType"`
			Text           string `json:"text"`
			AnnotatedClass struct {
				ID   string `json:"@id"`
				Type string `json:"@type"`
			} `json:"annotatedClass"`
			HierarchySize int `json:"hierarchySize"`
		} `json:"annotations"`
	} `json:"coverageResult"`
	SpecializationResult struct {
		Score           float64 `json:"score"`
		NormalizedScore int     `json:"normalizedScore"`
	} `json:"specializationResult"`
	AcceptanceResult struct {
		NormalizedScore float64 `json:"normalizedScore"`
		BioportalScore  float64 `json:"bioportalScore"`
		UmlsScore       int     `json:"umlsScore"`
	} `json:"acceptanceResult"`
	DetailResult struct {
		NormalizedScore  float64 `json:"normalizedScore"`
		DefinitionsScore int     `json:"definitionsScore"`
		SynonymsScore    int     `json:"synonymsScore"`
		PropertiesScore  float64 `json:"propertiesScore"`
	} `json:"detailResult"`
}

type SearchOptions

type SearchOptions struct {
	BaseOptions

	Query                string   `url:"q"`
	Ontologies           []string `url:"ontologies,omitempty"`
	RequireExactMatch    bool     `url:"require_exact_match"`
	Suggest              bool     `url:"suggest"`
	RequireDefinitions   bool     `url:"require_definitions"`
	AlsoSearchProperties bool     `url:"also_search_properties"`
	AlsoSearchViews      bool     `url:"also_search_views"`
	AlsoSearchObsolete   bool     `url:"also_search_obsolete"`
	CUI                  []string `url:"cui,omitempty"`
	SemanticTypes        []string `url:"semantic_types,omitempty"`
}

func DefaultSearchOptions

func DefaultSearchOptions() *SearchOptions

type SearchResult

type SearchResult struct {
	Page      int         `json:"page"`
	PageCount int         `json:"pageCount"`
	PrevPage  interface{} `json:"prevPage"`
	NextPage  int         `json:"nextPage"`
	Links     struct {
		NextPage string      `json:"nextPage"`
		PrevPage interface{} `json:"prevPage"`
	} `json:"links"`
	Collection []struct {
		PrefLabel    string   `json:"prefLabel"`
		Synonym      []string `json:"synonym,omitempty"`
		Cui          []string `json:"cui,omitempty"`
		SemanticType []string `json:"semanticType,omitempty"`
		Obsolete     bool     `json:"obsolete"`
		MatchType    string   `json:"matchType"`
		OntologyType string   `json:"ontologyType"`
		Provisional  bool     `json:"provisional"`
		ID           string   `json:"@id"`
		Type         string   `json:"@type"`
		Links        struct {
			Self        string `json:"self"`
			Ontology    string `json:"ontology"`
			Children    string `json:"children"`
			Parents     string `json:"parents"`
			Descendants string `json:"descendants"`
			Ancestors   string `json:"ancestors"`
			Instances   string `json:"instances"`
			Tree        string `json:"tree"`
			Notes       string `json:"notes"`
			Mappings    string `json:"mappings"`
			UI          string `json:"ui"`
			Context     struct {
				Self        string `json:"self"`
				Ontology    string `json:"ontology"`
				Children    string `json:"children"`
				Parents     string `json:"parents"`
				Descendants string `json:"descendants"`
				Ancestors   string `json:"ancestors"`
				Instances   string `json:"instances"`
				Tree        string `json:"tree"`
				Notes       string `json:"notes"`
				Mappings    string `json:"mappings"`
				UI          string `json:"ui"`
			} `json:"@context"`
		} `json:"links"`
		Context struct {
			Vocab        string `json:"@vocab"`
			PrefLabel    string `json:"prefLabel"`
			Synonym      string `json:"synonym"`
			Obsolete     string `json:"obsolete"`
			SemanticType string `json:"semanticType"`
			Cui          string `json:"cui"`
		} `json:"@context"`
		Definition []string `json:"definition,omitempty"`
	} `json:"collection"`
}

type Tree

type Tree struct {
	PrefLabel   string `json:"prefLabel"`
	HasChildren bool   `json:"hasChildren"`
	Children    []Tree `json:"children"`
	Obsolete    bool   `json:"obsolete"`
	ID          string `json:"@id"`
	Type        string `json:"@type"`
	Links       struct {
		Self        string `json:"self"`
		Ontology    string `json:"ontology"`
		Children    string `json:"children"`
		Parents     string `json:"parents"`
		Descendants string `json:"descendants"`
		Ancestors   string `json:"ancestors"`
		Instances   string `json:"instances"`
		Tree        string `json:"tree"`
		Notes       string `json:"notes"`
		Mappings    string `json:"mappings"`
		UI          string `json:"ui"`
		Context     struct {
			Self        string `json:"self"`
			Ontology    string `json:"ontology"`
			Children    string `json:"children"`
			Parents     string `json:"parents"`
			Descendants string `json:"descendants"`
			Ancestors   string `json:"ancestors"`
			Instances   string `json:"instances"`
			Tree        string `json:"tree"`
			Notes       string `json:"notes"`
			Mappings    string `json:"mappings"`
			UI          string `json:"ui"`
		} `json:"@context"`
	} `json:"links"`
	Context struct {
		Vocab     string `json:"@vocab"`
		PrefLabel string `json:"prefLabel"`
		Obsolete  string `json:"obsolete"`
	} `json:"@context"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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