Python API¶
Data Model¶
The Python API client is primarily a GraphQL client that interacts with our GraphQL API endpoint. The data model for the python API client and the GraphQL API are identical.
If you prefer to query our API endpoint directly, it’s available at https://graphql.cryoetdataportal.cziscience.com/v1/graphql
A simplified diagram of the graph data model is below:
Client¶
- class cryoet_data_portal.Client(url: str | None = None)¶
A GraphQL Client library that can traverse all the metadata in the CryoET Data Portal
- Parameters:
url (Optional[str]) – The API URL to connect to, defaults to “https://graphql.cryoetdataportal.cziscience.com/v1/graphql”
- Returns:
A GraphQL API Client library
Examples
Generate a client that connects to the default GraphQL API:
>>> client = cryoet_data_portal.Client()
Dataset¶
- class cryoet_data_portal.Dataset(client: Client, **kwargs)¶
Metadata for a dataset in the CryoET Data Portal
- id¶
An identifier for a CryoET dataset, assigned by the Data Portal. Used to identify the dataset as the directory name in data tree
- Type:
- authors¶
An array relationship with DatasetAuthor
- Type:
List[DatasetAuthor]
- cell_component_id¶
If the dataset focuses on a specific part of a cell, the subset is included here
- Type:
- cell_name¶
Name of the cell from which a biological sample used in a CryoET study is derived from.
- Type:
- dataset_citations¶
DOIs for publications that cite the dataset. Use a comma to separate multiple DOIs.
- Type:
- dataset_publications¶
DOIs for publications that describe the dataset. Use a comma to separate multiple DOIs.
- Type:
- deposition_date¶
Date when a dataset is initially received by the Data Portal.
- Type:
- description¶
A short description of a CryoET dataset, similar to an abstract for a journal article or dataset.
- Type:
- funding_sources¶
List[FundingSource] An array relationship with FundingSource
- Type:
- last_modified_date¶
Date when a released dataset is last modified.
- Type:
date
- organism_name¶
Name of the organism from which a biological sample used in a CryoET study is derived from, e.g. homo sapiens
- Type:
- other_setup¶
Describe other setup not covered by sample preparation or grid preparation that may make this dataset unique in the same publication
- Type:
If a CryoET dataset is also deposited into another database, enter the database identifier here (e.g. EMPIAR-11445). Use a comma to separate multiple identifiers.
- Type:
If a CryoET dataset is also deposited into another database, e.g. EMPIAR, enter the database identifier here (e.g.https://www.ebi.ac.uk/empiar/EMPIAR-12345/). Use a comma to separate multiple links.
- Type:
- release_date¶
Date when a dataset is made available on the Data Portal.
- Type:
date
- runs¶
List[Run] An array relationship with Run
- Type:
- sample_type¶
Type of samples used in a CryoET study. (cell, tissue, organism, intact organelle, in-vitro mixture, in-silico synthetic data, other)
- Type:
- tissue_name¶
Name of the tissue from which a biological sample used in a CryoET study is derived from.
- Type:
- download_everything(dest_path: str | None = None)¶
Download all of the data for this dataset.
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (
DatasetFunding¶
- class cryoet_data_portal.DatasetFunding(client: Client, **kwargs)¶
Metadata for a dataset’s funding sources
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (
Run¶
- class cryoet_data_portal.Run(client: Client, **kwargs)¶
Metadata for an experiment run
- tiltseries¶
An array relationship with TiltSeries that correspond to this run
- Type:
- tomogram_voxel_spacings¶
An array relationship with the Tomogram Voxel Spacings created from this run
- Type:
- download_everything(dest_path: str | None = None)¶
Download all of the data for this run.
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (
TomogramVoxelSpacing¶
- class cryoet_data_portal.TomogramVoxelSpacing(client: Client, **kwargs)¶
Metadata for a set of tomograms and annotations of a given voxel spacing
- annotations¶
An array relationship with the annotations associated with this voxel spacing
- Type:
- download_everything(dest_path: str | None = None)¶
Download all of the data for this run.
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (
Tomogram¶
- class cryoet_data_portal.Tomogram(client: Client, **kwargs)¶
Metadata for a tomogram
- affine_transformation_matrix¶
The flip or rotation transformation of this author submitted tomogram is indicated here
- Type:
- fiducial_alignment_status¶
Fiducial Alignment status: True = aligned with fiducial False = aligned without fiducial
- Type:
- is_canonical¶
Is this tomogram considered the canonical tomogram for the run experiment? True=Yes
- Type:
- reconstruction_method¶
Describe reconstruction method (Weighted back-projection, SART, SIRT)
- Type:
- size_z¶
Number of pixels in the 3D data slow axis. This is the image projection direction at zero stage tilt
- Type:
- tomogram_version¶
Version of tomogram using the same software and post-processing. Version of tomogram using the same software and post-processing. This will be presented as the latest version
- Type:
- tomogram_voxel_spacing¶
An object relationship with a specific voxel spacing for this experiment run
- Type:
- download_all_annotations(dest_path: str | None = None, format: str | None = None, shape: str | None = None)¶
Download all annotation files for this tomogram
- Parameters:
- download_mrcfile(dest_path: str | None = None)¶
Download an MRC file of this tomogram
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- download_omezarr(dest_path: str | None = None)¶
Download the OME-Zarr version of this tomogram
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (
Annotation¶
- class cryoet_data_portal.Annotation(client: Client, **kwargs)¶
Metadata for an annotation
- annotation_method¶
Describe how the annotation is made (e.g. Manual, crYoLO, Positive Unlabeled Learning, template matching)
- Type:
- annotation_publication¶
DOIs for publications that describe the dataset. Use a comma to separate multiple DOIs.
- Type:
- confidence_precision¶
Describe the confidence level of the annotation. Precision is defined as the % of annotation objects being true positive
- Type:
- confidence_recall¶
Describe the confidence level of the annotation. Recall is defined as the % of true positives being annotated correctly
- Type:
- deposition_date¶
Date when an annotation set is initially received by the Data Portal.
- Type:
date
- files¶
An array relationship with the files of this annotation
- Type:
- ground_truth_status¶
Whether an annotation is considered ground truth, as determined by the annotator.
- Type:
- last_modified_date¶
Date when an annotation was last modified in the Data Portal
- Type:
date
- method_type¶
The method type for generating the annotation (eg. manual, hybrid, automated)
- Type:
- object_description¶
A textual description of the annotation object, can be a longer description to include additional information not covered by the Annotation object name and state.
- Type:
- object_name¶
Name of the object being annotated (e.g. ribosome, nuclear pore complex, actin filament, membrane)
- Type:
- release_date¶
Date when annotation data is made public by the Data Portal.
- Type:
date
- tomogram_voxel_spacing¶
An object relationship with a specific voxel spacing for this annotation
- Type:
- tomogram_voxel_spacing_id¶
Reference to the tomogram voxel spacing group this annotation applies to
- Type:
- download(dest_path: str | None = None, format: str | None = None, shape: str | None = None)¶
Download annotation files for a given format and/or shape
- Parameters:
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (
AnnotationFile¶
- class cryoet_data_portal.AnnotationFile(client: Client, **kwargs)¶
Metadata for an annotation file
- is_visualization_default¶
Is this annotation shape displayed in visualization tools by default
- Type:
- Annotation¶
The annotation this file is a part of
- Type:
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (
TiltSeries¶
- class cryoet_data_portal.TiltSeries(client: Client, **kwargs)¶
Metadata about how a tilt series was generated, and locations of output files
- microscope_additional_info¶
Other microscope optical setup information, in addition to energy filter, phase plate and image corrector
- Type:
If a tilt series is deposited into EMPIAR, enter the EMPIAR dataset identifier
- Type:
- spherical_aberration_constant¶
Spherical Aberration Constant of the objective lens in millimeters
- Type:
- tilt_series_quality¶
Author assessment of tilt series quality within the dataset (1-5, 5 is best)
- Type:
- total_flux¶
Number of Electrons reaching the specimen in a square Angstrom area for the entire tilt series
- Type:
- download_alignment_file(dest_path: str | None = None)¶
Download the alignment file for this tiltseries
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- download_angle_list(dest_path: str | None = None)¶
Download the angle list for this tiltseries
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- download_collection_metadata(dest_path: str | None = None)¶
Download the collection metadata for this tiltseries
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- download_mrcfile(dest_path: str | None = None)¶
Download an MRC file for this tiltseries
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- download_omezarr(dest_path: str | None = None)¶
Download the omezarr version of this tiltseries
- Parameters:
dest_path (Optional[str], optional) – Choose a destination directory. Defaults to $CWD.
- classmethod find(client: Client, query_filters: Iterable[GQLExpression] | None = None)¶
Find objects based on a set of search filters.
Search filters are combined with and so all results will match all filters.
- Expressions with python-native operators (
==
,!=
,>
,>=
,<
,<=
) must be in the format: ModelSubclass.field
{operator}
{value}
Example
Tomogram.voxel_spacing.run.name == "RUN1"
- Expressions with method operators (
like
,ilike
,_in
) must be in the format: ModelSubclass.field.{operator}({value})
Examples
Tomogram.voxel_spacing.run.name.like("%RUN1%")
Tomogram.voxel_spacing.run.name._in(["RUN1", "RUN2"])
Supported operators are:
==
,!=
,>
,>=
,<
,<=
,like
,ilike
,_in
like
is a partial match, with the % character being a wildcardilike
is similar tolike
but case-insensitive_in
accepts a list of values that are acceptable matches.
Values may be strings or numbers depending on the type of the field being matched, and _in supports a list of values of the field’s corresponding type.
ModelSubclass.field
may be an arbitrarily nested path to any field on any related model, such as:ModelSubclass.related_class_field.related_field.second_related_class_field.second_field
- Parameters:
client – A CryoET Portal API Client
query_filters – A set of expressions that narrow down the search results
- Yields:
Matching Model objects.
Examples
Filter runs by attributes, including attributes in related models:
>>> runs = Run.find(client, query_filters=[Run.name == "TS_026", Run.dataset.id == 10000]) >>> runs = Run.find(client, query_filters=[Run.name._in(['TS_026', 'TS_027']), Run.tomogram_voxel_spacings.annotations.object_name.ilike('%membrane%')])
Get all results for this type:
>>> runs = Run.find(client)
- Expressions with python-native operators (