Skip to content

Computation

Computation

Bases: PrimaryBaseNode

Definition

The Computation node describes the transformation of data or the creation of a computational data set.

Common computations for simulations are energy minimization, annealing, quenching, or NPT/NVT (isothermal-isobaric/canonical ensemble) simulations.

Common computations for experimental data include fitting a reaction model to kinetic data to determine rate constants, a plateau modulus from a time-temperature-superposition, or calculating radius of gyration with the Debye function from small angle scattering data.

Attributes
attribute type example description required vocab
type str general molecular dynamics simulation category of computation True True
input_data list[Data] input data nodes
output_data list[Data] output data nodes
software_ configurations list[Software Configuration] software and algorithms used
condition list[Condition] setup information
prerequisite_computation Computation prior computation method in chain
citation list[Citation] reference to a book, paper, or scholarly work
notes str additional description of the step
JSON Representation
{
   "name":"my computation name",
   "node":["Computation"],
   "type":"analysis",
   "uid":"_:69f29bec-e30a-4932-b78d-2e4585b37d74",
   "uuid":"69f29bec-e30a-4932-b78d-2e4585b37d74"
   "citation":[],
}
Available Subobjects
Source code in src/cript/nodes/primary_nodes/computation.py
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
class Computation(PrimaryBaseNode):
    """
    ## Definition

    The
    [Computation node](https://pubs.acs.org/doi/suppl/10.1021/acscentsci.3c00011/suppl_file/oc3c00011_si_001.pdf#page=14)
    describes the transformation of data or the creation of a computational data
    set.

    **Common computations for simulations** are energy minimization, annealing, quenching, or
    NPT/NVT (isothermal-isobaric/canonical ensemble) simulations.

    **Common computations for experimental** data include fitting a reaction model to kinetic data
    to determine rate constants, a plateau modulus from a time-temperature-superposition, or calculating radius of
    gyration with the Debye function from small angle scattering data.



    ## Attributes
    | attribute                | type                          | example                               | description                                   | required | vocab |
    |--------------------------|-------------------------------|---------------------------------------|-----------------------------------------------|----------|-------|
    | type                     | str                           | general molecular dynamics simulation | category of computation                       | True     | True  |
    | input_data               | list[Data]                    |                                       | input data nodes                              |          |       |
    | output_data              | list[Data]                    |                                       | output data nodes                             |          |       |
    | software_ configurations | list[Software  Configuration] |                                       | software and algorithms used                  |          |       |
    | condition                | list[Condition]               |                                       | setup information                             |          |       |
    | prerequisite_computation | Computation                   |                                       | prior computation method in chain             |          |       |
    | citation                 | list[Citation]                |                                       | reference to a book, paper, or scholarly work |          |       |
    | notes                    | str                           |                                       | additional description of the step            |          |       |

    ## JSON Representation
    ```json
    {
       "name":"my computation name",
       "node":["Computation"],
       "type":"analysis",
       "uid":"_:69f29bec-e30a-4932-b78d-2e4585b37d74",
       "uuid":"69f29bec-e30a-4932-b78d-2e4585b37d74"
       "citation":[],
    }
    ```


    ## Available Subobjects
    * [Software Configuration](../../subobjects/software_configuration)
    * [Condition](../../subobjects/condition)
    * [Citation](../../subobjects/citation)

    """

    @dataclass(frozen=True)
    class JsonAttributes(PrimaryBaseNode.JsonAttributes):
        """
        all computation nodes attributes
        """

        type: str = ""
        # TODO add proper typing in future, using Any for now to avoid circular import error
        input_data: List[Union[Any, UIDProxy]] = field(default_factory=list)
        output_data: List[Union[Any, UIDProxy]] = field(default_factory=list)
        software_configuration: List[Union[Any, UIDProxy]] = field(default_factory=list)
        condition: List[Union[Any, UIDProxy]] = field(default_factory=list)
        prerequisite_computation: Optional[Union["Computation", UIDProxy]] = None
        citation: List[Union[Any, UIDProxy]] = field(default_factory=list)

    _json_attrs: JsonAttributes = JsonAttributes()

    @beartype
    def __init__(
        self,
        name: str,
        type: str,
        input_data: Optional[List[Union[Any, UIDProxy]]] = None,
        output_data: Optional[List[Union[Any, UIDProxy]]] = None,
        software_configuration: Optional[List[Union[Any, UIDProxy]]] = None,
        condition: Optional[List[Union[Any, UIDProxy]]] = None,
        prerequisite_computation: Optional[Union["Computation", UIDProxy]] = None,
        citation: Optional[List[Union[Any, UIDProxy]]] = None,
        notes: str = "",
        **kwargs
    ) -> None:
        """
        create a computation node

        Parameters
        ----------
        name: str
            name of computation node
        type: str
            type of computation node. Computation type must come from CRIPT controlled vocabulary
        input_data: List[Data] default=None
            input data (data node)
        output_data: List[Data] default=None
            output data (data node)
        software_configuration: List[SoftwareConfiguration] default=None
            software configuration of computation node
        condition: List[Condition] default=None
            condition for the computation node
        prerequisite_computation: Computation default=None
            prerequisite computation
        citation: List[Citation] default=None
            list of citations
        notes: str = ""
            any notes for this computation node
        **kwargs
            for internal use of deserialize JSON from API to node

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")

        Returns
        -------
        None
            instantiate a computation node

        """
        super().__init__(name=name, notes=notes, **kwargs)

        if input_data is None:
            input_data = []

        if output_data is None:
            output_data = []

        if software_configuration is None:
            software_configuration = []

        if condition is None:
            condition = []

        if citation is None:
            citation = []

        new_json_attrs = replace(
            self._json_attrs,
            type=type,
            input_data=input_data,
            output_data=output_data,
            software_configuration=software_configuration,
            condition=condition,
            prerequisite_computation=prerequisite_computation,
            citation=citation,
        )
        self._update_json_attrs_if_valid(new_json_attrs)

    # ------------------ Properties ------------------

    @property
    @beartype
    def type(self) -> str:
        """
        The type of computation

        The [computation type](https://app.criptapp.org/vocab/computation_type)
        must come from CRIPT controlled vocabulary

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")
        >>> my_computation.type = type="analysis"

        Returns
        -------
        str
            type of computation
        """
        return self._json_attrs.type

    @type.setter
    @beartype
    def type(self, new_computation_type: str) -> None:
        """
        set the computation type

        the computation type must come from CRIPT controlled vocabulary

        Parameters
        ----------
        new_computation_type: str

        Returns
        -------
        None
        """
        new_attrs = replace(self._json_attrs, type=new_computation_type)
        self._update_json_attrs_if_valid(new_attrs)

    @property
    @beartype
    def input_data(self) -> List[Any]:
        """
        List of input data (data nodes) for this node

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")
        >>> my_file = cript.File(
        ...     name="my file node name",
        ...     source="https://criptapp.org",
        ...     type="calibration",
        ...     extension=".csv",
        ...     data_dictionary="my file's data dictionary"
        ... )
        >>> my_input_data = cript.Data(name="my data name", type="afm_amp", file=[my_file])
        >>> my_computation.input_data = [my_input_data]

        Returns
        -------
        List[Data]
            list of input data for this computation
        """
        return self._json_attrs.input_data.copy()

    @input_data.setter
    @beartype
    def input_data(self, new_input_data_list: List[Any]) -> None:
        """
        set the input data list

        Parameters
        ----------
        new_input_data_list: List[Data]
            list of input data (data nodes) to replace the current

        Returns
        -------
        None
        """
        new_attrs = replace(self._json_attrs, input_data=new_input_data_list)
        self._update_json_attrs_if_valid(new_attrs)

    @property
    @beartype
    def output_data(self) -> List[Any]:
        """
        List of output data (data nodes)

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")
        >>> my_file = cript.File(
        ...     name="my file node name",
        ...     source="https://criptapp.org",
        ...     type="calibration",
        ...     extension=".csv",
        ...     data_dictionary="my file's data dictionary"
        ... )
        >>> my_output_data = cript.Data(name="my data name", type="afm_amp", file=[my_file])
        >>> my_computation.output_data = [my_output_data]

        Returns
        -------
        List[Data]
            list of output data for this computation
        """
        return self._json_attrs.output_data.copy()

    @output_data.setter
    @beartype
    def output_data(self, new_output_data_list: List[Any]) -> None:
        """
        set the list of output data (data nodes) for this node

        Parameters
        ----------
        new_output_data_list: List[Data]
            replace the current list of output data for this node

        Returns
        -------
        None
        """
        new_attrs = replace(self._json_attrs, output_data=new_output_data_list)
        self._update_json_attrs_if_valid(new_attrs)

    @property
    @beartype
    def software_configuration(self) -> List[Any]:
        """
        List of software_configuration for this computation node

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")
        >>> my_software = cript.Software(name="LAMMPS", version="23Jun22", source="lammps.org")
        >>> my_software_configuration = cript.SoftwareConfiguration(software=my_software)
        >>> my_computation.software_configuration = [my_software_configuration]

        Returns
        -------
        List[SoftwareConfiguration]
            list of software configurations
        """
        return self._json_attrs.software_configuration.copy()

    @software_configuration.setter
    @beartype
    def software_configuration(self, new_software_configuration_list: List[Any]) -> None:
        """
        set the list of software_configuration for this computation node

        Parameters
        ----------
        new_software_configuration_list: List[software_configuration]
            new_software_configuration_list to replace the current one

        Returns
        -------
        None
        """
        new_attrs = replace(self._json_attrs, software_configuration=new_software_configuration_list)
        self._update_json_attrs_if_valid(new_attrs)

    @property
    @beartype
    def condition(self) -> List[Any]:
        """
        List of condition for this computation node

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")
        >>> my_condition = cript.Condition(key="atm", type="min", value=1)
        >>> my_computation.condition = [my_condition]

        Returns
        -------
        List[Condition]
            list of condition for the computation node
        """
        return self._json_attrs.condition.copy()

    @condition.setter
    @beartype
    def condition(self, new_condition_list: List[Any]) -> None:
        """
        set the list of condition for this node

        Parameters
        ----------
        new_condition_list: List[Condition]

        Returns
        -------
        None
        """
        new_attrs = replace(self._json_attrs, condition=new_condition_list)
        self._update_json_attrs_if_valid(new_attrs)

    @property
    @beartype
    def prerequisite_computation(self) -> Optional[Union["Computation", UIDProxy]]:
        """
        prerequisite computation

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")
        >>> my_prerequisite_computation = cript.Computation(
        ...     name="my prerequisite computation name", type="data_fit"
        ... )
        >>> my_computation.prerequisite_computation = my_prerequisite_computation

        Returns
        -------
        Computation
            prerequisite computation
        """
        return self._json_attrs.prerequisite_computation

    @prerequisite_computation.setter
    @beartype
    def prerequisite_computation(self, new_prerequisite_computation: Optional[Union["Computation", UIDProxy]]) -> None:
        """
        set new prerequisite_computation

        Parameters
        ----------
        new_prerequisite_computation: "Computation"

        Returns
        -------
        None
        """
        new_attrs = replace(self._json_attrs, prerequisite_computation=new_prerequisite_computation)
        self._update_json_attrs_if_valid(new_attrs)

    @property
    @beartype
    def citation(self) -> List[Any]:
        """
        List of citations

        Examples
        --------
        >>> import cript
        >>> my_computation = cript.Computation(name="my computation name", type="analysis")
        >>> my_reference = cript.Reference(type="journal_article", title="'Living' Polymers")
        >>> my_citation = cript.Citation(type="derived_from", reference=my_reference)
        >>> my_computation.citation = [my_citation]

        Returns
        -------
        List[Citation]
            list of citations for this computation node
        """
        return self._json_attrs.citation.copy()  # type: ignore

    @citation.setter
    @beartype
    def citation(self, new_citation_list: List[Any]) -> None:
        """
        set the List of citations

        Parameters
        ----------
        new_citation_list: List[Citation]
            list of citations for this computation node

        Returns
        -------
        None
        """
        new_attrs = replace(self._json_attrs, citation=new_citation_list)
        self._update_json_attrs_if_valid(new_attrs)

