SampleOperations¶
Access via client.samples.
crucible.resources.samples.SampleOperations
¶
Sample-related API operations.
Access via: client.samples.get(), client.samples.list(), etc.
get(sample_id, include_links=False, include_metadata=False, include_owner=False)
¶
Get sample information by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
str
|
Sample unique identifier |
required |
include_links
|
bool
|
Whether to include immediate parent/child/associated links |
False
|
include_metadata
|
bool
|
Whether to include scientific metadata |
False
|
include_owner
|
bool
|
Whether to resolve owner_orcid into a full user object |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Sample information with optional links and metadata |
list(dataset_id=None, parent_id=None, include_metadata=False, include_links=False, include_owner=False, limit=DEFAULT_LIMIT, offset=0, **kwargs)
¶
List samples with optional filtering and automatic pagination.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset_id
|
str
|
Get samples from specific dataset |
None
|
parent_id
|
str
|
Get child samples from parent (deprecated) |
None
|
include_metadata
|
bool
|
Include scientific metadata in results |
False
|
include_links
|
bool
|
Include linked resources (parents, children, associated) per sample |
False
|
include_owner
|
bool
|
Resolve owner_orcid into a full user object per sample |
False
|
limit
|
int
|
Maximum total results to return (default: 100). Larger requests are handled transparently by following the server's keyset cursor. Pass None to fetch all matches. |
DEFAULT_LIMIT
|
offset
|
int
|
Deprecated for the top-level /samples endpoint, which now uses keyset pagination and ignores offset. Still honored for the dataset_id/parent_id sub-listings. |
0
|
**kwargs
|
Query parameters for filtering samples |
{}
|
Returns:
| Type | Description |
|---|---|
List[Dict]
|
List[Dict]: Sample information |
create(sample=None, scientific_metadata=None, parents=[], children=[], **kwargs)
¶
Create a new sample record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
Sample
|
Sample model instance with the desired fields. |
None
|
scientific_metadata
|
dict
|
Scientific metadata to attach after creation. |
None
|
parents
|
list
|
Parent samples to link ({unique_id: ...}). |
[]
|
children
|
list
|
Child samples to link ({unique_id: ...}). |
[]
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Created sample record. |
update(unique_id, sample_name=None, description=None, timestamp=None, owner_orcid=None, project_id=None, sample_type=None, public=None, parents=[], children=[], date_created=None, creation_date=None, owner_id=None, owner_user_id=None)
¶
Update an existing sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
unique_id
|
str
|
Sample unique identifier (required) |
required |
sample_name
|
str
|
Human-readable sample name |
None
|
sample_type
|
str
|
Category of sample (for filtering) |
None
|
description
|
str
|
Sample description |
None
|
timestamp
|
str
|
User-defined timestamp |
None
|
owner_orcid
|
str
|
Owner's ORCID |
None
|
public
|
bool
|
Whether the sample is publicly visible |
None
|
project_id
|
str
|
Project ID |
None
|
parents
|
List[Dict]
|
Parent samples to link |
[]
|
children
|
List[Dict]
|
Child samples to link |
[]
|
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Updated sample object |
add_dataset(sample_id, dataset_id)
¶
Link a dataset to this sample.
Delegates to DatasetOperations.add_sample — single implementation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
str
|
Sample unique identifier |
required |
dataset_id
|
str
|
Dataset unique identifier |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Information about the created link |
remove_dataset(sample_id, dataset_id)
¶
Remove the link between a sample and a dataset.
Requires admin permissions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
str
|
Sample unique identifier |
required |
dataset_id
|
str
|
Dataset unique identifier |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Deletion confirmation |
link(parent_id, child_id)
¶
Link two samples with a parent-child relationship.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
Unique sample identifier of parent sample |
required |
child_id
|
str
|
Unique sample identifier of child sample |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Created link object |
remove_child(parent_id, child_id)
¶
Remove the parent-child link between two samples.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
Unique sample identifier of parent sample |
required |
child_id
|
str
|
Unique sample identifier of child sample |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Dict |
Dict
|
Deletion confirmation |
list_parents(sample_id, limit=DEFAULT_LIMIT, offset=0, **kwargs)
¶
List the parents of a given sample with optional filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
str
|
The unique ID of the sample for which you want to find the parents |
required |
limit
|
int
|
Maximum number of results to return (default: 100) |
DEFAULT_LIMIT
|
offset
|
int
|
Starting position in the full result set (default: 0) |
0
|
**kwargs
|
Query parameters for filtering samples |
{}
|
Returns:
| Type | Description |
|---|---|
List[Dict]
|
List[Dict]: Parent samples |
list_children(sample_id, limit=DEFAULT_LIMIT, offset=0, **kwargs)
¶
List the children of a given sample with optional filtering.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
str
|
The unique ID of the sample for which you want to find the children |
required |
limit
|
int
|
Maximum number of results to return (default: 100) |
DEFAULT_LIMIT
|
offset
|
int
|
Starting position in the full result set (default: 0) |
0
|
**kwargs
|
Query parameters for filtering samples |
{}
|
Returns:
| Type | Description |
|---|---|
List[Dict]
|
List[Dict]: Children samples |
graph(sample_id, recursive=False, as_networkx=False)
¶
Return the graph of entities connected to this sample.
Delegates to client.graphs.get(). See GraphOperations.get() for full docs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample_id
|
str
|
Sample unique identifier. |
required |
recursive
|
bool
|
If True, traverse the full connected component. |
False
|
as_networkx
|
bool
|
Return a networkx DiGraph if True. |
False
|
Returns:
| Type | Description |
|---|---|
|
dict | networkx.DiGraph: Node-link graph data. |