htsrequest

package
v0.0.0-...-197f3f5 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package htsrequest provides operations for parsing htsget-related parameters from the HTTP request, and performing validation and transformation

Module defaults contains default values for each parameter

Package htsrequest provides operations for parsing htsget-related parameters from the HTTP request, and performing validation and transformation

Module parsing contains operations for parsing various parameter types from an HTTP request

Package htsrequest provides operations for parsing htsget-related parameters from the HTTP request, and performing validation and transformation

Module region contains genomic intervals

Package htsrequest provides operations for parsing htsget-related parameters from the HTTP request, and performing validation and transformation

Module request defines structs and operations for a mature htsget request, which holds all htsget-related parameters and has insight into what information was requested by the client

Package htsrequest provides operations for parsing htsget-related parameters from the HTTP request, and performing validation and transformation

Module set defines operations for setting request parameters to an HtsgetRequest, which first involves correct parsing, validation, and transformation. Sets parameters correctly based on request route

Package htsrequest provides operations for parsing htsget-related parameters from the HTTP request, and performing validation and transformation

Module transformations defines operations for transforming the raw string parsed from the HTTP request into a mature value that is usable by the program

Package htsrequest provides operations for parsing htsget-related parameters from the HTTP request, and performing validation and transformation

Module validation defines functions for validating whether the value of HTTP request parameters are acceptable

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HtsgetRequest

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

HtsgetRequest contains htsget-related parameters

func NewHtsgetRequest

func NewHtsgetRequest() *HtsgetRequest

NewHtsgetRequest instantiates a new HtsgetRequest instance

func SetAllParameters

func SetAllParameters(method htsconstants.HTTPMethod, endpoint htsconstants.APIEndpoint, writer http.ResponseWriter, request *http.Request) (*HtsgetRequest, error)

SetAllParameters parses, transforms, validates, and sets all parameters to an HtsgetRequest for a given ordered list of expected request parameters

func (*HtsgetRequest) AddRegion

func (r *HtsgetRequest) AddRegion(region *Region)

AddRegion adds a single region to the list of requested genomic regions

func (*HtsgetRequest) AllFieldsRequested

func (r *HtsgetRequest) AllFieldsRequested() bool

AllFieldsRequested checks if all fields were requested by the client. all fields are requested if the client does not specify the 'fields' parameter

func (*HtsgetRequest) AllRegionsRequested

func (r *HtsgetRequest) AllRegionsRequested() bool

AllRegionsRequested checks if the client request is for all chromosomal regions in the file (ie. referenceName not specified)

func (*HtsgetRequest) AllTagsRequested

func (r *HtsgetRequest) AllTagsRequested() bool

AllTagsRequested checks if all tags were requested by the client. all tags are requested if the request specifies neither the 'tags' or 'notags' parameters

func (*HtsgetRequest) ConstructDataEndpointURL

func (r *HtsgetRequest) ConstructDataEndpointURL(useRegion bool, regionI int) (string, error)

ConstructDataEndpointURL for a given htsget request object, return the url that will redirect the client to the correct data download endpoint with all necessary parameters and headers provided

func (*HtsgetRequest) EndRequested

func (r *HtsgetRequest) EndRequested() bool

EndRequested checks whether a genomic end position was specified in the request

func (*HtsgetRequest) GetClass

func (r *HtsgetRequest) GetClass() string

GetClass retrieves the requested class

func (*HtsgetRequest) GetDataSourceRegistry

func (r *HtsgetRequest) GetDataSourceRegistry() *htsconfig.DataSourceRegistry

GetDataSourceRegistry retrieves the data sources associated with the endpoint

func (*HtsgetRequest) GetEnd

func (r *HtsgetRequest) GetEnd() int

GetEnd retrieves the requested region end position

func (*HtsgetRequest) GetEndpoint

func (r *HtsgetRequest) GetEndpoint() htsconstants.APIEndpoint

GetEndpoint retrieves the API endpoint associated with request

func (*HtsgetRequest) GetFields

func (r *HtsgetRequest) GetFields() []string

GetFields retrieves the requested emitted fields

func (*HtsgetRequest) GetFormat

func (r *HtsgetRequest) GetFormat() string

GetFormat retrieves the requested file format

func (*HtsgetRequest) GetHtsgetBlockClass

func (r *HtsgetRequest) GetHtsgetBlockClass() string

GetHtsgetBlockClass retrieves the requested block class

