Author: bugman Date: Mon Feb 18 17:56:39 2013 New Revision: 18481 URL: http://svn.gna.org/viewcvs/relax?rev=18481&view=rev Log: Implemented the structure.add_model user function. Modified: trunk/generic_fns/structure/main.py trunk/user_functions/structure.py Modified: trunk/generic_fns/structure/main.py URL: http://svn.gna.org/viewcvs/relax/trunk/generic_fns/structure/main.py?rev=18481&r1=18480&r2=18481&view=diff ============================================================================== --- trunk/generic_fns/structure/main.py (original) +++ trunk/generic_fns/structure/main.py Mon Feb 18 17:56:39 2013 @@ -77,6 +77,28 @@ # Add the atoms. cdp.structure.add_atom(mol_name=mol_name, atom_name=atom_name, res_name=res_name, res_num=res_num, pos=pos, element=element, atom_num=atom_num, chain_id=chain_id, segment_id=segment_id, pdb_record=pdb_record) + + +def add_model(): + """Add a new model to the empty structural data object.""" + + # Test if the current data pipe exists. + pipes.test() + + # Place the structural object into the relax data store if needed. + if not hasattr(cdp, 'structure'): + cdp.structure = Internal() + + # The structural object can only be the internal object. + if cdp.structure.id != 'internal': + raise RelaxError("Models can only be added to the internal structural object.") + + # Check the structural object is empty. + if cdp.structure.num_molecules() != 0: + raise RelaxError("The internal structural object is not empty.") + + # Add a model. + cdp.structure.structural_data.add_item() def connect_atom(index1=None, index2=None): Modified: trunk/user_functions/structure.py URL: http://svn.gna.org/viewcvs/relax/trunk/user_functions/structure.py?rev=18481&r1=18480&r2=18481&view=diff ============================================================================== --- trunk/user_functions/structure.py (original) +++ trunk/user_functions/structure.py Mon Feb 18 17:56:39 2013 @@ -124,6 +124,20 @@ uf.menu_text = "&add_atom" uf.gui_icon = "oxygen.actions.list-add-relax-blue" uf.wizard_size = (800, 600) +uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png' + + +# The structure.add_model user function. +uf = uf_info.add_uf('structure.add_model') +uf.title = "Add a new model." +uf.title_short = "Model creation." +# Description. +uf.desc.append(Desc_container()) +uf.desc[-1].add_paragraph("This allows new models to be added to the internal structural object. Note that no structural information is allowed to be present") +uf.backend = generic_fns.structure.main.add_model +uf.menu_text = "&add_model" +uf.gui_icon = "oxygen.actions.list-add-relax-blue" +uf.wizard_size = (700, 400) uf.wizard_image = WIZARD_IMAGE_PATH + 'structure' + sep + '2JK4.png'