citation: List[Any] property writable

List of citations

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")
>>> my_reference = cript.Reference(type="journal_article", title="'Living' Polymers")
>>> my_citation = cript.Citation(type="derived_from", reference=my_reference)
>>> my_computation.citation = [my_citation]

Returns:

Type Description
List[Citation]

list of citations for this computation node

condition: List[Any] property writable

List of condition for this computation node

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")
>>> my_condition = cript.Condition(key="atm", type="min", value=1)
>>> my_computation.condition = [my_condition]

Returns:

Type Description
List[Condition]

list of condition for the computation node

input_data: List[Any] property writable

List of input data (data nodes) for this node

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")
>>> my_file = cript.File(
...     name="my file node name",
...     source="https://criptapp.org",
...     type="calibration",
...     extension=".csv",
...     data_dictionary="my file's data dictionary"
... )
>>> my_input_data = cript.Data(name="my data name", type="afm_amp", file=[my_file])
>>> my_computation.input_data = [my_input_data]

Returns:

Type Description
List[Data]

list of input data for this computation

output_data: List[Any] property writable

List of output data (data nodes)

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")
>>> my_file = cript.File(
...     name="my file node name",
...     source="https://criptapp.org",
...     type="calibration",
...     extension=".csv",
...     data_dictionary="my file's data dictionary"
... )
>>> my_output_data = cript.Data(name="my data name", type="afm_amp", file=[my_file])
>>> my_computation.output_data = [my_output_data]