func (*HtsgetRequest) GetHtsgetCurrentBlock

func (r *HtsgetRequest) GetHtsgetCurrentBlock() string

GetHtsgetCurrentBlock retrieves the current url data block number

func (*HtsgetRequest) GetHtsgetFilePath

func (r *HtsgetRequest) GetHtsgetFilePath() string

GetHtsgetFilePath retrieves the path to the requested source file

func (*HtsgetRequest) GetHtsgetRange

func (r *HtsgetRequest) GetHtsgetRange() string

GetHtsgetRange retrieves the byte range for a requested file

func (*HtsgetRequest) GetHtsgetTotalBlocks

func (r *HtsgetRequest) GetHtsgetTotalBlocks() string

GetHtsgetTotalBlocks retrieves the total number of expected url data blocks / fileparts for a single file download

func (*HtsgetRequest) GetID

func (r *HtsgetRequest) GetID() string

GetID retrieves request ID

func (*HtsgetRequest) GetNoTags

func (r *HtsgetRequest) GetNoTags() []string

GetNoTags retrieves the requested set of tags to be excluded from results

func (*HtsgetRequest) GetReferenceName

func (r *HtsgetRequest) GetReferenceName() string

GetReferenceName retrieves the requested chromosome/reference sequence name

func (*HtsgetRequest) GetRegions

func (r *HtsgetRequest) GetRegions() []*Region

GetRegions retrieves the requested list of genomic regions

func (*HtsgetRequest) GetServiceInfo

func (r *HtsgetRequest) GetServiceInfo() *htsconfig.ServiceInfo

GetServiceInfo retrieves the service info object associated with the endpoint

func (*HtsgetRequest) GetStart

func (r *HtsgetRequest) GetStart() int

GetStart retrieves the requested region start position

func (*HtsgetRequest) GetTags

func (r *HtsgetRequest) GetTags() []string

GetTags retrieves the requested emitted tags

func (*HtsgetRequest) HeaderOnlyRequested

func (r *HtsgetRequest) HeaderOnlyRequested() bool

HeaderOnlyRequested checks if the client request is only for the header

func (*HtsgetRequest) IsFinalBlock

func (r *HtsgetRequest) IsFinalBlock() bool

IsFinalBlock checks whether the current data block / filepart is the final block in a list of blocks, altogether constituting a single file

func (*HtsgetRequest) IsHeaderBlock

func (r *HtsgetRequest) IsHeaderBlock() bool

IsHeaderBlock checks whether the current data block / filepart represents the header of the genomic file

func (*HtsgetRequest) NRegions

func (r *HtsgetRequest) NRegions() int

NRegions returns the number of requested genomic loci

func (*HtsgetRequest) NoTagsNotSpecified

func (r *HtsgetRequest) NoTagsNotSpecified() bool

NoTagsNotSpecified checks if the notags parameter was not provided in the HTTP request

func (*HtsgetRequest) ReferenceNameRequested

func (r *HtsgetRequest) ReferenceNameRequested() bool

ReferenceNameRequested checks whether a reference name was specified in the request

func (*HtsgetRequest) SetClass

func (r *HtsgetRequest) SetClass(class string)

SetClass sets the requested class (ie. for header requests)

func (*HtsgetRequest) SetEnd

func (r *HtsgetRequest) SetEnd(end int)

SetEnd sets the requested region end position

func (*HtsgetRequest) SetEndpoint

func (r *HtsgetRequest) SetEndpoint(endpoint htsconstants.APIEndpoint)

SetEndpoint sets the API endpoint associated with request

func (*HtsgetRequest) SetFields

func (r *HtsgetRequest) SetFields(fields []string)

SetFields sets the requested emitted fields

func (*HtsgetRequest) SetFormat

func (r *HtsgetRequest) SetFormat(format string)

SetFormat sets the requested file format

func (*HtsgetRequest) SetHtsgetBlockClass

func (r *HtsgetRequest) SetHtsgetBlockClass(htsgetBlockClass string)

SetHtsgetBlockClass sets the request block class

func (*HtsgetRequest) SetHtsgetCurrentBlock

func (r *HtsgetRequest) SetHtsgetCurrentBlock(htsgetCurrentBlock string)

SetHtsgetCurrentBlock sets the current url data block number

func (*HtsgetRequest) SetHtsgetFilePath

func (r *HtsgetRequest) SetHtsgetFilePath(htsgetFilePath string)

