Models

Analyses

class onecodex.models.analysis.Analyses(*, field_uri: str, created_at: Annotated[datetime, PlainSerializer(func=rfc3339_encoder, return_type=str, when_used=always), BeforeValidator(func=rfc3339_decoder, json_schema_input_type=PydanticUndefined)], complete: bool = False, error_msg: str | None = None, job: Jobs | ApiRef, job_args: dict[str, Any] = {}, sample: Samples | ApiRef, success: bool = False, analysis_type: str)

Bases: _AnalysesBase, AnalysisSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

results(json=True)

Fetch the results of an Analyses resource.

Parameters

jsonbool, optional

Return a JSON result (raw API result)? Default True.

Returns

Return type varies by Analyses resource sub-type. See, e.g., Classifications or Panels for documentation.

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

Alignments

class onecodex.models.analysis.Alignments(*, field_uri: str, created_at: Annotated[datetime, PlainSerializer(func=rfc3339_encoder, return_type=str, when_used=always), BeforeValidator(func=rfc3339_decoder, json_schema_input_type=PydanticUndefined)], complete: bool = False, error_msg: str | None = None, job: Jobs | ApiRef, job_args: dict[str, Any] = {}, sample: Samples | ApiRef, success: bool = False)

Bases: _AnalysesBase, AlignmentSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

results(json=True)

Fetch the results of an Analyses resource.

Parameters

jsonbool, optional

Return a JSON result (raw API result)? Default True.

Returns

Return type varies by Analyses resource sub-type. See, e.g., Classifications or Panels for documentation.

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

Classifications

class onecodex.models.analysis.Classifications(*, field_uri: str, created_at: Annotated[datetime, PlainSerializer(func=rfc3339_encoder, return_type=str, when_used=always), BeforeValidator(func=rfc3339_decoder, json_schema_input_type=PydanticUndefined)], complete: bool = False, error_msg: str | None = None, job: Jobs | ApiRef, job_args: dict[str, Any] = {}, sample: Samples | ApiRef, success: bool = False)

Bases: _AnalysesBase, ClassificationSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

results(json=True)

Return the complete results table for a classification.

Parameters

jsonbool, optional

Return result as JSON? Default True.

Returns

tabledict or pd.DataFrame

Return a JSON object with the classification results or a pd.DataFrame if json=False.

table()

Return the complete results table for the classification.

Returns

tablepd.DataFrame

A Pandas DataFrame of the classification results.

classmethod where(*filters, **keyword_filters)

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

FunctionalProfiles

Panels

class onecodex.models.analysis.Panels(*, field_uri: str, created_at: Annotated[datetime, PlainSerializer(func=rfc3339_encoder, return_type=str, when_used=always), BeforeValidator(func=rfc3339_decoder, json_schema_input_type=PydanticUndefined)], complete: bool = False, error_msg: str | None = None, job: Jobs | ApiRef, job_args: dict[str, Any] = {}, sample: Samples | ApiRef, success: bool = False)

Bases: _AnalysesBase, PanelSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

results(json=True)

Fetch the results of an Analyses resource.

Parameters

jsonbool, optional

Return a JSON result (raw API result)? Default True.

Returns

Return type varies by Analyses resource sub-type. See, e.g., Classifications or Panels for documentation.

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

Assets

Documents

class onecodex.models.misc.Documents(*, field_uri: str, created_at: Annotated[datetime, PlainSerializer(func=rfc3339_encoder, return_type=str, when_used=always), BeforeValidator(func=rfc3339_decoder, json_schema_input_type=PydanticUndefined)], filename: str, size: int | None = None, uploader: Users | ApiRef, downloaders: List[Users | ApiRef] = [])

Bases: OneCodexBase, DocumentSchema, ResourceDownloadMixin

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod upload(file_path, progressbar=None)

Upload a series of files to the One Codex server.

Parameters

file_pathstring

A path to a file on the system.

progressbarclick.progressbar, optional

If passed, display a progress bar using Click.

Returns

A Documents object upon successful upload. None if the upload failed.

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

Jobs

class onecodex.models.misc.Jobs(*, field_uri: str, created_at: ~typing.Annotated[~datetime.datetime, ~pydantic.functional_serializers.PlainSerializer(func=~onecodex.models.schemas.types.rfc3339_encoder, return_type=str, when_used=always), ~pydantic.functional_validators.BeforeValidator(func=~onecodex.models.schemas.types.rfc3339_decoder, json_schema_input_type=PydanticUndefined)], name: str, job_args_schema: dict[str, ~typing.Any] = <factory>, analysis_type: str, public: bool)

Bases: OneCodexBase, JobSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

Projects

