cellpack.autopack.ingredient package¶
Submodules¶
cellpack.autopack.ingredient.Ingredient module¶
- class cellpack.autopack.ingredient.Ingredient.DistributionOptions(value)[source]¶
Bases:
MetaEnum
An enumeration.
- LIST_VALUES = 'list_values'¶
- MAX = 'max'¶
- MEAN = 'mean'¶
- MIN = 'min'¶
- STD = 'std'¶
- class cellpack.autopack.ingredient.Ingredient.DistributionTypes(value)[source]¶
Bases:
MetaEnum
An enumeration.
- LIST = 'list'¶
- NORMAL = 'normal'¶
- UNIFORM = 'uniform'¶
- class cellpack.autopack.ingredient.Ingredient.Ingredient(type='single_sphere', color=None, count=0, count_options=None, cutoff_boundary=None, cutoff_surface=0.0, distance_expression=None, distance_function=None, force_random=False, gradient=None, gradient_weights=None, is_attractor=False, max_jitter=(1, 1, 1), molarity=0.0, name=None, jitter_attempts=5, object_name=None, offset=[0, 0, 0], orient_bias_range=[-3.141592653589793, 3.141592653589793], overwrite_distance_function=True, packing_mode='random', priority=0, partners=None, perturb_axis_amplitude=0.1, place_method='jitter', principal_vector=(1, 0, 0), rejection_threshold=30, representations=None, resolution_dictionary=None, rotation_axis=None, rotation_range=6.2831, size_options=None, use_orient_bias=False, use_rotation_axis=False, weight=0.2)[source]¶
Bases:
Agent
- ARGUMENTS = ['color', 'count', 'count_options', 'cutoff_boundary', 'cutoff_surface', 'distance_expression', 'distance_function', 'force_random', 'gradient', 'gradient_weights', 'is_attractor', 'max_jitter', 'molarity', 'name', 'jitter_attempts', 'offset', 'orient_bias_range', 'overwrite_distance_function', 'packing_mode', 'priority', 'partners', 'perturb_axis_amplitude', 'place_method', 'principal_vector', 'rejection_threshold', 'representations', 'resolution_dictionary', 'rotation_axis', 'rotation_range', 'size_options', 'type', 'use_orient_bias', 'use_rotation_axis', 'weight', 'length', 'closed', 'uLength', 'biased', 'marge', 'orientation', 'walkignMode', 'constraintMarge', 'useHalton', 'compMask', 'use_rbsphere']¶
- attempt_to_pack_at_grid_location(env, ptInd, grid_point_distances, max_radius, spacing, usePP, collision_possible)[source]¶
- checkIfUpdate(nbFreePoints, threshold)[source]¶
Check if we need to update the distance array. Part of the hack free points
- getAxisRotation(rot)[source]¶
combines a rotation about axis to incoming rot. rot aligns the principal_vector with the surface normal rot aligns the principal_vector with the biased diretion
- getMesh(filename, geomname, mesh_store)[source]¶
Create a mesh representation from a filename for the ingredient
@type filename: string @param filename: the name of the input file @type geomname: string @param geomname: the name of the output geometry
@rtype: DejaVu.IndexedPolygons/HostObjec @return: the created mesh
- get_all_positions_to_check(packing_location)[source]¶
Takes a starting position in the packing space, and returns all the points that need to be tested for a collision as an array.
If the point isn’t close to an edge, will return just the staring point. If the point is close to the side of the bounding box, will return an array of 2. If the point is close to an edge of the bb (which is a “corner” in 2D), will return an array of 3. If the point is close to a corner in 3D will return an array of 8.
- get_cuttoff_value(spacing)[source]¶
Returns the min value a grid point needs to be away from a surfance in order for this ingredient to pack. Only needs to be calculated once per ingredient once the jitter is set.
- get_list_of_free_indices(distances, free_points, nbFreePoints, spacing, comp_ids, threshold)[source]¶
- get_new_distances_and_inside_points(env, packing_location, rotation_matrix, grid_point_index, grid_distance_values, new_dist_points, inside_points, signed_distance_to_surface=None)[source]¶
- get_new_pos(ingr, pos, rot, positions_to_adjust)[source]¶
Takes positions_to_adjust, such as an array of spheres at a level in a sphere tree, and adjusts them relative to the given position and rotation
- jitterPosition(position, spacing, normal=None)[source]¶
position are the 3d coordiantes of the grid point spacing is the grid spacing this will jitter gauss(0., 0.3) * Ingredient.max_jitter
- jitter_place(env, targeted_master_grid_point, rot_mat, moving, distance, dpad, pt_index)[source]¶
Check if the given grid point is available for packing using the jitter collision detection method. Returns packing location and new grid point values if packing is successful.
- pack_at_grid_pt_location(env, jtrans, rotation_matrix, dpad, grid_point_distances, inside_points, new_dist_points, pt_index)[source]¶
- rigid_place(env, ptInd, compartment, target_grid_point_position, rotation_matrix, nbFreePoints, distance, dpad, moving)[source]¶
drop the ingredient on grid point ptInd
- spheres_SST_place(env, compartment, ptInd, target_grid_point_position, rotation_matrix, moving, distance, dpad)[source]¶
drop the ingredient on grid point ptInd
- static_id = 0¶
Base class for Ingredients that can be added to a Recipe. Ingredients provide:
a molarity used to compute how many to place
a generic density value
a unit associated with the density value
a jitter amplitude vector specifying by how much the jittering
algorithm can move from the grid position. - a number of jitter attempts - an optional color used to draw the ingredient default (white) - an optional name - an optional pdb ID - an optional packing priority. If omitted the priority will be based on the radius with larger radii first ham here: (-)priority object will pack from high to low one at a time (+)priority will be weighted by assigned priority value (0)packignPriority will be weighted by complexity and appended to what is left of the (+) values - an optional principal vector used to align the ingredient - recipe will be a weakref to the Recipe this Ingredient belongs to - compartment_id is the compartment number (0 for cytoplasm, positive for compartment surface and negative compartment interior - Attributes used by the filling algorithm: - count counts the number of placed ingredients during a fill - counter is the target number of ingredients to place - completion is the ratio of placed/target - rejectionCounter is used to eliminate ingredients after too many failed attempts
- class cellpack.autopack.ingredient.Ingredient.IngredientInstanceDrop(ptId, position, rotation, ingredient, rb=None)[source]¶
Bases:
object
- cellpack.autopack.ingredient.Ingredient.random() x in the interval [0, 1). ¶
cellpack.autopack.ingredient.agent module¶
- class cellpack.autopack.ingredient.agent.Agent(name, concentration, distance_expression=None, distance_function=None, force_random=False, gradient=None, gradient_weights=None, is_attractor=False, overwrite_distance_function=True, packing_mode='random', partners=None, place_method='jitter', weight=0.2)[source]¶
Bases:
object
- getSubWeighted(weights)[source]¶
From http://eli.thegreenplace.net/2010/01/22/weighted-random-generation-in-python/ This method is about twice as fast as the binary-search technique, although it has the same complexity overall. Building the temporary list of totals turns out to be a major part of the functions runtime. This approach has another interesting property. If we manage to sort the weights in descending order before passing them to weighted_choice_sub, it will run even faster since the random call returns a uniformly distributed value and larger chunks of the total weight will be skipped in the beginning.
- cellpack.autopack.ingredient.agent.random() x in the interval [0, 1). ¶
cellpack.autopack.ingredient.grow module¶
- class cellpack.autopack.ingredient.grow.ActinIngredient(molarity, radii=[[50.0]], positions=None, positions2=None, priority=0, name=None, pdb=None, color=None, jitter_attempts=5, max_jitter=(1, 1, 1), perturb_axis_amplitude=0.1, length=10.0, closed=False, modelType='Cylinders', biased=1.0, type='Actine', principal_vector=(1, 0, 0), meshFile=None, packing=None, place_method='jitter', marge=35.0, influenceRad=100.0, meshObject=None, orientation=(1, 0, 0), count=0, **kw)[source]¶
Bases:
GrowIngredient
- class cellpack.autopack.ingredient.grow.GrowIngredient(available_regions=None, type='Grow', biased=1.0, closed=False, color=None, compMask=None, constraintMarge=False, cutoff_boundary=1.0, cutoff_surface=0.5, gradient=None, gradient_weights=None, is_attractor=False, max_jitter=(1, 1, 1), length=10.0, marge=20.0, meshFile=None, meshObject=None, model_type='Cylinders', molarity=0.0, name=None, jitter_attempts=5, count=0, count_options=None, orientation=(1, 0, 0), orient_bias_range=[-3.141592653589793, 3.141592653589793], priority=0, packing_mode='random', partners=None, perturb_axis_amplitude=0.1, place_method='jitter', positions=None, positions2=None, principal_vector=(1, 0, 0), radii=None, representations=None, rejection_threshold=30, rotation_axis=[0.0, 0.0, 0.0], rotation_range=6.2831, source=None, uLength=0, use_rbsphere=False, useHalton=True, useLength=False, use_orient_bias=False, use_rotation_axis=True, walkingMode='sphere', weight=0.2)[source]¶
Bases:
MultiCylindersIngr
- ARGUMENTS = ['color', 'count', 'count_options', 'cutoff_boundary', 'cutoff_surface', 'distance_expression', 'distance_function', 'force_random', 'gradient', 'gradient_weights', 'is_attractor', 'max_jitter', 'molarity', 'name', 'jitter_attempts', 'offset', 'orient_bias_range', 'overwrite_distance_function', 'packing_mode', 'priority', 'partners', 'perturb_axis_amplitude', 'place_method', 'principal_vector', 'rejection_threshold', 'representations', 'resolution_dictionary', 'rotation_axis', 'rotation_range', 'size_options', 'type', 'use_orient_bias', 'use_rotation_axis', 'weight', 'length', 'closed', 'uLength', 'biased', 'marge', 'orientation', 'walkignMode', 'constraintMarge', 'useHalton', 'compMask', 'use_rbsphere']¶
- grow(previousPoint, startingPoint, secondPoint, listePtCurve, listePtLinear, histoVol, ptInd, free_points, nbFreePoints, distance, dpad, stepByStep=False, r=False, usePP=False)[source]¶
- mask_sphere_points(v, pt, marge, listeclosest, cutoff, alternate=None, pv=None, marge_diedral=None, v3=[])[source]¶
- cellpack.autopack.ingredient.grow.random() x in the interval [0, 1). ¶
cellpack.autopack.ingredient.multi_cylinder module¶
- class cellpack.autopack.ingredient.multi_cylinder.MultiCylindersIngr(multi_bounds, radii, type='multi_cylinder', color=None, count=0, count_options=None, cutoff_boundary=None, cutoff_surface=0.0, distance_expression=None, distance_function=None, force_random=False, gradient=None, gradient_weights=None, is_attractor=False, max_jitter=(1, 1, 1), molarity=0.0, name=None, jitter_attempts=5, orient_bias_range=[-3.141592653589793, 3.141592653589793], packing_mode='random', priority=0, partners=None, perturb_axis_amplitude=0.1, place_method='jitter', principal_vector=(1, 0, 0), representations=None, rotation_axis=[0.0, 0.0, 0.0], rotation_range=6.2831, rejection_threshold=30, unit_length=None, use_orient_bias=False, use_rotation_axis=True, weight=0.2)[source]¶
Bases:
Ingredient
This Ingredient is represented by a collection of cylinder specified by multi_bounds and radii. Each cylinder in the group is has two bounds, representing the center of the bottom and the center of the top, and a radius. The array of multi_bounds and radii must be the same length. The principal Vector will be used to align the ingredient
- checkCylCollisions(centers1, centers2, radii, jtrans, rotMat, gridPointsCoords, distance, env, dpad)[source]¶
Check cylinders for collision
- collision_jitter(jtrans, rotMat, level, gridPointsCoords, distance, histoVol, dpad)[source]¶
Check cylinders for collision
cellpack.autopack.ingredient.multi_sphere module¶
- class cellpack.autopack.ingredient.multi_sphere.MultiSphereIngr(representations, available_regions=None, color=None, count=0, count_options=None, cutoff_boundary=None, cutoff_surface=None, gradient=None, gradient_weights=None, is_attractor=False, max_jitter=(1, 1, 1), molarity=0.0, name=None, jitter_attempts=5, offset=[0, 0, 0], orient_bias_range=[-3.141592653589793, 3.141592653589793], overwrite_distance_function=True, object_name=None, packing_mode='random', packing=0, partners=None, perturb_axis_amplitude=0.1, place_method='jitter', principal_vector=(1, 0, 0), priority=0, rejection_threshold=30, rotation_axis=[0.0, 0.0, 0.0], rotation_range=0, type='MultiSphere', use_orient_bias=False, use_rotation_axis=True, weight=0.2)[source]¶
Bases:
Ingredient
This Ingredient is represented by a collection of spheres specified by radii and positions. The principal Vector will be used to align the ingredient
- collides_with_compartment(env, jtrans, rotation_matrix)[source]¶
Check spheres for collision TODO improve the test when grid stepSize is larger that size of the ingredient
- collision_jitter(jtrans, rotMat, level, gridPointsCoords, current_grid_distances, env, dpad)[source]¶
Check spheres for collision
cellpack.autopack.ingredient.single_cube module¶
- class cellpack.autopack.ingredient.single_cube.SingleCubeIngr(bounds, available_regions=None, type='single_cube', color=None, count=0, count_options=None, cutoff_boundary=None, cutoff_surface=0.0, distance_expression=None, distance_function=None, force_random=False, gradient=None, gradient_weights=None, is_attractor=False, max_jitter=(1, 1, 1), molarity=0.0, name=None, jitter_attempts=5, offset=None, orient_bias_range=[-3.141592653589793, 3.141592653589793], overwrite_distance_function=True, priority=0, partners=None, perturb_axis_amplitude=0.1, place_method='jitter', principal_vector=(1, 0, 0), representations=None, rejection_threshold=30, resolution_dictionary=None, rotation_axis=[0.0, 0.0, 0.0], rotation_range=0, use_orient_bias=False, use_rotation_axis=True, weight=0.2)[source]¶
Bases:
Ingredient
This Ingredient is represented by a single cube. Required attribute: bounds, in the form of [lower bounds, upper bounds]. Each an x, y, z point.
- collides_with_compartment(env, jtrans, rotation_matrix)[source]¶
Check cube for collision centers1 and centers2 should be the cornerPoints ? can also use the center plus size (edges), or the position/position2
cellpack.autopack.ingredient.single_cylinder module¶
- class cellpack.autopack.ingredient.single_cylinder.SingleCylinderIngr(bounds, radius, available_regions=None, type='single_cylinder', color=None, count=0, count_options=None, cutoff_boundary=None, cutoff_surface=0.0, distance_expression=None, distance_function=None, force_random=False, gradient=None, gradient_weights=None, is_attractor=False, max_jitter=(1, 1, 1), molarity=0.0, name=None, jitter_attempts=5, orient_bias_range=[-3.141592653589793, 3.141592653589793], packing_mode='random', priority=0, partners=None, perturb_axis_amplitude=0.1, place_method='jitter', principal_vector=(1, 0, 0), rotation_axis=[0.0, 0.0, 0.0], rotation_range=6.2831, rejection_threshold=30, u_length=None, use_orient_bias=False, use_rotation_axis=True, weight=0.2)[source]¶
Bases:
Ingredient
This Ingredient is represented by a single cylinder specified by radii, positions and positions2. The principal Vector will be used to align the ingredient
- checkCylCollisions(centers1, centers2, radii, jtrans, rotMat, gridPointsCoords, distance, env, dpad)[source]¶
Check cylinders for collision
- collision_jitter(jtrans, rotMat, level, gridPointsCoords, distance, histoVol, dpad)[source]¶
Check cylinders for collision
cellpack.autopack.ingredient.single_sphere module¶
- class cellpack.autopack.ingredient.single_sphere.SingleSphereIngr(radius, available_regions=None, type='single_sphere', color=None, count=0, count_options=None, cutoff_boundary=None, cutoff_surface=0.0, distance_expression=None, distance_function=None, force_random=False, gradient=None, gradient_weights=None, is_attractor=False, max_jitter=(1, 1, 1), molarity=0.0, name=None, jitter_attempts=5, object_name=None, offset=None, orient_bias_range=[-3.141592653589793, 3.141592653589793], overwrite_distance_function=True, packing_mode='random', priority=0, partners=None, perturb_axis_amplitude=0.1, place_method='jitter', principal_vector=(1, 0, 0), representations=None, rejection_threshold=30, resolution_dictionary=None, rotation_axis=[0.0, 0.0, 0.0], rotation_range=0, size_options=None, use_orient_bias=False, use_rotation_axis=True, weight=0.2)[source]¶
Bases:
Ingredient
This Ingredient is represented by a single sphere and either a single radius, or a list of radii and offset vectors for each sphere representing the ingredient
- collides_with_compartment(env, jtrans, rotation_matrix=None)[source]¶
Check spheres for collision TODO improve the testwhen grid stepSize is larger that size of the ingredient
- collision_jitter(jtrans, rotMat, level, gridPointsCoords, current_grid_distances, env, dpad)[source]¶
Check spheres for collision
- static create_circular_mask(x_width, y_width, z_width, center=None, radius=None, voxel_size=None)[source]¶
Creates a circular mask of the given shape with the specified center and radius
cellpack.autopack.ingredient.utils module¶
- cellpack.autopack.ingredient.utils.ApplyMatrix(coords, mat)[source]¶
Apply the 4x4 transformation matrix to the given list of 3d points.
@type coords: array @param coords: the list of point to transform. @type mat: 4x4array @param mat: the matrix to apply to the 3d points
@rtype: array @return: the transformed list of 3d points
- cellpack.autopack.ingredient.utils.get_reflected_point(self, new_position, boundingBox=None)[source]¶
- cellpack.autopack.ingredient.utils.rotVectToVect(vect1, vect2, i=None)[source]¶
returns a 4x4 transformation that will align vect1 with vect2 vect1 and vect2 can be any vector (non-normalized)
- cellpack.autopack.ingredient.utils.rotax(a, b, tau, transpose=1)[source]¶
Build 4x4 matrix of clockwise rotation about axis a–>b by angle tau (radians). a and b are sequences of 3 floats each Result is a homogenous 4x4 transformation matrix. NOTE: This has been changed by Brian, 8/30/01: rotax now returns the rotation matrix, _not_ the transpose. This is to get consistency across rotax, mat_to_quat and the classes in transformation.py when transpose is 1 (default) a C-style rotation matrix is returned i.e. to be used is the following way Mx (opposite of OpenGL style which is using the FORTRAN style)