SetHtsgetFilePath sets the path to the requested source file

func (*HtsgetRequest) SetHtsgetRange

func (r *HtsgetRequest) SetHtsgetRange(htsgetRange string)

SetHtsgetRange sets the byte range for a requested file

func (*HtsgetRequest) SetHtsgetTotalBlocks

func (r *HtsgetRequest) SetHtsgetTotalBlocks(htsgetTotalBlocks string)

SetHtsgetTotalBlocks sets the total number of expected url data blocks / fileparts for a single file download

func (*HtsgetRequest) SetID

func (r *HtsgetRequest) SetID(id string)

SetID sets request ID

func (*HtsgetRequest) SetNoTags

func (r *HtsgetRequest) SetNoTags(noTags []string)

SetNoTags sets the requested set of tags to be excluded from results

func (*HtsgetRequest) SetReferenceName

func (r *HtsgetRequest) SetReferenceName(referenceName string)

SetReferenceName sets the requested chromosome/reference sequence name

func (*HtsgetRequest) SetRegions

func (r *HtsgetRequest) SetRegions(regions []*Region)

SetRegions sets the requested list of genomic regions to be returned

func (*HtsgetRequest) SetStart

func (r *HtsgetRequest) SetStart(start int)

SetStart sets the requested region start position

func (*HtsgetRequest) SetTags

func (r *HtsgetRequest) SetTags(tags []string)

SetTags sets the requested emitted tags

func (*HtsgetRequest) StartRequested

func (r *HtsgetRequest) StartRequested() bool

StartRequested checks whether a genomic start position was specified in the request

func (*HtsgetRequest) TagsNotSpecified

func (r *HtsgetRequest) TagsNotSpecified() bool

TagsNotSpecified checks if the tags parameter was not provided in the HTTP request

func (*HtsgetRequest) UnplacedUnmappedReadsRequested

func (r *HtsgetRequest) UnplacedUnmappedReadsRequested() bool

UnplacedUnmappedReadsRequested checks if the client request is for unplaced, unmapped reads

type ParamTransformer

type ParamTransformer struct{}

ParamTransformer transforms request parameters on query string to expected datatype

func NewParamTransformer

func NewParamTransformer() *ParamTransformer

NewParamTransformer instantiates a new ParamTransformer object

func (*ParamTransformer) NoTransform

func (t *ParamTransformer) NoTransform(s string) (string, string)

NoTransform performs no param transformation, returning the exact same value

func (*ParamTransformer) TransformSplit

func (t *ParamTransformer) TransformSplit(s string) ([]string, string)

TransformSplit splits a string into a list of strings, delimited by comma

func (*ParamTransformer) TransformSplitAndUppercase

func (t *ParamTransformer) TransformSplitAndUppercase(s string) ([]string, string)

TransformSplitAndUppercase splits a string into a list of strings, and uppercases each element

func (*ParamTransformer) TransformStringLowercase

func (t *ParamTransformer) TransformStringLowercase(s string) (string, string)

TransformStringLowercase transforms a param with uppercase characters to all lowercase

func (*ParamTransformer) TransformStringToInt

func (t *ParamTransformer) TransformStringToInt(s string) (int, string)

TransformStringToInt converts a request param to integer datatype

func (*ParamTransformer) TransformStringUppercase

func (t *ParamTransformer) TransformStringUppercase(s string) (string, string)

TransformStringUppercase transforms a param with lowercase characters to all uppercase

type ParamValidator

type ParamValidator struct{}

ParamValidator validates request parameters

func NewParamValidator

func NewParamValidator() *ParamValidator

NewParamValidator instantiates a new ParamValidator object

func (*ParamValidator) NoValidation

func (v *ParamValidator) NoValidation(htsgetReq *HtsgetRequest, value string) (bool, string)

NoValidation is an empty validation function for request parameters that do not need to be validated. always returns true

func (*ParamValidator) ValidateClass

func (v *ParamValidator) ValidateClass(htsgetReq *HtsgetRequest, class string) (bool, string)

ValidateClass validates the 'class' parameter. checks if the requested class is one of the allowed options

func (*ParamValidator) ValidateEnd

func (v *ParamValidator) ValidateEnd(htsgetReq *HtsgetRequest, end int) (bool, string)

ValidateEnd validates the 'end' query string parameter. checks that it is a valid, non-zero integer, that it's being used correctly in conjunction with 'referenceName', and that the end coordinate is greater than the start coordinate

