Documentation
¶
Overview ¶
Package repository defines interfaces and error types for annotation data storage.
Index ¶
- func IsAllStopwords(query string) bool
- func IsAnnoTagNotFound(err error) bool
- func IsAnnotationGroupListNotFound(err error) bool
- func IsAnnotationListNotFound(err error) bool
- func IsAnnotationNotFound(err error) bool
- func IsFeatureNameNotFound(err error) bool
- func IsGroupNotFound(err error) bool
- func IsListNotFound(err error) bool
- func IsOrganismNotFound(err error) bool
- func IsPublicationAnnotationNotFound(err error) bool
- func NormalizeAutocompleteQuery(q string) string
- type AnnoGroupListNotFoundError
- type AnnoListNotFoundError
- type AnnoNotFoundError
- type AnnoTagNotFoundError
- type AutocompleteQuery
- type FeatureAnnotationRepository
- type FeatureNameNotFoundError
- type FullSearchQuery
- type FullSearchResult
- type GroupNotFoundError
- type ListAnnotationsParams
- type ListNotFoundError
- type OrganismNotFoundError
- type OrganismRepository
- type PublicationAnnotationNotFoundError
- type Suggestion
- type TaggedAnnotationRepository
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsAllStopwords ¶ added in v0.2.0
IsAllStopwords reports whether every whitespace-separated word of a normalized query is an English stopword (or the query has no words).
func IsAnnoTagNotFound ¶
IsAnnoTagNotFound reports whether err is an AnnoTagNotFoundError.
func IsAnnotationGroupListNotFound ¶
IsAnnotationGroupListNotFound reports whether err is an AnnoGroupListNotFoundError.
func IsAnnotationListNotFound ¶
IsAnnotationListNotFound reports whether err is an AnnoListNotFoundError.
func IsAnnotationNotFound ¶
IsAnnotationNotFound reports whether err is an AnnoNotFoundError.
func IsFeatureNameNotFound ¶
IsFeatureNameNotFound checks if the error is a FeatureNameNotFoundError.
func IsGroupNotFound ¶
IsGroupNotFound reports whether err is a GroupNotFoundError.
func IsListNotFound ¶
IsListNotFound reports whether err is a ListNotFoundError.
func IsOrganismNotFound ¶
IsOrganismNotFound reports whether err is an OrganismNotFoundError.
func IsPublicationAnnotationNotFound ¶
IsPublicationAnnotationNotFound reports whether err is a PublicationAnnotationNotFoundError.
func NormalizeAutocompleteQuery ¶ added in v0.2.0
NormalizeAutocompleteQuery trims an autocomplete query, lowercases it, and strips its combining marks, so the text lines up with the normalized field the search index holds.
The service guards on this canonical form and the repository searches with it, so both must share one implementation. A copy in each package would let the minimum-length guard and the search text drift apart.
Types ¶
type AnnoGroupListNotFoundError ¶
type AnnoGroupListNotFoundError struct{}
AnnoGroupListNotFoundError is returned when the annotation group list is empty or not found.
func (*AnnoGroupListNotFoundError) Error ¶
func (agl *AnnoGroupListNotFoundError) Error() string
type AnnoListNotFoundError ¶
type AnnoListNotFoundError struct{}
AnnoListNotFoundError is returned when the annotation list is empty or not found.
func (*AnnoListNotFoundError) Error ¶
func (al *AnnoListNotFoundError) Error() string
type AnnoNotFoundError ¶
type AnnoNotFoundError struct {
ID string
}
AnnoNotFoundError is returned when an annotation with the given ID does not exist.
func (*AnnoNotFoundError) Error ¶
func (ae *AnnoNotFoundError) Error() string
type AnnoTagNotFoundError ¶
type AnnoTagNotFoundError struct {
Tag string
}
AnnoTagNotFoundError is returned when an annotation tag is not found.
func (*AnnoTagNotFoundError) Error ¶
func (at *AnnoTagNotFoundError) Error() string
type AutocompleteQuery ¶ added in v0.2.0
type AutocompleteQuery struct {
// Query is the partial search text. The caller sends it untrimmed;
// the repository trims it, lowercases it, and strips combining marks.
Query string
// Limit is the maximum number of suggestions. A value at or below 0
// becomes 5. A value above 50 becomes 50.
Limit int
}
AutocompleteQuery holds the input of an annotation autocomplete search. The repository normalizes Query and clamps Limit.
type FeatureAnnotationRepository ¶
type FeatureAnnotationRepository interface {
// GetFeatureAnnotation retrieves a feature annotation by ID
GetFeatureAnnotation(id string) (*model.FeatureAnnotationDoc, error)
// GetFeatureAnnotationByName retrieves a feature annotation by name
GetFeatureAnnotationByName(name string) (*model.FeatureAnnotationDoc, error)
// AddFeatureAnnotation creates a new feature annotation
AddFeatureAnnotation(
doc *feature.NewFeatureAnnotation,
) (*model.FeatureAnnotationDoc, error)
// EditFeatureAnnotation updates an existing feature annotation
EditFeatureAnnotation(
doc *feature.FeatureAnnotationUpdate,
) (*model.FeatureAnnotationDoc, error)
// RemoveFeatureAnnotation deletes a feature annotation
RemoveFeatureAnnotation(id string, purge bool) error
// ClearFeatureAnnotations removes all feature annotations
ClearFeatureAnnotations() error
// Dbh returns the underlying database handler
Dbh() *manager.Database
// Tag management methods
// AddTag adds a single tag to an existing feature annotation
AddTag(req *feature.AddTagRequest) (*model.FeatureAnnotationDoc, error)
// AddTags adds multiple tags to an existing feature annotation
AddTags(req *feature.AddTagsRequest) (*model.FeatureAnnotationDoc, error)
// SetTags replaces all tags for a feature annotation with the provided set
SetTags(req *feature.SetTagsRequest) (*model.FeatureAnnotationDoc, error)
// RemoveTags removes tags from a feature annotation by tag and value
RemoveTags(req *feature.RemoveTagsRequest) (*model.FeatureAnnotationDoc, error)
// Publication-based queries
// ListByPublicationID retrieves all feature annotations associated with the given publication ID and source
ListByPublicationID(id string, source string) ([]*model.FeatureAnnotationDoc, error)
}
FeatureAnnotationRepository is an interface for accessing feature annotation data from its data sources.
type FeatureNameNotFoundError ¶
type FeatureNameNotFoundError struct {
Name string
}
FeatureNameNotFoundError indicates that a feature annotation with the given name was not found.
func (*FeatureNameNotFoundError) Error ¶
func (fnf *FeatureNameNotFoundError) Error() string
Error returns the error message for FeatureNameNotFoundError.
type FullSearchQuery ¶ added in v0.2.0
type FullSearchQuery struct {
// Query is the search text. The caller sends it untrimmed;
// the repository trims it, lowercases it, and strips combining marks.
Query string
// Limit is the maximum number of results. A value at or below 0
// becomes 50. A value above 50 becomes 50.
Limit int
}
FullSearchQuery holds the input of an annotation full search. The repository normalizes Query, rejects all-stopword queries, and clamps Limit.
type FullSearchResult ¶ added in v0.2.0
type FullSearchResult struct {
// EntryID is the strain identifier of the matched annotation, for
// example DBS0236126.
EntryID string
// Field is the canonical field label that matched (for example,
// "synonym", "genotype", "phenotype", or "public_note").
Field string
// DisplayText is the stored annotation value or cvterm label shown
// in the user interface.
DisplayText string
// Score ranks the match across the four bands (prefix >= 1000,
// phrase >= 500, token >= 250, fuzzy >= 0).
Score float64
}
FullSearchResult is one annotation full search match, deduplicated by EntryID.
type GroupNotFoundError ¶
type GroupNotFoundError struct {
ID string
}
GroupNotFoundError is returned when an annotation group with the given ID does not exist.
func (*GroupNotFoundError) Error ¶
func (ge *GroupNotFoundError) Error() string
type ListAnnotationsParams ¶
type ListAnnotationsParams struct {
Cursor int64
Limit int64 `validate:"required"`
Filter string `validate:"required"`
}
ListAnnotationsParams defines the parameters for listing annotations.
type ListNotFoundError ¶
type ListNotFoundError struct{}
ListNotFoundError is returned when a generic list is empty or not found.
func (*ListNotFoundError) Error ¶
func (lnf *ListNotFoundError) Error() string
type OrganismNotFoundError ¶
type OrganismNotFoundError struct {
ID string
}
OrganismNotFoundError is returned when an organism with the given ID does not exist.
func (*OrganismNotFoundError) Error ¶
func (onf *OrganismNotFoundError) Error() string
type OrganismRepository ¶
type OrganismRepository interface {
// GetOrganism retrieves an organism by ID
GetOrganism(id string) (*model.OrganismDoc, error)
// GetOrganismByName retrieves an organism by scientific name (genus + species)
GetOrganismByName(genus, species string) (*model.OrganismDoc, error)
// AddOrganism creates a new organism
AddOrganism(doc *organism.NewOrganism) (*model.OrganismDoc, error)
// EditOrganism updates an existing organism
EditOrganism(doc *organism.OrganismUpdate) (*model.OrganismDoc, error)
// RemoveOrganism deletes an organism
RemoveOrganism(id string) error
// ListOrganisms provides a paginated list of organisms along with optional filtering
ListOrganisms() ([]*model.OrganismDoc, error)
// ClearOrganisms removes all organisms
ClearOrganisms() error
// Dbh returns the underlying database handler
Dbh() *manager.Database
}
OrganismRepository is an interface for accessing organism data from its data sources.
type PublicationAnnotationNotFoundError ¶
PublicationAnnotationNotFoundError is returned when no annotations are found for a publication ID.
func (*PublicationAnnotationNotFoundError) Error ¶
func (panf *PublicationAnnotationNotFoundError) Error() string
type Suggestion ¶ added in v0.2.0
type Suggestion struct {
// EntryID is the strain identifier of the matched annotation, for
// example DBS0236126.
EntryID string
// Field is the tag label that matched: "synonym" or "genotype".
Field string
// DisplayText is the stored annotation value shown in the user interface.
DisplayText string
// Score ranks the match. A prefix match scores above a fuzzy match.
Score float64
}
Suggestion is one annotation autocomplete match, deduplicated by EntryID.
type TaggedAnnotationRepository ¶
type TaggedAnnotationRepository interface {
// GetAnnotationById retrieves an annotation
GetAnnotationByID(id string) (*model.AnnoDoc, error)
GetAnnotationByEntry(
req *annotation.EntryAnnotationRequest,
) (*model.AnnoDoc, error)
AddAnnotation(na *annotation.NewTaggedAnnotation) (*model.AnnoDoc, error)
EditAnnotation(
ua *annotation.TaggedAnnotationUpdate,
) (*model.AnnoDoc, error)
RemoveAnnotation(id string, purge bool) error
// ListAnnotationGroup provides a paginated list of annotation along
// with optional filtering
ListAnnotations(ctx context.Context, params *ListAnnotationsParams) ([]*model.AnnoDoc, error)
ClearAnnotations() error
Clear() error
// AddAnnotationGroup creates a new annotation group
AddAnnotationGroup(idslice ...string) (*model.AnnoGroup, error)
// GetAnnotationGroup retrieves an annotation group
GetAnnotationGroup(groupID string) (*model.AnnoGroup, error)
// AppendToAnnotationGroup adds new annotations to an existing group
AppendToAnnotationGroup(
groupID string,
idslice ...string,
) (*model.AnnoGroup, error)
// DeleteAnnotationGroup deletes an annotation group
RemoveAnnotationGroup(groupID string) error
// RemoveFromAnnotationGroup remove annotations from an existing group
RemoveFromAnnotationGroup(
groupID string,
idslice ...string,
) (*model.AnnoGroup, error)
// ListAnnotationGroup provides a paginated list of annotation groups along
// with optional filtering
ListAnnotationGroup(
ctx context.Context,
cursor, limit int64,
filter string,
) ([]*model.AnnoGroup, error)
// GetAnnotationTag retrieves tag information
GetAnnotationTag(name, ontology string) (*model.AnnoTag, error)
// AutocompleteAnnotation returns at most Limit short suggestions for
// the normalized query of params as a lazy IOEither pipeline.
AutocompleteAnnotation(
ctx context.Context,
params *AutocompleteQuery,
) IOE.IOEither[error, []*Suggestion]
// SearchAnnotation returns at most Limit ranked results for the
// normalized query of params as a lazy IOEither pipeline.
SearchAnnotation(
ctx context.Context,
params *FullSearchQuery,
) IOE.IOEither[error, []*FullSearchResult]
Dbh() *manager.Database
LoadOboJSON(r io.Reader) (*storage.UploadInformation, error)
}
TaggedAnnotationRepository is an interface for accessing annotation data from its data sources.