StopgapMotl#

class cryocat.core.cryomotl.StopgapMotl(input_motl=None)#

Bases: Motl

columns = ['motl_idx', 'tomo_num', 'object', 'subtomo_num', 'halfset', 'orig_x', 'orig_y', 'orig_z', 'score', 'x_shift', 'y_shift', 'z_shift', 'phi', 'psi', 'the', 'class']#
convert_to_motl(stopgap_df, keep_halfsets=False)#

Converts a stopgap DataFrame to a motl DataFrame and stores it in self.df.

Parameters:
stopgap_dfpandas.DataFrame

The Stopgap DataFrame to be converted.

Returns:
None

Warning

If the particles are split into A and B halfsets the subtomo_id will be assigned based on them and will not correspond to the “subtomo_num” anymore. The “subtomo_num” information will be store in “geom3” column instead. New extraction of subtomograms will be neceesary in such a case.

Notes

This method modifies the df attribute of the object.

static convert_to_sg_motl(motl_df, reset_index=False)#

Converts a given motl DataFrame to a Stopgap DataFrame.

Parameters:
motl_dfpandas.DataFrame

The input DataFrame in motl format.

reset_indexbool, default=False

Whether to reset the index of the resulting DataFrame. Defaults to False.

Returns:
pandas.DataFrame

The converted Stopgap DataFrame.

pairs = {'class': 'class', 'object_id': 'object', 'phi': 'phi', 'psi': 'psi', 'score': 'score', 'shift_x': 'x_shift', 'shift_y': 'y_shift', 'shift_z': 'z_shift', 'subtomo_id': 'subtomo_num', 'theta': 'the', 'tomo_id': 'tomo_num', 'x': 'orig_x', 'y': 'orig_y', 'z': 'orig_z'}#
static read_in(input_path)#

Reads in a starfile in stopgap format and returns the particles as a dataframe in stopgap format.

Parameters:
input_pathstr

The path to the starfile in stopgap format.

Returns:
pandas.DataFrame

The dataframe in the stopgap format containing the particles.

Raises:
UserInputError

If the starfile does not exist.

UserInputError

If the starfile does not contain the ‘data_stopgap_motivelist’ specifier, i.e., is not a particle list.

static sg_df_reset_index(stopgap_df, reset_index=False)#

Resets the “motl_idx” of a stopgap DataFrame to sequence from 1 to the length of the particle list if reset_index is True.

Parameters:
stopgap_dfpandas.DataFrame

The DataFrame to set the “motl_idx” of.

reset_indexbool, default=False

Whether to set the “motl_idx” to a sequence from 1 to the length of the particle list or leave the original values. Defaults to False.

Returns:
pandas.DataFrame

The DataFrame with the “motl_idx” either reset to the sequence from 1 to the length of the particle list or original values.

write_out(output_path, update_coord=False, reset_index=False)#

Writes the StopgapMotl object to a star file unless the extesions of the file is .em in which case it writes out the emfile type.

Parameters:
output_pathstr

The path to save the star or em file.

update_coordbool, default=False

Whether to update the coordinates before writing. Defaults to False.

reset_indexbool, default=False

Whether to reset the index of the dataframe before writing. Defaults to False.

Returns:
None

See also

cryocat.cryomotl.StopgapMotl.sg_df_reset_index()

Provides more details on index reseting.

Examples

>>> obj = StopgapMotl()
>>> obj.write("output.star", update_coord=True, reset_index=True)