Author: bugman Date: Mon Feb 16 10:08:49 2015 New Revision: 27646 URL: http://svn.gna.org/viewcvs/relax?rev=27646&view=rev Log: Introduced the max_rotations argument into the frame_order.distribute user function. This is used to prevent the user function from running forever. This happens whenever a cone opening angle or torsion angle is zero, and hence the random sampling of the rotational space will never find rotations within the motional distribution. Modified: branches/frame_order_cleanup/lib/frame_order/simulation.py branches/frame_order_cleanup/specific_analyses/frame_order/uf.py branches/frame_order_cleanup/user_functions/frame_order.py Modified: branches/frame_order_cleanup/lib/frame_order/simulation.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/lib/frame_order/simulation.py?rev=27646&r1=27645&r2=27646&view=diff ============================================================================== --- branches/frame_order_cleanup/lib/frame_order/simulation.py (original) +++ branches/frame_order_cleanup/lib/frame_order/simulation.py Mon Feb 16 10:08:49 2015 @@ -211,7 +211,7 @@ structure.write_pdb(file=file) -def uniform_distribution(file=None, model=None, structure=None, parameters={}, eigenframe=None, pivot=None, atom_id=None, total=1000): +def uniform_distribution(file=None, model=None, structure=None, parameters={}, eigenframe=None, pivot=None, atom_id=None, total=1000, max_rotations=100000): """Uniform distribution of the frame order motions. @keyword file: The opened and writable file object to place the PDB models of the distribution into. @@ -230,6 +230,8 @@ @type atom_id: None or str @keyword total: The total number of states in the distribution. @type total: int + @keyword max_rotations: The maximum number of rotations to generate the distribution from. This prevents an execution for an infinite amount of time when a frame order amplitude parameter is close to zero so that the subset of all rotations within the distribution is close to zero. + @type max_rotations: int """ # Check the structural object. @@ -287,9 +289,13 @@ # Distribution. current_state = 1 + num = -1 while True: + # The total number of rotations. + num += 1 + # End. - if current_state == total: + if current_state == total or num >= max_rotations: break # Loop over each state, or motional mode. Modified: branches/frame_order_cleanup/specific_analyses/frame_order/uf.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/specific_analyses/frame_order/uf.py?rev=27646&r1=27645&r2=27646&view=diff ============================================================================== --- branches/frame_order_cleanup/specific_analyses/frame_order/uf.py (original) +++ branches/frame_order_cleanup/specific_analyses/frame_order/uf.py Mon Feb 16 10:08:49 2015 @@ -47,19 +47,21 @@ from specific_analyses.frame_order.parameters import assemble_param_vector, update_model -def distribute(file="distribution.pdb.bz2", dir=None, total=1000, model=1, force=True): +def distribute(file="distribution.pdb.bz2", dir=None, total=1000, max_rotations=100000, model=1, force=True): """Create a uniform distribution of structures for the frame order motions. - @keyword file: The PDB file for storing the frame order motional distribution. The compression is determined automatically by the file extensions '*.pdb', '*.pdb.gz', and '*.pdb.bz2'. - @type file: str - @keyword dir: The directory name to place the file into. - @type dir: str or None - @keyword total: The total number of states/model/structures in the distribution. - @type total: int - @keyword model: Only one model from an analysed ensemble of structures can be used for the distribution, as the corresponding PDB file consists of one model per state. - @type model: int - @keyword force: A flag which, if set to True, will overwrite the any pre-existing file. - @type force: bool + @keyword file: The PDB file for storing the frame order motional distribution. The compression is determined automatically by the file extensions '*.pdb', '*.pdb.gz', and '*.pdb.bz2'. + @type file: str + @keyword dir: The directory name to place the file into. + @type dir: str or None + @keyword total: The total number of states/model/structures in the distribution. + @type total: int + @keyword max_rotations: The maximum number of rotations to generate the distribution from. This prevents an execution for an infinite amount of time when a frame order amplitude parameter is close to zero so that the subset of all rotations within the distribution is close to zero. + @type max_rotations: int + @keyword model: Only one model from an analysed ensemble of structures can be used for the distribution, as the corresponding PDB file consists of one model per state. + @type model: int + @keyword force: A flag which, if set to True, will overwrite the any pre-existing file. + @type force: bool """ # Printout. @@ -108,7 +110,7 @@ frame = generate_axis_system() # Create the distribution. - uniform_distribution(file=file, model=cdp.model, structure=structure, parameters=params, eigenframe=frame, pivot=pivot, atom_id=domain_moving(), total=total) + uniform_distribution(file=file, model=cdp.model, structure=structure, parameters=params, eigenframe=frame, pivot=pivot, atom_id=domain_moving(), total=total, max_rotations=max_rotations) # Close the file. file.close() Modified: branches/frame_order_cleanup/user_functions/frame_order.py URL: http://svn.gna.org/viewcvs/relax/branches/frame_order_cleanup/user_functions/frame_order.py?rev=27646&r1=27645&r2=27646&view=diff ============================================================================== --- branches/frame_order_cleanup/user_functions/frame_order.py (original) +++ branches/frame_order_cleanup/user_functions/frame_order.py Mon Feb 16 10:08:49 2015 @@ -93,6 +93,16 @@ py_type = "int", desc_short = "total number of structures", desc = "The total number of structures to include in the uniform distribution.", + wiz_element_type = "spin" +) +uf.add_keyarg( + name = "max_rotations", + default = 1000000, + min = 1, + max = 100000000, + py_type = "int", + desc_short = "maximum number of rotations", + desc = "The maximum number of rotations to generate the distribution from. This prevents the user function from executing for an infinite amount of time. This occurs whenever a frame order amplitude parameter (cone opening angle or torsion angle) is zero so that the subset of all rotations within the motional distribution is also zero.", wiz_element_type = "spin" ) uf.add_keyarg(