func (*ParamValidator) ValidateFields

func (v *ParamValidator) ValidateFields(htsgetReq *HtsgetRequest, fields []string) (bool, string)

ValidateFields validates 'fields' parameter. every requested field must have an acceptable BAM/CRAM column name

func (*ParamValidator) ValidateFormat

func (v *ParamValidator) ValidateFormat(htsgetReq *HtsgetRequest, format string) (bool, string)

ValidateFormat validates the 'format' parameter. checks if the requested format is one of the allowed options based on endpoint

func (*ParamValidator) ValidateID

func (v *ParamValidator) ValidateID(htsgetReq *HtsgetRequest, id string) (bool, string)

ValidateID validates the 'id' parameter. checks if an object matching the 'id' could be found from the data source

func (*ParamValidator) ValidateNoTags

func (v *ParamValidator) ValidateNoTags(htsgetReq *HtsgetRequest, notags []string) (bool, string)

ValidateNoTags validates the 'notags' query string parameter. checks that there is no overlap between tags included by 'tags' and tags excluded by 'notags'

func (*ParamValidator) ValidateReferenceName

func (v *ParamValidator) ValidateReferenceName(htsgetReq *HtsgetRequest, referenceName string) (bool, string)

ValidateReferenceName validates the 'referenceName' query string parameter. checks if the requested reference contig/chromosome is in the BAM/CRAM header sequence dictionary. if unplaced unmapped reads are requested (*), do not perform validation

func (*ParamValidator) ValidateRegions

func (v *ParamValidator) ValidateRegions(htsgetReq *HtsgetRequest, regions []*Region) (bool, string)

ValidateRegions validates whether every region within an array of regions is valid, that is, contains acceptable referenceName, start, and end values

func (*ParamValidator) ValidateStart

func (v *ParamValidator) ValidateStart(htsgetReq *HtsgetRequest, start int) (bool, string)

ValidateStart validates the 'start' query string parameter. checks that it is a valid, non-zero integer, and that it is being used correctly in conjunction with 'referenceName'

func (*ParamValidator) ValidateTags

func (v *ParamValidator) ValidateTags(htsgetReq *HtsgetRequest, tags []string) (bool, string)

ValidateTags only validates that tags hasn't been requested alongside a header only request

type Region

type Region struct {
	ReferenceName string `json:"referenceName"`
	Start         *int   `json:"start"`
	End           *int   `json:"end"`
}

Region defines a simple genomic interval: contig name, start, and end position

func NewRegion

func NewRegion() *Region

NewRegion instantiates a Region instance

func (*Region) EndRequested

func (region *Region) EndRequested() bool

EndRequested validates whether a real end position has been requested

func (*Region) EndString

func (region *Region) EndString() string

EndString retrieves the end position as a string

func (*Region) ExportBcftools

func (region *Region) ExportBcftools() string

ExportBcftools exports the region in a manner compatible to how region requests are specified on the samtools command-line

func (*Region) ExportSamtools

func (region *Region) ExportSamtools() string

ExportSamtools exports the region in a manner compatible to how region requests are specified on the samtools command-line

func (*Region) GetEnd

func (region *Region) GetEnd() int

GetEnd retrieves a region's end position

func (*Region) GetReferenceName

func (region *Region) GetReferenceName() string

GetReferenceName retrieves a region's reference name

func (*Region) GetStart

func (region *Region) GetStart() int

GetStart retrieves a region's start position

func (*Region) ReferenceNameRequested

func (region *Region) ReferenceNameRequested() bool

ReferenceNameRequested validates whether a real reference name has been requested

func (*Region) SetEnd

func (region *Region) SetEnd(end int)

SetEnd sets a region's end position

func (*Region) SetReferenceName

func (region *Region) SetReferenceName(referenceName string)

SetReferenceName sets a region's reference name

func (*Region) SetStart

func (region *Region) SetStart(start int)

SetStart sets a region's start position

func (*Region) StartRequested

func (region *Region) StartRequested() bool

StartRequested validates whether a real start position has been requested

func (*Region) StartString

func (region *Region) StartString() string

StartString retrieves the start position as a string

func (*Region) String

func (region *Region) String() string

String gets a representation of a genomic region

type SetParameterTuple

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

SetParameterTuple describes how a single request parameter will be parsed, transformed, validated, and then set to the mature htsgetrequest object

Jump to

Keyboard shortcuts

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