sfftkrw¶
This module defines a user-friendly adapter API (compared to the one generated by generateDS). It is designed to fulfill several requirements:
- allow multiple versions of
generateDS
APIs to exist for the same adapter; - implement more convenient ways of working with the classes of the API;
- easily integrate new EMDB-SFF entities into the API;
- decouple the file format from the data model: most classes in this adapter implement methods to handle conversion to non-XML formats (XML is the only format that generateDS writes to)
Here is an example of how the SFFSegmentation
class is defined using these classes (details omitted for brevity):
from .base import SFFType, SFFAttribute
class SFFSegmentation(SFFType):
"""Adapter class to make using the output of ``generateDS`` easier to use"""
gds_type = sff.segmentation
gds_tag_name = "segmentation"
repr_string = "SFFSegmentation(...)"
# attributes
name = SFFAttribute('name', required=True)
version = SFFAttribute('version')
software_list = SFFAttribute('software_list', sff_type=SFFSoftwareList)
primary_descriptor = SFFAttribute('primary_descriptor')
transform_list = SFFAttribute('transform_list', sff_type=SFFTransformList)
bounding_box = SFFAttribute('bounding_box', sff_type=SFFBoundingBox)
global_external_references = SFFAttribute('global_external_references', sff_type=SFFGlobalExternalReferences)
segment_list = SFFAttribute('segment_list', sff_type=SFFSegmentList)
lattice_list = SFFAttribute('lattice_list', sff_type=SFFLatticeList)
details = SFFAttribute('details')
In the above example, the SFFSegmentation
class inherits from SFFType
; SFFType
uses the first three attributes (gds_type
, gds_tag_name
and repr_string
) to configure the user class
SFFSegmentation
. The API user can now exploit SFFSegmentation
without any need to know the
underlying implementation while benefiting from the aforementioned facilities:
from sfftkrw import SFFSegmentation
# to create a new empty EMDB-SFF segmentation object
# provide the only required attribute
seg = SFFSegmentation(name='my name')
seg.to_file('file.sff') # export
# to read an XML-, HDF5- or JSON-formatted file, respectively
seg = SFFSegmentation('file.sff')
seg = SFFSegmentation('file.hff')
seg = SFFSegmentation('file.json')
The attributes (name
, version
, etc.) are all instances of SFFAttribute
, which takes the name (first
positional argument) and an optional keyword argument sff_type
denoting the class of the attribute. In the above
example, the software_list
attribute will be of type SFFSoftwareList
.
To learn more about the core classes please refer to sfftkrw.schema.base.
SFFSegmentation
class¶
-
class
sfftkrw.
SFFSegmentation
(name=None, software_list=None, primary_descriptor=None, details=None, transform_list=None, bounding_box=None, segment_list=None, lattice_list=None)¶ Bases:
sfftkrw.schema.base.SFFType
Adapter class to make using the output of
generateDS
easier to use-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
bounding_box
¶ the bounding box in which the segmentation sits; a
sfftkrw.schema.adapter.SFFBoundingBox
object
-
clear_annotation
(from_id)¶ Clear all annotations from the segment with ID specified
Parameters: from_id – segment ID Returns:
-
copy_annotation
(from_id, to_id)¶ Copy annotation across segments
Parameters: - from_id (int/list) – segment ID to get notes from; use -1 for for global notes
- to_id (int/list) – segment ID to copy notes to; use -1 for global notes
-
details
¶ any other details about this segmentation (free text)
-
export
(fn, args=None, *_args, **_kwargs)¶ Export to a file on disc
Parameters: fn (str or io.TextIOWrapper or io.RawIOBase or io.BufferedIOBase or file) – filename to export to; the output format is determined by the extension: Return int status: exit code from os
library.sff
- XML.hff
- HDF5.json
- JSON
-
classmethod
from_file
(fn, args=None)¶ Instantiate an
SFFSegmentations
object from a file nameThe file suffix determines how the data is extracted.
Parameters: fn (str) – name of a file hosting an EMDB-SFF-structured segmentation Return seg: the corresponding SFFSegmentation
objectRtype seg: SFFSegmentation
-
classmethod
from_gds_type
(inst=None)¶ Create an
SFFType
subclass directly from a gds_type objectNotice that we ignore do not pass *args, **kwargs as we assume the inst is complete.
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
gds_type
¶
-
global_external_references
¶ a list of external references that apply to the whole segmentation (global); a
sfftkrw.schema.adapter.SFFGlobalexternal_references
object
-
lattice_list
¶ the list of lattices (if any) containing 3D volumes referred to; a
sfftkrw.schema.adapter.SFFLatticeList
object
-
merge_annotation
(other_seg, include_colour=False)¶ Merge the annotation from another sff_seg to this one
Parameters: - other_seg (
sfftkrw.SFFSegmentation
) – segmentation to get annotations from - include_colour (bool) – copy the colours from the source (useful if you want control over the colours)
- other_seg (
-
name
¶ the name of this segmentation
-
primary_descriptor
¶ the main type of representation used for this segmentation; can be one of ‘mesh_list’, ‘shape_primitive_list’ or ‘threeDVolume’
-
segment_list
¶ the list of annotated segments; a
sfftkrw.schema.adapter.SFFSegmentList
object
-
software_list
¶ the list of software tools used to crate this segmentation a
sfftkrw.schema.adapter.SFFSoftwareList
object
-
to_file
(*args, **kwargs)¶ Alias for
export()
method. Passes all args and kwargs ontoSFFSegmentation.export()
-
transform_list
¶ a list of transforms; a
sfftkrw.schema.adapter.SFFTransformList
object
-
version
¶ EMDB-SFF version
-
SFFSoftwareList
class¶
-
class
sfftkrw.
SFFSoftwareList
¶ Bases:
sfftkrw.schema.base.SFFListType
List of SFFSoftware objects
-
as_hff
(parent_group, name='software_list', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='software_list', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
SFFSoftware
class¶
-
class
sfftkrw.
SFFSoftware
(name=None, version=None, processing_details=None)¶ Bases:
sfftkrw.schema.base.SFFIndexType
Class definition for specifying software used to create this segmentation
-
name
¶ The name of the software used
-
version
¶ The version string
-
processing_details
¶ Details of how the segmentation was produced
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
id
¶ the software ID
-
name
the software/programmeu’s name
-
processing_details
a description of how the data was processed to produce the segmentation
-
version
the version used
-
SFFTransformList
class¶
-
class
sfftkrw.
SFFTransformList
¶ Bases:
sfftkrw.schema.base.SFFListType
Container for transforms
-
as_hff
(parent_group, name='transform_list', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='transform_list', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
gds_type
¶
-
SFFTransformationMatrix
class¶
-
class
sfftkrw.
SFFTransformationMatrix
(id=None, rows=None, cols=None, data=None)¶ Bases:
sfftkrw.schema.base.SFFIndexType
Transformation matrix transform
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
cols
¶ the number of columns in this matrix
-
data
¶ a string sequence by row of the data in this matrix
-
classmethod
from_array
(ndarray, **kwargs)¶ Construct an SFFTransformationMatrix object from a numpy numpy.ndarray array
Parameters: ndarray ( numpy.ndarray
) – a numpy arrayReturns: a SFFTransformationMatrix
object
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
gds_type
¶ alias of
sfftkrw.schema.v0_8_0_dev1.transformation_matrix_type
-
id
¶ an ID for this transform
-
rows
¶ the number of rows in this matrix
-
static
stringify
(array)¶ Convert a
numpy.ndarray
to a space-separated list of numbers
-
SFFBoundingBox
class¶
-
class
sfftkrw.
SFFBoundingBox
(xmin=0.0, xmax=None, ymin=0.0, ymax=None, zmin=0.0, zmax=None)¶ Bases:
sfftkrw.schema.base.SFFType
Dimensions of bounding box
-
as_hff
(parent_group, name='bounding_box', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='bounding_box', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
xmax
¶ maximum x co-ordinate value
-
xmin
¶ minimum x co-ordinate value
-
ymax
¶ maximum y co-ordinate value
-
ymin
¶ minimum y co-ordinate value
-
zmax
¶ maximum z co-ordinate value
-
zmin
¶ minimum z co-ordinate value
-
SFFGlobalExternalReferenceList
class¶
-
class
sfftkrw.
SFFGlobalExternalReferenceList
¶ Bases:
sfftkrw.schema.base.SFFListType
Container for global external references
-
as_hff
(parent_group, name='global_external_references', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='global_external_references', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
SFFExternalReferenceList
class¶
-
class
sfftkrw.
SFFExternalReferenceList
¶ Bases:
sfftkrw.schema.base.SFFListType
Container for external references
-
as_hff
(parent_group, name='external_references', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='external_references', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
SFFExternalReference
class¶
-
class
sfftkrw.
SFFExternalReference
(id=None, resource=None, url=None, accession=None, label=None, description=None)¶ Bases:
sfftkrw.schema.base.SFFIndexType
-
accession
¶ the accession for this external reference
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
description
¶ a long description of this external reference
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
id
¶ this external reference’s ID
-
label
¶ a short description of this external reference
-
resource
¶ the ontology/archive name
-
url
¶ a URL/IRI where data for this external reference may be obtained
-
SFFSegmentList
class¶
-
class
sfftkrw.
SFFSegmentList
¶ Bases:
sfftkrw.schema.base.SFFListType
Container for segments
-
as_hff
(parent_group, name='segment_list', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='segment_list', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
SFFSegment
class¶
-
class
sfftkrw.
SFFSegment
(id=None, biological_annotation=None, colour=None, mesh_list=None, three_d_volume=None, shape_primitive_list=None)¶ Bases:
sfftkrw.schema.base.SFFIndexType
Class that encapsulates segment data
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ Format this segment as JSON
-
biological_annotation
¶ the biological annotation for this segment; described using a
sfftkrw.schema.adapter.SFFBiologicalAnnotation
object
-
colour
¶ this segments colour; described using a
sfftkrw.schema.adapter.SFFRGBA
object
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
gds_type
¶
-
id
¶ the ID for this segment; segment IDs begin at 1 with the value of 0 implying the segmentation i.e. all segments are children of the root segment (the segmentation)
-
mesh_list
¶ the list of mesh_list (if any) that describe this segment; a
sfftkrw.schema.adapter.SFFMeshList
object
-
parent_id
¶ the ID for the segment that contains this segment; defaults to 0 (the whole segmentation)
-
shape_primitive_list
¶ the list of shape primitives that describe this segment; a
sfftkrw.schema.adapter.SFFShapePrimitiveList
object
-
three_d_volume
¶ the 3D volume (if any) that describes this segment; a
sfftkrw.schema.adapter.SFFThreeDVolume
object
-
SFFBiologicalAnnotation
class¶
-
class
sfftkrw.
SFFBiologicalAnnotation
(name=None, description=None, external_references=None)¶ Bases:
sfftkrw.schema.base.SFFType
Biological annotation
-
as_hff
(parent_group, name='biological_annotation', args=None)¶ Return the data of this object as an HDF5 group in the given parent group
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
description
¶ a brief description for this segment
-
external_references
¶ the set of external references
-
classmethod
from_hff
(parent_group, name='biological_annotation', args=None)¶ Return an SFFType object given an HDF5 object
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
name
¶ the name of this segment
-
number_of_instances
¶ the number of instances of this segment
-
SFFRGBA
class¶
-
class
sfftkrw.
SFFRGBA
(red=None, green=None, blue=None, alpha=1.0, random_colour=False)¶ Bases:
sfftkrw.schema.base.SFFType
Colours
-
alpha
¶ alpha (opacity) channel
-
as_hff
(parent_group, name='colour', args=None)¶ Return the data of this object as an HDF5 group in the given parent group
-
as_json
(args=None)¶ Export as JSON
-
blue
¶ blue channel
-
classmethod
from_hff
(parent_group, name='colour', args=None)¶ Return an SFFType object given an HDF5 object
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
green
¶ green channel
-
red
¶ red channel
-
SFFEncodedSequence
class¶
-
class
sfftkrw.
SFFEncodedSequence
(*args, **kwargs)¶ Bases:
sfftkrw.schema.base.SFFType
Abstract base class for SFFVertices, SFFNormals and SFFTriangles
-
static
_decode
(bin64, mode=None, endianness=None, **kwargs)¶ Decode a base64-encoded byte sequence to a numpy array
Parameters: Returns: a
numpy.ndarray
objectReturn type:
-
static
_encode
(array, mode=None, endianness=None, **kwargs)¶ Encode a
numpy.ndarray
as a base64-encoded byte sequenceParameters: - array (
numpy.ndarray
) – anumpy.ndarray
array - mode (str) – the data type
- endianness (str) – the byte orientation
Return str: the corresponding encoded sequence
- array (
-
classmethod
from_array
(data, mode=None, endianness=None)¶ Create a
SFFVertices
object from a numpy array inferring size and assuming certain defaultsParameters: - data (
numpy.ndarray
) – the data as anumpy.ndarray
object - mode (bytes or str or unicode) – the size of each voxel; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64``float32, float64
- endianness (bytes or str or unicode) – byte ordering:
little
(default) orbig
Returns: a
SFFVertices
objectReturn type: - data (
-
classmethod
from_bytes
(byte_seq, num_items, mode=None, endianness=None)¶ Create a
SFFVertices
object using a bytes objectParameters: - byte_seq (bytes or unicode) – the data as a base64-encoded sequence; can be bytes or unicode
- num_vertices (int) – the number of vertices contained (for validation)
- mode (bytes or str or unicode) – the size of each voxel; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64``float32, float64
- endianness (bytes or str or unicode) – byte ordering:
little
(default) orbig
Returns: a
SFFVertices
objectReturn type:
-
static
SFFVertices
class¶
-
class
sfftkrw.
SFFVertices
(num_vertices=None, mode="float32", endianness="little", data=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFEncodedSequence
Vertices: neither a list nor an index type but is encoded
Suggests the need for an SFFCodedType which has encoded data with _encode and _decode services/methods.
-
as_hff
(parent_group, name='vertices', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
data
¶ base64-encoded packed binary data
-
endianness
¶ binary packing endianness [default: ‘little’]
-
classmethod
from_hff
(parent_group, name='vertices', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
gds_type
¶
-
mode
¶ data type; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64 [default: ‘float32’]
-
num_vertices
¶ the number of vertices contained
-
SFFNormals
class¶
-
class
sfftkrw.
SFFNormals
(num_normals=None, mode="float32", endianness="little", data=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFEncodedSequence
Normals
-
as_hff
(parent_group, name='normals', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
data
¶ base64-encoded packed binary data
-
endianness
¶ binary packing endianness [default: ‘little’]
-
classmethod
from_hff
(parent_group, name='normals', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
gds_type
¶
-
mode
¶ data type; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64 [default: ‘float32’]
-
num_normals
¶ the number of normals contained
-
SFFTriangles
class¶
-
class
sfftkrw.
SFFTriangles
(num_triangles=None, mode="uint32", endianness="little", data=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFEncodedSequence
Triangles
-
as_hff
(parent_group, name='triangles', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
data
¶ base64-encoded packed binary data
-
endianness
¶ binary packing endianness [default: ‘little’]
-
classmethod
from_hff
(parent_group, name='triangles', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
gds_type
¶
-
mode
¶ data type; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64 [default: ‘float32’]
-
num_triangles
¶ the number of triangles contained
-
SFFMeshList
class¶
-
class
sfftkrw.
SFFMeshList
¶ Bases:
sfftkrw.schema.base.SFFListType
Mesh list representation
-
as_hff
(parent_group, name='mesh_list', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='mesh_list', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
SFFMesh
class¶
-
class
sfftkrw.
SFFMesh
(id=None, vertices=None, normals=None, triangles=None, transform_id=None)¶ Bases:
sfftkrw.schema.base.SFFIndexType
Single mesh
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
id
¶ the mesh ID
-
normals
¶ a list of normals which correspond to vertices
-
transform_id
¶ a transform applied to the mesh
-
triangles
¶ a list of triangles; each triangle is represented by a trio of vertex indices
-
vertices
¶ a list of vertices
-
SFFThreeDVolume
class¶
-
class
sfftkrw.
SFFThreeDVolume
(lattice_id=None, value=None, transform_id=None)¶ Bases:
sfftkrw.schema.base.SFFType
Class representing segments described using a 3D volume
-
as_hff
(parent_group, name='three_d_volume', args=None)¶ Return an SFFType object given an HDF5 object
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='three_d_volume', args=None)¶ Return an SFFType object given an HDF5 object
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
lattice_id
¶ the ID of the lattice that has the data for this 3D volume
-
transform_id
¶ a transform applied to this 3D volume [optional]
-
value
¶ the voxel values associated with this 3D volume
-
SFFLatticeList
class¶
-
class
sfftkrw.
SFFLatticeList
¶ Bases:
sfftkrw.schema.base.SFFListType
A container for lattice objects
-
as_hff
(parent_group, name='lattice_list', args=None)¶ Return the data of this object as an HDF5 group in the given parent group
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='lattice_list', args=None)¶ Return an SFFType object given an HDF5 object
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
SFFLattice
class¶
-
class
sfftkrw.
SFFLattice
(id=None, mode=None, endianness=None, size=None, start=None, data=None)¶ Bases:
sfftkrw.schema.base.SFFIndexType
Class representing 3D
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
data
¶ data provided by a
numpy.ndarray
, byte-sequence or unicode string; the dimensions should correspond with those specified in the ‘size’ attribute
-
data_array
¶ The data as a
numpy.ndarray
-
endianness
¶ endianness; either ‘little’ (default) or ‘big’
-
classmethod
from_array
(data, size=None, mode='uint32', endianness='little', start=SFFVolumeIndex(rows=0, cols=0, sections=0))¶ Create a
SFFLattice
object from a numpy array inferring size and assuming certain defaultsParameters: - data (
numpy.ndarray
) – the data as anumpy.ndarray
object - size (
SFFVolumeStructure
) – the size of the lattice as aSFFVolumeStructure
object - start (
SFFVolumeIndex
) – the values of the corner voxel - mode (bytes or str or unicode) – the size of each voxel; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64``float32, float64
- endianness (bytes or str or unicode) – byte ordering:
little
(default) orbig
Returns: a
SFFLattice
objectReturn type: - data (
-
classmethod
from_bytes
(byte_seq, size, mode='uint32', endianness='little', start=SFFVolumeIndex(rows=0, cols=0, sections=0))¶ Create a
SFFLattice
object using a bytes objectParameters: - byte_seq (bytes or unicode) – the data as a base64-encoded, zipped sequence; can be bytes or unicode
- size (
SFFVolumeStructure
) – the size of the lattice as aSFFVolumeStructure
object - start (
SFFVolumeIndex
) – the values of the corner voxel - mode (bytes or str or unicode) – the size of each voxel; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64``float32, float64
- endianness (bytes or str or unicode) – byte ordering:
little
(default) orbig
Returns: a
SFFLattice
objectReturn type:
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
id
¶ the ID for this lattice (referenced by 3D volumes)
-
mode
¶ type of data for each voxel; valid values are: int8, uint8, int16, uint16, int32, uint32, int64, uint64, float32, float64
-
size
¶ size of the lattice described using a
sfftkrw.schema.adapter.SFFVolumeStructure
object
-
start
¶ starting index of the lattices described using a:py:class:sfftkrw.schema.adapter.SFFVolumeIndex object
-
SFFVolumeStructure
class¶
-
class
sfftkrw.
SFFVolumeStructure
(rows=None, cols=None, sections=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFVolume
-
as_hff
(parent_group, name='size', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
classmethod
from_hff
(parent_group, name='size', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
voxel_count
¶ The number of voxels in this volume
-
SFFVolumeIndex
class¶
-
class
sfftkrw.
SFFVolumeIndex
(rows=None, cols=None, sections=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFVolume
Class representing volume indices
-
as_hff
(parent_group, name='start', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
classmethod
from_hff
(parent_group, name='start', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
SFFShapePrimitiveList
class¶
-
class
sfftkrw.
SFFShapePrimitiveList
¶ Bases:
sfftkrw.schema.base.SFFListType
Container for shapes
-
as_hff
(parent_group, name='shape_primitive_list', args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name='shape_primitive_list', args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
num_cones
¶ The number of cones in this container
-
num_cuboids
¶ The number of cuboids in this container
-
num_cylinders
¶ The number of cylinders in this container
-
num_ellipsoids
¶ The number of ellipsoids in this container
-
SFFShape
class¶
-
class
sfftkrw.
SFFShape
(id=None, transform_id=None, attribute=None)¶ Bases:
sfftkrw.schema.base.SFFIndexType
Base shape class
-
attribute
¶ extra attribute information e.g. ‘FOM’
-
id
¶ the ID of this shape
-
transform_id
¶ the transform applied to this shape to position it in the space
-
classmethod
update_counter
(value)¶ Update the index for all subclasses sequentially for sibling classes
This method works alongside the index_in_super class attribute.
The superclass must specify this method to ensure correct sequencing of shared indices.
-
SFFCone
class¶
-
class
sfftkrw.
SFFCone
(id=None, height=None, bottom_radius=None, transform_id=None, attribute=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFShape
Cone shape class
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
bottom_radius
¶ cone bottom radius
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
height
¶ cone height
-
SFFCuboid
class¶
-
class
sfftkrw.
SFFCuboid
(id=None, x=None, y=None, z=None, transform_id=None, attribute=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFShape
Cuboid shape class
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
gds_type
¶ alias of
sfftkrw.schema.v0_8_0_dev1.cuboid
-
x
¶ length in x
-
y
¶ length in y
-
z
¶ length in z
-
SFFCylinder
class¶
-
class
sfftkrw.
SFFCylinder
(id=None, height=None, diameter=None, transform_id=None, attribute=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFShape
Cylinder shape class
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
diameter
¶ cylinder diameter
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
height
¶ cylinder height
-
SFFEllipsoid
class¶
-
class
sfftkrw.
SFFEllipsoid
(id=None, x=None, y=None, z=None, transform_id=None, attribute=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFShape
Ellipsoid shape class
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
gds_type
¶ alias of
sfftkrw.schema.v0_8_0_dev1.ellipsoid
-
x
¶ length in x
-
y
¶ length in y
-
z
¶ length in z
-
SFFSubtomogramAverage
class¶
-
class
sfftkrw.
SFFSubtomogramAverage
(id=None, lattice_id, value=None, transform_id=None)¶ Bases:
sfftkrw.schema.adapter_v0_8_0_dev1.SFFShape
Subtomogram average class
-
as_hff
(parent_group, name=None, args=None)¶ Returns the current object as a group in an HDF5 file with the given name
For instances which are subclasses of
base.SFFIndexType
name will be a string version of the index (id). If id is None then we will generate a unique one so as to write the object to file. Therefore, the process of writing to HDF5 could end up looking slightly different from the original if the original had missing indexes for some objects.Parameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the populated parent group
Return type: Group
- parent_group (
-
as_json
(args=None)¶ For all contained classes this method returns a dictionary which will be serialised into JSON. Only at the top level (SFFSegmentation) will the final serialisation be done.
Parameters: args ( argparse.Namespace
) – command line argumentsReturns: a set of nested dictionaries Return type: dict
-
classmethod
from_hff
(parent_group, name=None, args=None)¶ Convert HDF5 objects into EMDB-SFF objects It should either return a valid object or raise an
SFFValueError
due to failed validationParameters: - parent_group (
Group
) – an HDF5 Group that will contain the objects in this object - args (
argparse.Namespace
) – command line arguments - name (str or None) – the name to be given to this object in the object hierarchy (default: None)
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass- parent_group (
-
classmethod
from_json
(data, args=None)¶ Deserialise the given json object into an EMDB-SFF object
Parameters: - data (dict) – the data to be converted into SFF* objects
- args (
argparse.Namespace
) – command line arguments
Returns: the corresponding SFF* object
Return type: base.SFFType
subclass
-
lattice_id
¶ the ID of the lattice holding the subtomogram average
-
transform_id
¶ the transform applied to this shape to position it in the space
-
value
¶ the value at which the contour is defined
-