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 ¶
- type HtsgetRequest
- func (r *HtsgetRequest) AddRegion(region *Region)
- func (r *HtsgetRequest) AllFieldsRequested() bool
- func (r *HtsgetRequest) AllRegionsRequested() bool
- func (r *HtsgetRequest) AllTagsRequested() bool
- func (r *HtsgetRequest) ConstructDataEndpointURL(useRegion bool, regionI int) (string, error)
- func (r *HtsgetRequest) EndRequested() bool
- func (r *HtsgetRequest) GetClass() string
- func (r *HtsgetRequest) GetDataSourceRegistry() *htsconfig.DataSourceRegistry
- func (r *HtsgetRequest) GetEnd() int
- func (r *HtsgetRequest) GetEndpoint() htsconstants.APIEndpoint
- func (r *HtsgetRequest) GetFields() []string
- func (r *HtsgetRequest) GetFormat() string
- func (r *HtsgetRequest) GetHtsgetBlockClass() string
- func (r *HtsgetRequest) GetHtsgetCurrentBlock() string
- func (r *HtsgetRequest) GetHtsgetFilePath() string
- func (r *HtsgetRequest) GetHtsgetRange() string
- func (r *HtsgetRequest) GetHtsgetTotalBlocks() string
- func (r *HtsgetRequest) GetID() string
- func (r *HtsgetRequest) GetNoTags() []string
- func (r *HtsgetRequest) GetReferenceName() string
- func (r *HtsgetRequest) GetRegions() []*Region
- func (r *HtsgetRequest) GetServiceInfo() *htsconfig.ServiceInfo
- func (r *HtsgetRequest) GetStart() int
- func (r *HtsgetRequest) GetTags() []string
- func (r *HtsgetRequest) HeaderOnlyRequested() bool
- func (r *HtsgetRequest) IsFinalBlock() bool
- func (r *HtsgetRequest) IsHeaderBlock() bool
- func (r *HtsgetRequest) NRegions() int
- func (r *HtsgetRequest) NoTagsNotSpecified() bool
- func (r *HtsgetRequest) ReferenceNameRequested() bool
- func (r *HtsgetRequest) SetClass(class string)
- func (r *HtsgetRequest) SetEnd(end int)
- func (r *HtsgetRequest) SetEndpoint(endpoint htsconstants.APIEndpoint)
- func (r *HtsgetRequest) SetFields(fields []string)
- func (r *HtsgetRequest) SetFormat(format string)
- func (r *HtsgetRequest) SetHtsgetBlockClass(htsgetBlockClass string)
- func (r *HtsgetRequest) SetHtsgetCurrentBlock(htsgetCurrentBlock string)
- func (r *HtsgetRequest) SetHtsgetFilePath(htsgetFilePath string)
- func (r *HtsgetRequest) SetHtsgetRange(htsgetRange string)
- func (r *HtsgetRequest) SetHtsgetTotalBlocks(htsgetTotalBlocks string)
- func (r *HtsgetRequest) SetID(id string)
- func (r *HtsgetRequest) SetNoTags(noTags []string)
- func (r *HtsgetRequest) SetReferenceName(referenceName string)
- func (r *HtsgetRequest) SetRegions(regions []*Region)
- func (r *HtsgetRequest) SetStart(start int)
- func (r *HtsgetRequest) SetTags(tags []string)
- func (r *HtsgetRequest) StartRequested() bool
- func (r *HtsgetRequest) TagsNotSpecified() bool
- func (r *HtsgetRequest) UnplacedUnmappedReadsRequested() bool
- type ParamTransformer
- func (t *ParamTransformer) NoTransform(s string) (string, string)
- func (t *ParamTransformer) TransformSplit(s string) ([]string, string)
- func (t *ParamTransformer) TransformSplitAndUppercase(s string) ([]string, string)
- func (t *ParamTransformer) TransformStringLowercase(s string) (string, string)
- func (t *ParamTransformer) TransformStringToInt(s string) (int, string)
- func (t *ParamTransformer) TransformStringUppercase(s string) (string, string)
- type ParamValidator
- func (v *ParamValidator) NoValidation(htsgetReq *HtsgetRequest, value string) (bool, string)
- func (v *ParamValidator) ValidateClass(htsgetReq *HtsgetRequest, class string) (bool, string)
- func (v *ParamValidator) ValidateEnd(htsgetReq *HtsgetRequest, end int) (bool, string)
- func (v *ParamValidator) ValidateFields(htsgetReq *HtsgetRequest, fields []string) (bool, string)
- func (v *ParamValidator) ValidateFormat(htsgetReq *HtsgetRequest, format string) (bool, string)
- func (v *ParamValidator) ValidateID(htsgetReq *HtsgetRequest, id string) (bool, string)
- func (v *ParamValidator) ValidateNoTags(htsgetReq *HtsgetRequest, notags []string) (bool, string)
- func (v *ParamValidator) ValidateReferenceName(htsgetReq *HtsgetRequest, referenceName string) (bool, string)
- func (v *ParamValidator) ValidateRegions(htsgetReq *HtsgetRequest, regions []*Region) (bool, string)
- func (v *ParamValidator) ValidateStart(htsgetReq *HtsgetRequest, start int) (bool, string)
- func (v *ParamValidator) ValidateTags(htsgetReq *HtsgetRequest, tags []string) (bool, string)
- type Region
- func (region *Region) EndRequested() bool
- func (region *Region) EndString() string
- func (region *Region) ExportBcftools() string
- func (region *Region) ExportSamtools() string
- func (region *Region) GetEnd() int
- func (region *Region) GetReferenceName() string
- func (region *Region) GetStart() int
- func (region *Region) ReferenceNameRequested() bool
- func (region *Region) SetEnd(end int)
- func (region *Region) SetReferenceName(referenceName string)
- func (region *Region) SetStart(start int)
- func (region *Region) StartRequested() bool
- func (region *Region) StartString() string
- func (region *Region) String() string
- type SetParameterTuple
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) 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) 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 (*Region) EndRequested ¶
EndRequested validates whether a real end position has been requested
func (*Region) ExportBcftools ¶
ExportBcftools exports the region in a manner compatible to how region requests are specified on the samtools command-line
func (*Region) ExportSamtools ¶
ExportSamtools exports the region in a manner compatible to how region requests are specified on the samtools command-line
func (*Region) GetReferenceName ¶
GetReferenceName retrieves a region's reference name
func (*Region) ReferenceNameRequested ¶
ReferenceNameRequested validates whether a real reference name has been requested
func (*Region) SetReferenceName ¶
SetReferenceName sets a region's reference name
func (*Region) StartRequested ¶
StartRequested validates whether a real start position has been requested
func (*Region) StartString ¶
StartString retrieves the start position as a string
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