Protocol¶
The protocol
module helps extracting information from a
MultispeQ protocol for a subsequent analysis of the MultispeQ data based on
settings and information within the used protocol.
The provided protocol can either be from a local resource like a file or a variable, or from an online project’s information.
Protocol¶
Functions to work with MultispeQ protocols. This includes getting the protocol from the project information and extracting information from the protocol code including subprotocols by their labels or positions within the protocol.
- get_protocol(project=None, index=0)[source]¶
Return the protocol for a project given the project information. A project’s protocol for a MultispeQ is a list of protocols. This function is returning a single protocol from the list.
- Parameters:
project (dict) – Project information as returned by
jii_multispeq.project.get()
index (int) – Protocol position in list of project protocols. The default protocol position is 0.
- Returns:
The code of the selected protocol.
- Return type:
dict
- Raises:
ValueError – if no project information is provided
KeyError – if the key protocol_json is missing in the project information
ValueError – if the protocol_json value is not formatted properly
ValueError – if the provided index is not an integer
IndexError – if the provided index is out of range
- get_protocol_name(project=None, index=0)[source]¶
Get the protocol name from the provided Project. The PhotosynQ_Py library is creating a dictionary of data frames, with the keys being the protocol names. Most projects have only one protocol, but some projects in the past had multiple.
- Parameters:
project (dict) – Project information as returned by
jii_multispeq.project.get()
index (int) – Protocol position in list of project protocols. The default protocol position is 0.
- Returns:
a string with the protocol name
- Return type:
string
- Raises:
ValueError – if no project information is provided
KeyError – if the protocols key is missing in the project information
IndexError – if provided index is out of range for the protocols list
- get_subprotocol_labels(protocol=None)[source]¶
Returns a list of labels for each subprotocol. In case a sub-protocol has no label,
None
is returned.- Parameters:
protocol (dict) – Protocol as returned by
jii_multispeq.protocol.get_protocol()
- Returns:
list of sub-protocols label
- Return type:
list[str]
- Raises:
ValueError – If no protocol is provided
ValueError – If the provided protocol is not a dictionary
KeyError – If the _protocol_set_ key is missing in the provided protocol
- get_subprotocols_by_label(protocol=None, label='')[source]¶
Returns a list of sub_protocols in a protocol with given label value label is the desired label. If the protocol does not have labels, will be ignored. protocol is the protocol to be seaerched.
- Parameters:
protocol (dict) – Protocol as returned by
jii_multispeq.protocol.get_protocol()
label (string) – Protocol label to search
- Returns:
list of sub-protocols with matching label
- Return type:
list[dict]
- Raises:
ValueError – If no protocol is provided
ValueError – If the provided protocol is not a dictionary
KeyError – If the _protocol_set_ key is missing in the provided protocol
- get_subprotocol_by_index(protocol=None, index=0)[source]¶
Returns a list of sub_protocols in a protocol with given label value label is the desired label. If the protocol does not have labels, will be ignored. protocol is the protocol to be seaerched.
- Parameters:
project_json – project information file
subidx – index of the selected sub-protocol
index – protocol position in the list of protocols (default: 0)
- Returns:
single sub-protocol as a dictionary
- Return type:
dict
- Raises:
ValueError – If no protocol is provided
ValueError – If the provided protocol is not a dictionary
KeyError – If the _protocol_set_ key is missing in the provided protocol
ValueError – If provided index is not an integer
IndexError – If provided index is out of range
Variable Arrays¶
MultispeQ protocols can contain a so called v_arrays
that allow to define
values as variabls, which can be used throughout the protocol, so the value
itself doesn’t need to be repeated multiple times throughout the protocol.
The functions allow to access the v_arrays
themselfs as well as
accessing specific variable values, so they can be available for the later
data analysis.
- get_v_arrays(protocol=None)[source]¶
Get the
v_arrays
(variable arrays) from a given protocol. Seeget_protocol()
on how to extract a single protocol.- Parameters:
protocol (dict) – Single MultispeQ Protocol
- Returns:
v_arrays
content- Return type:
dict
- Raises:
ValueError – If no protocol is provided.
ValueError – If protocol is not provided as a dictionary.
Exception – If the provided protocol doesn’t have a v_arrays.