lamindb.core.QueryManager#
- class lamindb.core.QueryManager(*args, **kwargs)#
Bases:
Manager
Manage queries through fields.
See also
Examples
>>> ln.save(ln.ULabel.from_values(["ULabel1", "ULabel2", "ULabel3"], field="name")) # noqa >>> labels = ln.ULabel.filter(name__icontains = "label").all() >>> ln.ULabel(name="ULabel1").save() >>> label = ln.ULabel.filter(name="ULabel1").one() >>> label.parents.set(labels) >>> manager = label.parents >>> manager.df()
Attributes
- auto_created bool#
- creation_counter int#
- db property#
- use_in_migrations bool#
If set to True the manager will be serialized into migrations and will thus be available in e.g. RunPython operations.
Methods
- all()#
Return QuerySet of all.
For
**kwargs
, seelamindb.core.QuerySet.df()
.
- df(**kwargs)#
Convert to DataFrame.
For
**kwargs
, seelamindb.core.QuerySet.df()
.
- list(field=None)#
Populate a list with the results.
Examples
>>> ln.save(ln.ULabel.from_values(["ULabel1", "ULabel2", "ULabel3"], field="name")) >>> labels = ln.ULabel.filter(name__icontains="label").all() >>> ln.ULabel(name="ULabel1").save() >>> label = ln.ULabel.filter(name="ULabel1").one() >>> label.parents.set(labels) >>> label.parents.list() >>> label.parents.list("name") ['ULabel1', 'ULabel2', 'ULabel3']
- lookup(field=None, **kwargs)#
Return an auto-complete object for a field.
- Parameters:
field (
Union
[str
,DeferredAttribute
,None
], default:None
) – The field to look up the values for. Defaults to first string field.return_field – The field to return. If
None
, returns the whole record.
- Return type:
NamedTuple
- Returns:
A
NamedTuple
of lookup information of the field values with a dictionary converter.
See also
Examples
>>> import bionty as bt >>> bt.settings.organism = "human" >>> bt.Gene.from_public(symbol="ADGB-DT").save() >>> lookup = bt.Gene.lookup() >>> lookup.adgb_dt >>> lookup_dict = lookup.dict() >>> lookup_dict['ADGB-DT'] >>> lookup_by_ensembl_id = bt.Gene.lookup(field="ensembl_gene_id") >>> genes.ensg00000002745 >>> lookup_return_symbols = bt.Gene.lookup(field="ensembl_gene_id", return_field="symbol")
- search(string, **kwargs)#
Search.
Makes reasonable choices of which fields to search.
For instance, for
Artifact
, searcheskey
anddescription
fields.- Parameters:
string (
str
) – The input string to match against the field ontology values.field – The field against which the input string is matching.
limit – Maximum amount of top results to return.
return_queryset – Return search result as a sorted QuerySet.
case_sensitive – Whether the match is case sensitive.
synonyms_field – Search synonyms if column is available. If
None
, is ignored.
- Returns: If
return_queryset
isTrue
, an orderedQuerySet
.
Examples
>>> ln.save(ln.ULabel.from_values(["ULabel1", "ULabel2", "ULabel3"], field="name")) >>> ln.ULabel.search("ULabel2") uid score name ULabel2 o3FY3c5n 100.0 ULabel1 CcFPLmpq 75.0 ULabel3 Qi3c4utq 75.0