Returns:

Type Description
List[Data]

list of output data for this computation

prerequisite_computation: Optional[Union[Computation, UIDProxy]] property writable

prerequisite computation

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")
>>> my_prerequisite_computation = cript.Computation(
...     name="my prerequisite computation name", type="data_fit"
... )
>>> my_computation.prerequisite_computation = my_prerequisite_computation

Returns:

Type Description
Computation

prerequisite computation

software_configuration: List[Any] property writable

List of software_configuration for this computation node

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")
>>> my_software = cript.Software(name="LAMMPS", version="23Jun22", source="lammps.org")
>>> my_software_configuration = cript.SoftwareConfiguration(software=my_software)
>>> my_computation.software_configuration = [my_software_configuration]

Returns:

Type Description
List[SoftwareConfiguration]

list of software configurations

type: str property writable

The type of computation

The computation type must come from CRIPT controlled vocabulary

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")
>>> my_computation.type = type="analysis"

Returns:

Type Description
str

type of computation

JsonAttributes dataclass

Bases: JsonAttributes

all computation nodes attributes

Source code in src/cript/nodes/primary_nodes/computation.py
@dataclass(frozen=True)
class JsonAttributes(PrimaryBaseNode.JsonAttributes):
    """
    all computation nodes attributes
    """

    type: str = ""
    # TODO add proper typing in future, using Any for now to avoid circular import error
    input_data: List[Union[Any, UIDProxy]] = field(default_factory=list)
    output_data: List[Union[Any, UIDProxy]] = field(default_factory=list)
    software_configuration: List[Union[Any, UIDProxy]] = field(default_factory=list)
    condition: List[Union[Any, UIDProxy]] = field(default_factory=list)
    prerequisite_computation: Optional[Union["Computation", UIDProxy]] = None
    citation: List[Union[Any, UIDProxy]] = field(default_factory=list)

