Author: bugman Date: Sat Jul 5 00:46:18 2008 New Revision: 6705 URL: http://svn.gna.org/viewcvs/relax?rev=6705&view=rev Log: Modified how non-standard residue information is collected and stored for future writing. Modified: branches/rdc_analysis/generic_fns/structure/internal.py Modified: branches/rdc_analysis/generic_fns/structure/internal.py URL: http://svn.gna.org/viewcvs/relax/branches/rdc_analysis/generic_fns/structure/internal.py?rev=6705&r1=6704&r2=6705&view=diff ============================================================================== --- branches/rdc_analysis/generic_fns/structure/internal.py (original) +++ branches/rdc_analysis/generic_fns/structure/internal.py Sat Jul 5 00:46:18 2008 @@ -719,28 +719,27 @@ continue # If the residue is not already stored initialise a new het_data element. - # (residue number, residue name, chain ID, number of atoms, number of H, number of C, number of N). + # (residue number, residue name, chain ID, number of atoms, atom count array). if not het_data or not struct.res_num[i] == het_data[-1][0]: - het_data.append([struct.res_num[i], struct.res_name[i], struct.chain_id[i], 0, 0, 0, 0]) + het_data.append([struct.res_num[i], struct.res_name[i], struct.chain_id[i], 0, []]) # Total atom count. het_data[-1][3] = het_data[-1][3] + 1 - # Proton count. - if struct.element[i] == 'H': - het_data[-1][4] = het_data[-1][4] + 1 - - # Carbon count. - elif struct.element[i] == 'C': - het_data[-1][5] = het_data[-1][5] + 1 - - # Nitrogen count. - elif struct.element[i] == 'N': - het_data[-1][6] = het_data[-1][6] + 1 - - # Unsupported element type. - else: - raise RelaxError, "The element " + `struct.element[i]` + " was expected to be one of ['H', 'C', 'N']." + # Find if the atom has already a count entry. + entry = False + for i in xrange(len(het_data[-1][4])): + if struct.element[i] == het_data[-1][4][i][0]: + entry = True + + # Create a new specific atom count entry. + if not entry: + het_data[-1][4].append([struct.element[i], 0]) + + # Increment the specific atom count. + for i in xrange(len(het_data[-1][4])): + if struct.element[i] == het_data[-1][4][i][0]: + het_data[-1][4][i][1] = het_data[-1][4][i][1] + 1 # The HET records.