class onecodex.models.misc.Projects(*, field_uri: str, description: str | None = None, external_id: str | None = None, name: str | None = None, owner: Users | ApiRef, permissions: list[str], project_name: Annotated[str | None, MinLen(min_length=3), MaxLen(max_length=15), _PydanticGeneralMetadata(pattern='^[a-zA-Z0-9_-]{3,15}$')], public: bool = False)

Bases: OneCodexBase, ProjectSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

Samples

class onecodex.models.sample.Samples(*, field_uri: str, created_at: datetime, error_msg: str | None = None, filename: str | None = None, metadata: Metadata | ApiRef, owner: Users | ApiRef, primary_classification: Classifications | ApiRef | None = None, project: Projects | ApiRef | None = None, size: int | None = None, tags: List[Tags | ApiRef] = [], status: str, visibility: str, updated_at: datetime | None = None)

Bases: OneCodexBase, _SampleSchema, ResourceDownloadMixin

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod preupload(metadata=None, tags=None, project=None)

Create a sample in a waiting state where the files will be sent later on.

Parameters

metadata : dict, optional tags : list, optional

A list of optional tags to create. Tags must be passed as dictionaries with a single key name and the tag name, e.g., {“name”: “my tag”}. New tags will be created on-the-fly as needed.

projectstring, optional

UUID of project to associate this sample with.

save()

Send changes on this Samples object to the One Codex server.

Changes to the metadata object and tags list are passed as well.

classmethod upload(files, metadata=None, tags=None, project=None, coerce_ascii=False, progressbar=None, sample_id=None, external_sample_id=None)

Upload a series of files to the One Codex server.

Parameters

filesstring or tuple

A single path to a file on the system, or a tuple containing a pairs of paths. Tuple values will be interleaved as paired-end reads and both files should contain the same number of records. Paths to single files will be uploaded as-is.

metadata : dict, optional tags : list, optional

A list of optional tags to create. Tags must be passed as dictionaries with a single key name and the tag name, e.g., {“name”: “my tag”}. New tags will be created on-the-fly as needed.

projectstring, optional

UUID of project to associate this sample with.

coerce_asciibool, optional

If true, rename unicode filenames to ASCII and issue warning.

progressbarclick.progressbar, optional

If passed, display a progress bar using Click.

sample_idstring, optional

If passed, will upload the file(s) to the sample with that id. Only works if the sample was pre-uploaded

external_sample_idstring, optional

If passed, will upload the file(s) to the sample with that metadata external id. Only works if the sample was pre-uploaded

Returns

A Samples object upon successful upload. None if the upload failed.

classmethod where(*filters, **keyword_filters)

Query and retrieve a set of samples.

Parameters

limitint, optional

If set, retrieve a maximum of limit samples. Note a limit of 1000 samples is automatically enforced for queries of all public samples (public=True)

organizationbool, optional

If True, search all samples within your organization (including your samples). May not be combined with public=True.

publicbool, optional

If True, search all public samples (limited to 1000 results). May not be combined with organization=True.

tagslist, optional

A list of optional Tags to filter by. Tags should be Tag objects retrieved with ocx.Tags.get() or ocx.Tags.where()

projectProject, optional

Filter by a Project

**keyword_filtersdict, optional

Pass any additional sample or metadata attribute to filter by that attribute. Metadata filtering is not currently supported for

Returns

A SampleCollection object with samples matching the query

Tags

class onecodex.models.misc.Tags(*, field_uri: str | None = None, name: Annotated[str, MaxLen(max_length=30)])

Bases: OneCodexBase, TagSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.

Users

class onecodex.models.misc.Users(*, field_uri: str, email: str | None)

Bases: OneCodexBase, UserSchema

model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'populate_by_alias': True}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

classmethod where(*filters, **keyword_filters) List[OneCodexBase]

Filter model records of this type from the One Codex server.

This method works for all OneCodex model types including Samples, Classifications, Projects, and Panels.

Parameters

filtersobject

Advanced filters to use (not implemented)

sortstr or list, optional

Sort the results by this field (or list of fields). By default in descending order, but if any of the fields start with the special character ^, sort in ascending order. For example, sort=[‘size’, ‘^filename’] will sort by size from largest to smallest and filename from A-Z for items with the same size.

limitint, optional

Number of records to return. For smaller searches, this can reduce the number of network requests made.

keyword_filtersstr or object

Filter the results by specific keywords (or filter objects, in advanced usage)

Examples

You can filter objects that are returned locally using a lambda function

All models implement the same method. To see a complete list of models which can be retrieved by ID, see the models page.

# Filter samples by filename
my_samples = Samples.where(filter=lambda s: s.filename.endswith('.gz'))

# Filter classifications by completion status
completed = Classifications.where(filter=lambda c: c.complete == True)

# Filter projects by name
my_projects = Projects.where(filter=lambda p: 'test' in p.name)

Returns

list

A list of all objects matching these filters. If no filters are passed, this matches all objects.