Multiprocessing SasMol¶
Multiprocessing SasMol¶
- class sasmol.multiprocessing_sasmol.Multiprocessing_SasMol[source]¶
Bases:
objectClass containing methods to manage the creation and combination of sasmol.system objects and to manage multiprocessing jobs using these objects.
Examples
First example shows how to use class methods from system object:
>>> import sasmol.system as system >>> molecule = system.Molecule('hiv1_gag.pdb') >>> molecule.read_dcd('hiv1_gag_200_frames.dcd') >>> number_of_batches = 10 >>> test = Multiprocessing_SasMol() >>> molecules = test.divide_molecule(number_of_batches) >>> test.submit_jobs(molecules, test.example_worker, number_of_batches)
>>> molecules = molecule.divide_molecule(number_of_batches) >>> test = Multiprocessing_SasMol() >>> test.submit_jobs(molecules, test.example_worker, number_of_batches)
Note
THIS CLASS IS NEW AND IS UNDER ACTIVE DEVELOPMENT AND MAY CHANGE DRAMATICALLY
- ### LAST THREE LINES OF EXAMPLE ARE FOR CONSIDERATION FOR POTENTIAL
WOULD REQUIRE CLASS TO INHERIT FROM SASMOL.SYSTEM.ATOM
self parameter is not shown in the
Parameterssection in the documentation- divide_molecule(molecule, number_of_batches, **kwargs)[source]¶
Method makes a deep copy of frame 0 of the input molecule into a set of new molecules indicated by the number_of_batches input variable.
After duplicating the molecule, the coordinates are assigned to the duplicate molecules.
The number of frames per duplicate is the same, except perhaps when the number of frames is not an equal divisor of number_of_batches which leads to the remainder frames assigned to the last duplicate molecule.
- Parameters
molecule – system object :
number_of_batches – integer : number of duplicate molecules to generate
kwargs – optional future arguments
- Returns
updated self._coor
- Return type
None
Examples
>>> import sasmol.system as system >>> molecule = system.Molecule('hiv1_gag.pdb') >>> molecule.read_dcd('hiv1_gag_200_frames.dcd') >>> number_of_batches = 10 >>> test = Multiprocessing_SasMol() >>> molecules = test.divide_molecule(number_of_batches)
>>> molecules = molecule.divide_molecule(number_of_batches)
Note
Last line in the examples is an alternative use case to explore yet not implemented.
- example_worker(i, molecule, **kwargs)[source]¶
Example method to execute in parallel using multiprocessing
- Parameters
i – integer : job number
molecule – sasmol object
kwargs – optional future arguments
- Returns
list of float center_of_mass values
- Return type
com
- get_frame_lists(number_of_frames, number_of_batches, **kwargs)[source]¶
Utility method to determine individual frame lists for each of the total number_of_frames divided into number_of_batches
- Parameters
number_of_frames – integer : number of frames in complete molecule
number_of_batches – integer : number of frame groups to create
kwargs – optional future arguments
- Returns
integer list of frame lists
- Return type
frames
Examples
>>> frames = self.get_frame_lists(molecule.number_of_frames(), number_of_batches)
- submit_jobs(molecules, target_method, number_of_jobs, **kwargs)[source]¶
Utility method to start a set of multiprocessing jobs
- Parameters
molecules – list : system objects
target_method – string : name of method to call
number_of_jobs – int : number of job / processes to run
kwargs – optional future arguments
- Return type
None
Examples
>>> test.submit_jobs(molecules, test.example_worker, number_of_batches)