__init__(name, type, input_data=None, output_data=None, software_configuration=None, condition=None, prerequisite_computation=None, citation=None, notes='', **kwargs)

create a computation node

Parameters:

Name Type Description Default
name str

name of computation node

required
type str

type of computation node. Computation type must come from CRIPT controlled vocabulary

required
input_data Optional[List[Union[Any, UIDProxy]]]

input data (data node)

None
output_data Optional[List[Union[Any, UIDProxy]]]

output data (data node)

None
software_configuration Optional[List[Union[Any, UIDProxy]]]

software configuration of computation node

None
condition Optional[List[Union[Any, UIDProxy]]]

condition for the computation node

None
prerequisite_computation Optional[Union[Computation, UIDProxy]]

prerequisite computation

None
citation Optional[List[Union[Any, UIDProxy]]]

list of citations

None
notes str

any notes for this computation node

''
**kwargs

for internal use of deserialize JSON from API to node

{}

Examples:

>>> import cript
>>> my_computation = cript.Computation(name="my computation name", type="analysis")

Returns:

Type Description
None

instantiate a computation node

Source code in src/cript/nodes/primary_nodes/computation.py
@beartype
def __init__(
    self,
    name: str,
    type: str,
    input_data: Optional[List[Union[Any, UIDProxy]]] = None,
    output_data: Optional[List[Union[Any, UIDProxy]]] = None,
    software_configuration: Optional[List[Union[Any, UIDProxy]]] = None,
    condition: Optional[List[Union[Any, UIDProxy]]] = None,
    prerequisite_computation: Optional[Union["Computation", UIDProxy]] = None,
    citation: Optional[List[Union[Any, UIDProxy]]] = None,
    notes: str = "",
    **kwargs
) -> None:
    """
    create a computation node

    Parameters
    ----------
    name: str
        name of computation node
    type: str
        type of computation node. Computation type must come from CRIPT controlled vocabulary
    input_data: List[Data] default=None
        input data (data node)
    output_data: List[Data] default=None
        output data (data node)
    software_configuration: List[SoftwareConfiguration] default=None
        software configuration of computation node
    condition: List[Condition] default=None
        condition for the computation node
    prerequisite_computation: Computation default=None
        prerequisite computation
    citation: List[Citation] default=None
        list of citations
    notes: str = ""
        any notes for this computation node
    **kwargs
        for internal use of deserialize JSON from API to node

    Examples
    --------
    >>> import cript
    >>> my_computation = cript.Computation(name="my computation name", type="analysis")

    Returns
    -------
    None
        instantiate a computation node

    """
    super().__init__(name=name, notes=notes, **kwargs)

    if input_data is None:
        input_data = []

    if output_data is None:
        output_data = []

    if software_configuration is None:
        software_configuration = []

    if condition is None:
        condition = []

    if citation is None:
        citation = []

    new_json_attrs = replace(
        self._json_attrs,
        type=type,
        input_data=input_data,
        output_data=output_data,
        software_configuration=software_configuration,
        condition=condition,
        prerequisite_computation=prerequisite_computation,
        citation=citation,
    )
    self._update_json_attrs_if_valid(new_json_attrs)