Author: bugman Date: Fri Dec 10 16:27:22 2010 New Revision: 11758 URL: http://svn.gna.org/viewcvs/relax?rev=11758&view=rev Log: The molecule type can now be specified. Modified: 1.3/data/mol_res_spin.py 1.3/generic_fns/mol_res_spin.py 1.3/prompt/molecule.py 1.3/test_suite/shared_data/model_free/OMP/final_results_trunc_1.3.bz2 Modified: 1.3/data/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/data/mol_res_spin.py?rev=11758&r1=11757&r2=11758&view=diff ============================================================================== --- 1.3/data/mol_res_spin.py (original) +++ 1.3/data/mol_res_spin.py Fri Dec 10 16:27:22 2010 @@ -500,11 +500,14 @@ class MoleculeContainer(Prototype): """Class containing all the molecule specific data.""" - def __init__(self, mol_name=None): + def __init__(self, mol_name=None, mol_type=None): """Set up the default objects of the molecule data container.""" # The name of the molecule, corresponding to that of the structure file if specified. self.name = mol_name + + # The type of molecule. + self.type = mol_type # The empty residue list. self.res = ResidueList() @@ -558,7 +561,7 @@ # An object has been added to the container. for name in dir(self): # Skip the objects initialised in __init__(). - if name == 'name' or name == 'res': + if name in ['name', 'res', 'type']: continue # Skip the MoleculeContainer methods. @@ -605,12 +608,13 @@ return text - def add_item(self, mol_name=None): + def add_item(self, mol_name=None, mol_type=None): """Append an empty MoleculeContainer to the MoleculeList.""" # If no molecule data exists, replace the empty first molecule with this molecule (just a renaming). if self.is_empty(): self[0].name = mol_name + self[0].type = mol_type # Otherwise append an empty MoleculeContainer. else: @@ -620,7 +624,7 @@ raise RelaxError("The molecule '%s' already exists in the sequence." % mol_name) # Append an empty MoleculeContainer. - self.append(MoleculeContainer(mol_name)) + self.append(MoleculeContainer(mol_name, mol_type)) def is_empty(self): @@ -656,7 +660,10 @@ name = mol_node.getAttribute('name') if name == 'None': name = None - self.add_item(mol_name=name) + type = mol_node.getAttribute('type') + if type == 'None': + type = None + self.add_item(mol_name=name, mol_type=type) # Get the residue nodes. res_nodes = mol_node.getElementsByTagName('res') @@ -683,9 +690,10 @@ # Set the molecule attributes. mol_element.setAttribute('desc', 'Molecule container') mol_element.setAttribute('name', str(self[i].name)) + mol_element.setAttribute('type', str(self[i].type)) # Add all simple python objects within the MoleculeContainer to the XML element. - fill_object_contents(doc, mol_element, object=self[i], blacklist=['name', 'res'] + list(self[i].__class__.__dict__.keys())) + fill_object_contents(doc, mol_element, object=self[i], blacklist=['name', 'res', 'type'] + list(self[i].__class__.__dict__.keys())) # Add the residue data. self[i].res.to_xml(doc, mol_element) Modified: 1.3/generic_fns/mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/mol_res_spin.py?rev=11758&r1=11757&r2=11758&view=diff ============================================================================== --- 1.3/generic_fns/mol_res_spin.py (original) +++ 1.3/generic_fns/mol_res_spin.py Fri Dec 10 16:27:22 2010 @@ -50,6 +50,14 @@ from relax_warnings import RelaxWarning +ALLOWED_MOL_TYPES = ['protein', + 'DNA', + 'RNA', + 'organic molecule', + 'inorganic molecule' +] +"""The list of allowable molecule types.""" + id_string_doc = """ Identification string documentation ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -803,15 +811,21 @@ return spin_num -def create_molecule(mol_name=None): +def create_molecule(mol_name=None, mol_type=None): """Add a molecule into the relax data store. @keyword mol_name: The name of the molecule. @type mol_name: str + @keyword mol_type: The type of molecule. + @type mol_type: str """ # Test if the current data pipe exists. pipes.test() + + # Test the molecule type. + if mol_type and mol_type not in ALLOWED_MOL_TYPES: + raise RelaxError("The molecule type '%s' must be one of %s" % (mol_type, ALLOWED_MOL_TYPES)) # Test if the molecule name already exists. for i in xrange(len(cdp.mol)): @@ -819,7 +833,7 @@ raise RelaxError("The molecule '" + repr(mol_name) + "' already exists in the relax data store.") # Append the molecule. - cdp.mol.add_item(mol_name=mol_name) + cdp.mol.add_item(mol_name=mol_name, mol_type=mol_type) def create_residue(res_num=None, res_name=None, mol_name=None): Modified: 1.3/prompt/molecule.py URL: http://svn.gna.org/viewcvs/relax/1.3/prompt/molecule.py?rev=11758&r1=11757&r2=11758&view=diff ============================================================================== --- 1.3/prompt/molecule.py (original) +++ 1.3/prompt/molecule.py Fri Dec 10 16:27:22 2010 @@ -91,7 +91,7 @@ copy_molecule(pipe_from=pipe_from, mol_from=mol_from, pipe_to=pipe_to, mol_to=mol_to) - def create(self, mol_name=None): + def create(self, mol_name=None, type=None): """Function for creating a new molecule. Keyword Arguments @@ -99,12 +99,16 @@ mol_name: The name of the molecule. + type: The type of molecule. + Description ~~~~~~~~~~~ This function will add a new molecule data container to the relax data storage object. The - same molecule name cannot be used more than once. + same molecule name cannot be used more than once. The molecule type need not be specified. + However if it given, it should be one of 'protein', 'RNA', 'DNA', 'organic molecule', + 'inorganic molecule'. Examples @@ -120,14 +124,16 @@ # Function intro text. if self._exec_info.intro: text = self._exec_info.ps3 + "molecule.create(" - text = text + "mol_name=" + repr(mol_name) + ")" + text = text + "mol_name=" + repr(mol_name) + text = text + ", type=" + repr(type) + ")" print(text) # The argument checks. arg_check.is_str(mol_name, 'molecule name') - - # Execute the functional code. - create_molecule(mol_name=mol_name) + arg_check.is_str(type, 'molecule type', can_be_none=True) + + # Execute the functional code. + create_molecule(mol_name=mol_name, mol_type=type) def delete(self, mol_id=None): Modified: 1.3/test_suite/shared_data/model_free/OMP/final_results_trunc_1.3.bz2 URL: http://svn.gna.org/viewcvs/relax/1.3/test_suite/shared_data/model_free/OMP/final_results_trunc_1.3.bz2?rev=11758&r1=11757&r2=11758&view=diff ============================================================================== Binary files - no diff available.