pwem.objects.data module
This modules contains basic hierarchy for EM data objects like: Image, SetOfImage and others
- class pwem.objects.data.Alphabet[source]
Bases:
object
class with a dictionary of all valid alphabets
- AMBIGOUS_DNA_ALPHABET = 2
- AMBIGOUS_RNA_ALPHABET = 5
- AMINOACIDS = 0
- DUMMY_ALPHABET = 8
- EXTENDED_DNA_ALPHABET = 4
- EXTENDED_PROTEIN_ALPHABET = 1
- NUCLEOTIDES = 1
- NUCLEOTIDES_ALPHABET = 7
- PROTEIN_ALPHABET = 0
- SEQ_TYPE = ['aminoacids', 'nucleotides']
- UNAMBIGOUS_DNA_ALPHABET = 3
- UNAMBIGOUS_RNA_ALPHABET = 6
- alphabets = {0: 'ACDEFGHIKLMNPQRSTVWY', 1: 'ACDEFGHIKLMNPQRSTVWYBJOUXZ', 2: 'GATCRYWSMKHBVDN', 3: 'GATC', 4: 'GATCBDSW', 5: 'GAUCRYWSMKHBVDN', 6: 'GAUC', 7: 'GAC', 8: 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}
- alphabetsLabels = {0: 'Protein', 1: 'Extended Protein', 2: 'Ambigous DNA', 3: 'Unambigous DNA', 4: 'Extended DNA', 5: 'Ambigous RNA', 6: 'Unambigous RNA'}
- class pwem.objects.data.AtomStruct(filename=None, pseudoatoms=False, **kwargs)[source]
Bases:
EMFile
Represents an PDB file.
- class pwem.objects.data.CTFModel(**kwargs)[source]
Bases:
EMObject
Represents a generic CTF model.
- DEFOCUS_RATIO_ERROR_VALUE = -1
- DEFOCUS_V_MINIMUM_VALUE = 0.1
- equalAttributes(other, ignore=[], verbose=False)[source]
Override default behaviour to compare two CTF objects, now ignoring the psdFile.
- setStandardDefocus(defocusU, defocusV, defocusAngle)[source]
Set defocus values following emx conventions. See _standardize function.
- setWrongDefocus()[source]
Set parameters if results parsing has failed. :param ctfModel: the model to be updated
- standardize()[source]
Modify defocusU, defocusV and defocusAngle to conform the EMX standard: defocusU > defocusV, 0 <= defocusAngle < 180 and the defocusAnges is between x-axis and defocusU. Also determine the defocusRatio(defocusU/defocusV). For more details see: http://i2pc.cnb.csic.es/emx/LoadDictionaryFormat.htm?type=Convention#ctf
- class pwem.objects.data.Class2D(**kwargs)[source]
Bases:
SetOfParticles
Represent a Class that groups Particles objects. Usually the representative of the class is another Particle (some kind of average particle from the particles assigned to the class)
- class pwem.objects.data.Class3D(**kwargs)[source]
Bases:
SetOfParticles
Represent a Class that groups Particles objects. Usually the representative of the class is a Volume reconstructed from the particles assigned to the class.
- class pwem.objects.data.ClassVol(**kwargs)[source]
Bases:
SetOfVolumes
Represent a Class that groups Volume objects. Usually the representative of the class is another Volume.
- class pwem.objects.data.Coordinate(**kwargs)[source]
Bases:
EMObject
This class holds the (x,y) position and other information associated with a coordinate
- class pwem.objects.data.EMFile(filename=None, **kwargs)[source]
Bases:
EMObject
Class to link usually to text files.
- class pwem.objects.data.EMObject(value=None, **kwargs)[source]
Bases:
Object
Base object for all EM classes
- class pwem.objects.data.EMSet(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]
-
- copyInfo(other)[source]
Define a dummy copyInfo function to be used for some generic operations on sets.
- copyItems(otherSet, updateItemCallback=None, itemDataIterator=None, copyDisabled=False, doClone=True, itemSelectedCallback=None)[source]
Copy items from another set, allowing to update items information based on another source of data, paired with each item.
- Params:
otherSet: input set from where the items will be copied. updateItemCallback: if not None, this will be called for each item
and each data row (if the itemDataIterator is not None). Apart from setting item values or new attributes, it is possible to set the special flag _appendItem to False, and then this item will not be added to the set.
- itemDataIterator: if not None, it must be an iterator that have one
data item for each item in the set. Usually the data item is a data row, coming from a table stored in text files (e.g STAR)
- copyDisabled: By default, disabled items are not copied from the other
set. If copyDisable=True, then the enabled property of the item will be ignored.
- doClone: By default, the new item that will be inserted is a “clone”
of the input item. By using doClone=False, the same input item will be passed to the callback and added to the set. This will avoid the clone operation and the related overhead.
- itemSelectedCallback: Optional, callback receiving an item and
returning true if it has to be copied
- classmethod create(outputPath, prefix=None, suffix=None, ext=None, **kwargs)[source]
Create an empty set from the current Set class. Params:
outputPath: where the output file will be written. prefix: prefix of the created file, if None, it will be deduced
from the ClassName.
- suffix: additional suffix that will be added to the prefix with a
“_” in between.
ext: extension of the output file, be default will use .sqlite
- createCopy(outputPath, prefix=None, suffix=None, ext=None, copyInfo=False, copyItems=False, itemSelectedCallback=None)[source]
Make a copy of the current set to another location (e.g file). Params:
outputPath: where the output file will be written.
- prefix: prefix of the created file, if None, it will be deduced
from the ClassName.
- suffix: additional suffix that will be added to the prefix with a
“_” in between.
- ext: extension of the output file, be default will use the same
extension of this set filename.
copyInfo: if True the copyInfo will be called after set creation.
copyItems: if True the copyItems function will be called.
- itemSelectedCallback: Optional, callback receiving an item and returning
true if it has to be copied
- class pwem.objects.data.FSC(**kwargs)[source]
Bases:
EMObject
Store a Fourier Shell Correlation
- class pwem.objects.data.FramesRange(firstFrame=1, lastFrame=0, firstFrameIndex=1)[source]
Bases:
CsvList
Store first and last frames in a movie. The last element will be the index in the stack of the first frame.
Frames numbering always refer to the initial movies imported into the project. Counting goes from 1 to the number of frames.
The underlying stack file could have all original frames or just a subset of them, so we need to keep which is the index of the first frame in the stack, again, the first image in a stack is 1
- class pwem.objects.data.Image(location=None, **kwargs)[source]
Bases:
EMObject
Represents an EM Image object
Params:
- Parameters
location – Could be a valid location: (index, filename)
or filename
- getDimensions()[source]
getDimensions is redundant here but not in setOfVolumes create it makes easier to create protocols for both images and sets of images
- getLocation()[source]
This function return the image index and filename. It will only differs from getFileName, when the image is contained in a stack and the index make sense.
- setLocation(*args)[source]
Set the image location, see getLocation. Params:
- First argument can be:
a tuple with (index, filename)
a index, this implies a second argument with filename
a filename, this implies index=NO_INDEX
- class pwem.objects.data.ImageDim(x=None, y=None, z=None)[source]
Bases:
CsvList
Just a wrapper to a CsvList to store image dimensions as X, Y and Z.
- class pwem.objects.data.Mask(location=None, **kwargs)[source]
Bases:
Particle
Represent a mask.
Params:
- Parameters
location – Could be a valid location: (index, filename)
or filename
- class pwem.objects.data.Matrix(**kwargs)[source]
Bases:
Scalar
- class pwem.objects.data.Micrograph(location=None, **kwargs)[source]
Bases:
Image
Represents an EM Micrograph object
Params:
- Parameters
location – Could be a valid location: (index, filename)
or filename
- class pwem.objects.data.Movie(location=None, **kwargs)[source]
Bases:
Micrograph
Represent a set of frames of micrographs.
Params:
- Parameters
location – Could be a valid location: (index, filename)
or filename
- getDim()[source]
Return image dimensions as tuple: (Xdim, Ydim, Zdim) Consider compressed Movie files
- class pwem.objects.data.MovieAlignment(first=-1, last=-1, **kwargs)[source]
Bases:
EMObject
Store the alignment between the different Movie frames. Also store the first and last frames used for alignment.
- getRange()[source]
Return the first and last frames used for alignment. The first frame in a movie stack is numbered 1 and the maximum value for the last one is N, where N is the total number of frames.
- class pwem.objects.data.MovieParticle(**kwargs)[source]
Bases:
Particle
Params:
- Parameters
location – Could be a valid location: (index, filename)
or filename
- class pwem.objects.data.NormalMode(**kwargs)[source]
Bases:
EMObject
Store normal mode information.
- class pwem.objects.data.Particle(location=None, **kwargs)[source]
Bases:
Image
Represents an EM Particle object
Params:
- Parameters
location – Could be a valid location: (index, filename)
or filename
- class pwem.objects.data.PdbFile(filename=None, pseudoatoms=False, **kwargs)[source]
Bases:
AtomStruct
- class pwem.objects.data.Sequence(name=None, sequence=None, alphabet=None, isAminoacids=True, id=None, description=None, **kwargs)[source]
Bases:
EMObject
Class containing a sequence of aminoacids/nucleotides Attribute names follow the biopython default ones
param: name: name of the sequence param: sequence: string with the sequence param: alphabet: integer with the alphabet to be used param: isAminoacids: boolean indicating if the sequence is an aminoacid sequence param: id: string with the sequence id param: description: string with the sequence description
- appendToFile(seqFileName, doClean=True)[source]
Exports the sequence to the specified file. If it already exists, the sequence is appended to the ones in the file
- class pwem.objects.data.SetOfAtomStructs(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]
Bases:
EMSet
Set containing PDB items.
- EXPOSE_ITEMS = True
- ITEM_TYPE
alias of
AtomStruct
- class pwem.objects.data.SetOfAverages(**kwargs)[source]
Bases:
SetOfParticles
Represents a set of Averages. It is a SetOfParticles but it is useful to differentiate outputs.
- class pwem.objects.data.SetOfCTF(**kwargs)[source]
Bases:
EMSet
Contains a set of CTF models estimated for a set of images.
- class pwem.objects.data.SetOfClasses(**kwargs)[source]
Bases:
EMSet
Store results from a classification.
- ITEM_TYPE = None
- REP_TYPE = None
- appendFromClasses(classesSet, filterClassFunc=None, updateClassCallback=None)[source]
Iterate over the classes and the elements inside each class and append classes and items that are enabled.
- Parameters
classesSet – Set of classes to copy items from
filterClassFunc – Extra callback to exclude classes. Receives a class item, should return a boolean
- classifyItems(updateItemCallback=None, updateClassCallback=None, itemDataIterator=None, classifyDisabled=False, iterParams=None, doClone=True, raiseOnNextFailure=True)[source]
Classify items from the self.getImages() and add the needed classes. This function iterates over each item in the images and call the updateItemCallback to register the information coming from the iterator in itemDataIterator. The callback function should set the classId of the image that will be used to classify it. It is also possible to pass a callback to update the class properties.
- Parameters
updateItemCallback – callback to be invoked on each item’s loop (e.g.: 2d image in a 2d classification)
updateClassCallback – callback to be invoked when a item.getClassId() changes
itemDataIterator – an iterator (usually on metadata files, star, xmd,…) that will be called on each loop.
usually has that same lines as items and iteration is kept in sync :param classifyDisabled: classify disabled items. By default, they are skipped. :param iterParams: Parameters for self.getImages() to leave oot images/filter :param doClone: Make a clone of the item (defaults to true) :param raiseOnNextFailure: A boolean flag indicating whether to raise an exception if there is a failure while
attempting to retrieve the next element from itemDataIterator. If set to True(default), an exception will be raised; if set to False, the loop will be terminated in case of failure. Pass False when itemDataIterator is a subset of the inputSet. Important: Pass the right iterParams to make sure the iteration on the inputSet
matches the iteration of the itemDataIterator
- getImagesPointer()[source]
” Return the pointer to the SetOfImages used to create the SetOfClasses.
- class pwem.objects.data.SetOfClasses2D(**kwargs)[source]
Bases:
SetOfClasses
Store results from a 2D classification of Particles.
- class pwem.objects.data.SetOfClasses3D(**kwargs)[source]
Bases:
SetOfClasses
Store results from a 3D classification of Particles.
- class pwem.objects.data.SetOfClassesVol(**kwargs)[source]
Bases:
SetOfClasses3D
Store results from a classification of Volumes.
- class pwem.objects.data.SetOfCoordinates(**kwargs)[source]
Bases:
EMSet
Encapsulate the logic of a set of particles coordinates. Each coordinate has a (x,y) position and is related to a Micrograph The SetOfCoordinates can also have information about TiltPairs.
- ITEM_TYPE
alias of
Coordinate
- copyInfo(other)[source]
Copy basic information (boxsize) from other set of coordinates to current one
- getMicrographs(asPointer=False)[source]
Returns the SetOfMicrographs associated with this SetOfCoordinates
- iterCoordinates(micrograph=None)[source]
Iterate over the coordinates associated with a micrograph. If micrograph=None, the iteration is performed over the whole set of coordinates.
- iterMicrographCoordinates(micrograph)[source]
Iterates over the set of coordinates belonging to that micrograph.
- class pwem.objects.data.SetOfData(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]
Bases:
EMSet
Represents lines of data elements
- class pwem.objects.data.SetOfDefocusGroup(**kwargs)[source]
Bases:
EMSet
Contains a set of DefocusGroup. if min/max/avg exists the corresponding flag must be set to true.
- ITEM_TYPE
alias of
DefocusGroup
- class pwem.objects.data.SetOfDefocusGroups(inputSet, groupRange=1000, groupMinSize=1, **kwargs)[source]
Bases:
object
Store a set of several defocus groups.
Create necessary defocus groups. Params:
inputSet: input particles or micrographs with CTF information. groupRange: maximum defocus range allowed in one group. groupMinSize: impose a minimum number of particles per group.
- class pwem.objects.data.SetOfFSCs(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]
Bases:
EMSet
Represents a set of FSCs
- class pwem.objects.data.SetOfImages(**kwargs)[source]
Bases:
EMSet
Represents a set of Images
- appendFromClasses(classesSet, filterClassFunc=None)[source]
Iterate over the classes and the element inside each class and append to the set all that are enabled.
- appendFromImages(imagesSet, itemSelectedCallback=None)[source]
Iterate over the images and append every image that is enabled.
- Parameters
imagesSet – Set to go copy items from
itemSelectedCallback – Optional, callback receiving an item and returning true if it has to be added
- copyInfo(other)[source]
Copy basic information (sampling rate and ctf) from other set of images to current one
- iterItems(orderBy='id', direction='ASC', where='1', limit=None, iterate=True)[source]
Redefine iteration to set the acquisition to images.
- class pwem.objects.data.SetOfMicrographs(**kwargs)[source]
Bases:
SetOfMicrographsBase
Represents a set of Micrographs
- ITEM_TYPE
alias of
Micrograph
- class pwem.objects.data.SetOfMicrographsBase(**kwargs)[source]
Bases:
SetOfImages
Create a base class for both Micrographs and Movies, but avoid to select Movies when Micrographs are required.
- class pwem.objects.data.SetOfMovieParticles(**kwargs)[source]
Bases:
SetOfParticles
This is just to distinguish the special case when the particles have been extracted from a set of movies.
- ITEM_TYPE
alias of
MovieParticle
- class pwem.objects.data.SetOfMovies(**kwargs)[source]
Bases:
SetOfMicrographsBase
Represents a set of Movies.
- class pwem.objects.data.SetOfNormalModes(**kwargs)[source]
Bases:
EMSet
Set containing NormalMode items.
- ITEM_TYPE
alias of
NormalMode
- class pwem.objects.data.SetOfPDBs[source]
Bases:
SetOfAtomStructs
Set containing PDB items.
- class pwem.objects.data.SetOfParticles(**kwargs)[source]
Bases:
SetOfImages
Represents a set of Particles. The purpose of this class is to separate the concepts of Micrographs and Particles, even if both are considered Images
- copyInfo(other)[source]
Copy basic information (voltage, spherical aberration and sampling rate) from other set of micrographs to current one.
- class pwem.objects.data.SetOfPrincipalComponents(**kwargs)[source]
Bases:
SetOfNormalModes
Set of Principal Components is a SetOfNormalModes with a new name
- class pwem.objects.data.SetOfSequences(**kwargs)[source]
Bases:
EMSet
Set containing Sequence items.
- class pwem.objects.data.SetOfStats(filename=None, prefix='', mapperClass=None, classesDict=None, **kwargs)[source]
Bases:
SetOfData
Replaces by SetOfData. Here for backwards compatibility.
- class pwem.objects.data.SetOfVolumes(**kwargs)[source]
Bases:
SetOfImages
Represents a set of Volumes
- EXPOSE_ITEMS = True
- class pwem.objects.data.Transform(matrix=None, **kwargs)[source]
Bases:
EMObject
This class will contain a transformation matrix that can be applied to 2D/3D objects like images and volumes. It should contain information about euler angles, translation(or shift) and mirroring. Shifts are stored in pixels as treated in extract coordinates, or assign angles,…
- ROT_X_90_CLOCKWISE = 'rotX90c'
- ROT_X_90_COUNTERCLOCKWISE = 'rotX90cc'
- ROT_Y_90_CLOCKWISE = 'rotY90c'
- ROT_Y_90_COUNTERCLOCKWISE = 'rotY90cc'
- ROT_Z_90_CLOCKWISE = 'rotZ90c'
- ROT_Z_90_COUNTERCLOCKWISE = 'rotZ90cc'
- class pwem.objects.data.Volume(location=None, **kwargs)[source]
Bases:
Image
Represents an EM Volume object
Params:
- Parameters
location – Could be a valid location: (index, filename)
or filename