Author: bugman Date: Tue May 20 18:46:40 2008 New Revision: 6168 URL: http://svn.gna.org/viewcvs/relax?rev=6168&view=rev Log: Updated the atom_add() method to handle multiple models. Modified: 1.3/generic_fns/structure/internal.py Modified: 1.3/generic_fns/structure/internal.py URL: http://svn.gna.org/viewcvs/relax/1.3/generic_fns/structure/internal.py?rev=6168&r1=6167&r2=6168&view=diff ============================================================================== --- 1.3/generic_fns/structure/internal.py (original) +++ 1.3/generic_fns/structure/internal.py Tue May 20 18:46:40 2008 @@ -288,42 +288,52 @@ raise RelaxError, "The structural data is invalid." - def atom_add(self, pdb_record=None, atom_name=None, res_name=None, chain_id=None, res_num=None, pos=[None, None, None], segment_id=None, element=None): + def atom_add(self, pdb_record=None, atom_name=None, res_name=None, chain_id=None, res_num=None, pos=[None, None, None], segment_id=None, element=None, model=None): """Method for adding an atom to the structural data object. This method will create the key-value pair for the given atom. - @param pdb_record: The optional PDB record name, e.g. 'ATOM', 'HETATM', or 'TER'. - @type pdb_record: str or None - @param atom_name: The atom name, e.g. 'H1'. - @type atom_name: str or None - @param res_name: The residue name. - @type res_name: str or None - @param chain_id: The chain identifier. - @type chain_id: str or None - @param res_num: The residue number. - @type res_num: int or None - @param pos: The position vector of coordinates. - @type pos: list (length = 3) - @param segment_id: The segment identifier. - @type segment_id: str or None - @param element: The element symbol. - @type element: str or None - """ - - # Append to all the arrays. - self.structural_data.atom_name.append(atom_name) - self.structural_data.bonded.append([]) - self.structural_data.chain_id.append(chain_id) - self.structural_data.element.append(element) - self.structural_data.pdb_record.append(pdb_record) - self.structural_data.res_name.append(res_name) - self.structural_data.res_num.append(res_num) - self.structural_data.seg_id.append(segment_id) - self.structural_data.x.append(pos[0]) - self.structural_data.y.append(pos[1]) - self.structural_data.z.append(pos[2]) + @keyword pdb_record: The optional PDB record name, e.g. 'ATOM', 'HETATM', or 'TER'. + @type pdb_record: str or None + @keyword atom_name: The atom name, e.g. 'H1'. + @type atom_name: str or None + @keyword res_name: The residue name. + @type res_name: str or None + @keyword chain_id: The chain identifier. + @type chain_id: str or None + @keyword res_num: The residue number. + @type res_num: int or None + @keyword pos: The position vector of coordinates. + @type pos: list (length = 3) + @keyword segment_id: The segment identifier. + @type segment_id: str or None + @keyword element: The element symbol. + @type element: str or None + @keyword model: The model to add the atom to. If not supplied and multiple models + exist, then the atom will be added to all models. + @type model: None or int + """ + + + # Loop over the models. + for struct in self.structural_data: + # Skip non-matching models. + if model != None and model != struct.model: + continue + + # Append to all the arrays. + struct.atom_name.append(atom_name) + struct.bonded.append([]) + struct.chain_id.append(chain_id) + struct.element.append(element) + struct.pdb_record.append(pdb_record) + struct.res_name.append(res_name) + struct.res_num.append(res_num) + struct.seg_id.append(segment_id) + struct.x.append(pos[0]) + struct.y.append(pos[1]) + struct.z.append(pos[2]) def atom_connect(self, index1=None, index2=None):