ncbi

package
v0.0.0-...-a011eca Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2022 License: BSD-3-Clause, GPL-2.0, BSD-3-Clause, + 1 more Imports: 7 Imported by: 0

Documentation

Overview

Package ncbi provides support for interaction with the NCBI services, Entrez and Blast.

Please check the relevant usage policy when using these services. Note that the Blast and Entrez server requests are subject to frequency limits.

Required parameters are specified by name in the function call.

The following two parameters should be included in all requests.

tool   Name of application making the call. Its value must be a string with no internal
       spaces.

email  E-mail address of the user. Its value must be a string with no internal spaces,
       and should be a valid e-mail address.

Index

Constants

This section is empty.

Variables

View Source
var GetMethodLimit = 2048

GetMethodLimit is the maximum length of a constructed URL that will be retrieved by the high level API functions using the GET method.

Functions

This section is empty.

Types

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

Limiter implements a thread-safe event frequency limit.

func NewLimiter

func NewLimiter(d time.Duration) *Limiter

NewLimiter returns a Limiter that will wait for the specified duration between Wait calls.

func (*Limiter) Wait

func (d *Limiter) Wait()

Wait blocks until the Limiter's specified duration has passed since the last Wait call.

type Util

type Util string

Util implements low level request generator for interaction with the NCBI services. It is the clients responsibility to provide appropriate program parameters and deserialise the returned data using the appropriate unmarshaling method.

func (Util) Get

func (ut Util) Get(v url.Values, tool, email string, l *Limiter) (io.ReadCloser, error)

Get performs a GET or POST method call to the URI in ut, passing the parameters in v, tool and email. The decision on which method to use is based on the length of the constructed URL the value of GetMethodLimit. An io.ReadCloser is returned for a successful request. It is the caller's responsibility to close this.

func (Util) GetResponse

func (ut Util) GetResponse(v url.Values, tool, email string, l *Limiter) (*http.Response, error)

GetResponse performs a GET or POST method call to the URI in ut, passing the parameters in v, tool and email. The decision on which method to use is based on the length of the constructed URL the value of GetMethodLimit. An http.Response is returned for a successful request. It is the caller's responsibility to close the response body.

func (Util) GetXML

func (ut Util) GetXML(v url.Values, tool, email string, l *Limiter, d interface{}) error

GetXML performs a GET or POST method call to the URI in ut, passing the parameters in v, tool and email. The returned stream is unmarshaled into d. The decision on which method to use is based on the length of the constructed URL the value of GetMethodLimit.

func (Util) NewRequest

func (ut Util) NewRequest(method, db string, v url.Values, tool, email string, l *Limiter) (*http.Request, error)

NewRequest returns an http.Request for the utility, ut using the given method. Parameters to be sent to the utility program should be places in db, v, tool and email. NewRequest is subject to a limit that prevents requests being sent more frequently than allowed by l. The limit is easy to circumvent, though circumvention may result in IP blocking by the NCBI servers, so please do not do this.

func (Util) Prepare

func (ut Util) Prepare(v url.Values, tool, email string) (*url.URL, error)

Prepare constructs a URL with the base provided by ut and the parameters provided by v, tool and email.

Jump to

Keyboard shortcuts

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