bionty.core.BioRecord

class bionty.core.BioRecord(*args, **kwargs)

Bases: Record, HasParents, CanValidate

Base Record of bionty.

BioRecord inherits all methods from Record and provides additional methods including public() and from_source().

Notes

For more info, see tutorials:

Simple fields

Methods

classmethod add_source(source, currently_used=True)

Configure a source of the entity.

Return type:

Source

classmethod from_public(*args, **kwargs)

Create a record or records from public reference based on a single field value.

Return type:

BioRecord | list[BioRecord] | None

Notes

For more info, see tutorial bionty

Bulk create protein records via from_values().

Examples

Create a record by passing a field value:

>>> record = bionty.Gene.from_public(symbol="TCF7", organism="human")
classmethod from_source(*, mute=False, **kwargs)

Create a record or records from source based on a single field value.

Return type:

BioRecord | list[BioRecord] | None

Notes

For more info, see tutorial bionty

Bulk create protein records via from_values().

Examples

Create a record by passing a field value:

>>> record = bionty.Gene.from_source(symbol="TCF7", organism="human")

Create a record from non-default source:

>>> source = bionty.Source.get(entity="CellType", source="cl", version="2022-08-16")  # noqa
>>> record = bionty.CellType.from_source(name="T cell", source=source)
classmethod import_from_source(source=None, ontology_ids=None, organism=None, ignore_conflicts=True, update=False)

Bulk save records from a dataframe.

Use this method to initialize your registry with public ontology.

Parameters:
  • ontology_ids (list[str] | None, default: None) – List of ontology ids to save

  • organism (str | Record | None, default: None) – Organism record or name

  • source (Source | None, default: None) – Source record

  • ignore_conflicts (bool, default: True) – Ignore conflicts during bulk create

Examples

>>> bionty.CellType.import_from_source()
classmethod list_source(currently_used=None, in_db=None, organism=None)

Default source for the registry.

Parameters:

currently_used (bool | None, default: None) – Only returns currently used sources

Return type:

Source

Examples

>>> bionty.Gene.list_source()
>>> bionty.Gene.list_source(currently_used=True)
classmethod public(organism=None, source=None)

The corresponding PublicOntology object.

Note that the source is auto-configured and tracked via bionty.Source(). :rtype: PublicOntology | StaticReference

See also

PublicOntology

Examples

>>> celltype_pub = bionty.CellType.public()
>>> celltype_pub
PublicOntology
Entity: CellType
Organism: all
Source: cl, 2023-04-20
#terms: 2698
save(*args, **kwargs)

Save the record and its parents recursively.

Return type:

BioRecord