Models

Analyses

class onecodex.models.analysis.Analyses(_resource=None, **kwargs)

Bases: OneCodexBase

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
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.

save()

Either create or persist changes on this object back to the One Codex server.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

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(_resource=None, **kwargs)

Bases: Analyses

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
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.

save()

Either create or persist changes on this object back to the One Codex server.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

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(_resource=None, **kwargs)

Bases: Analyses

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
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.

save()

Either create or persist changes on this object back to the One Codex server.

table()

Return the complete results table for the classification.

Returns

tablepd.DataFrame

A Pandas DataFrame of the classification results.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

Returns

list

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

Panels

class onecodex.models.analysis.Panels(_resource=None, **kwargs)

Bases: Analyses

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
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.

save()

Either create or persist changes on this object back to the One Codex server.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

Returns

list

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

Assets

class onecodex.models.misc.Assets(_resource=None, **kwargs)

Bases: OneCodexBase, ResourceDownloadMixin

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

download(path=None, file_obj=None, progressbar=False)

Download files from One Codex.

Parameters

pathstring, optional

Full path to save the file to. If omitted, defaults to the original filename in the current working directory.

file_objfile-like object, optional

Rather than save the file to a path, write it to this file-like object.

progressbarbool

Display a progress bar using Click for the download?

Returns

string

The path the file was downloaded to, if applicable. Otherwise, None.

Notes

If no arguments specified, defaults to download the file as the original filename in the current working directory. If file_obj given, will write data into the passed file-like object. If path given, will download the file to the path provided, but will not overwrite any existing files.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
save()

Either create or persist changes on this object back to the One Codex server.

classmethod upload(file_path, progressbar=None, name=None)

Upload a file to an asset.

Parameters

file_pathstring

A path to a file on the system.

progressbarclick.progressbar, optional

If passed, display a progress bar using Click.

namestring, optional

If passed, name is sent with upload request and is associated with asset.

Returns

An Assets object upon successful upload. None if the upload failed.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

Returns

list

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

Documents

class onecodex.models.misc.Documents(_resource=None, **kwargs)

Bases: OneCodexBase, ResourceDownloadMixin

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

download(path=None, file_obj=None, progressbar=False)

Download files from One Codex.

Parameters

pathstring, optional

Full path to save the file to. If omitted, defaults to the original filename in the current working directory.

file_objfile-like object, optional

Rather than save the file to a path, write it to this file-like object.

progressbarbool

Display a progress bar using Click for the download?

Returns

string

The path the file was downloaded to, if applicable. Otherwise, None.

Notes

If no arguments specified, defaults to download the file as the original filename in the current working directory. If file_obj given, will write data into the passed file-like object. If path given, will download the file to the path provided, but will not overwrite any existing files.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
save()

Either create or persist changes on this object back to the One Codex server.

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)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

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(_resource=None, **kwargs)

Bases: OneCodexBase

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
save()

Either create or persist changes on this object back to the One Codex server.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

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(_resource=None, **kwargs)

Bases: OneCodexBase

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
save()

Either create or persist changes on this object back to the One Codex server.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

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(_resource=None, **kwargs)

Bases: OneCodexBase, ResourceDownloadMixin

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

download(path=None, file_obj=None, progressbar=False)

Download files from One Codex.

Parameters

pathstring, optional

Full path to save the file to. If omitted, defaults to the original filename in the current working directory.

file_objfile-like object, optional

Rather than save the file to a path, write it to this file-like object.

progressbarbool

Display a progress bar using Click for the download?

Returns

string

The path the file was downloaded to, if applicable. Otherwise, None.

Notes

If no arguments specified, defaults to download the file as the original filename in the current working directory. If file_obj given, will write data into the passed file-like object. If path given, will download the file to the path provided, but will not overwrite any existing files.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
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(_resource=None, name=None, sample=None)

Bases: OneCodexBase

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
save()

Either create or persist changes on this object back to the One Codex server.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

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(_resource=None, **kwargs)

Bases: OneCodexBase

classmethod all(sort=None, limit=None)

Return all objects of this type. Alias for where() (without filter arguments).

See where for documentation on the sort and limit parameters.

delete()

Delete this object from the One Codex server.

classmethod get(uuid)

Retrieve one specific object from the server by its UUID (unique 16-character id).

UUIDs are found in the web browser’s address bar while viewing analyses and other objects.

Parameters

uuidstr

UUID of the object to retrieve.

Returns

OneCodexBase or None

The object with that UUID or None if no object could be found.

Examples

>>> api.Samples.get('xxxxxxxxxxxxxxxx')
<Sample xxxxxxxxxxxxxxxx>
save()

Either create or persist changes on this object back to the One Codex server.

classmethod where(*filters, **keyword_filters)

Retrieve objects (Samples, Classifications, etc.) from the One Codex server.

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:

# returns only samples with a filename ending in ‘.gz’ my_samples = Samples.where(filter=lambda s: s.filename.endswith(‘.gz’))

Returns

list

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