def test_write_list(self): """Test the lib.software.sparky.write_list() function.""" # The data. res_names = ['LEU', 'GLY', 'SER', 'MET', 'TRP', 'TRP', 'ASN'] res_nums = [3, 4, 5, 6, 40, 40, 55] atom1_names = ['N', 'N', 'N', 'N', 'N', 'NE1', 'N'] atom2_names = ['HN', 'HN', 'HN', 'HN', 'HN', 'HE1', 'HN'] w1 = [122.454, 111.978, 115.069, 120.910, 123.335, 130.204, 116.896] w2 = [8.397, 8.720, 8.177, 8.813, 8.005, 10.294, 7.468] heights = [2535, 5050, 51643, 53663, -65111, -181131, -105322] # The result. file_data = [ ' Assignment w1 w2 Data Height\n', '\n', ' LEU3N-HN 122.454 8.397 2535\n', ' GLY4N-HN 111.978 8.720 5050\n', ' SER5N-HN 115.069 8.177 51643\n', ' MET6N-HN 120.910 8.813 53663\n', ' TRP40N-HN 123.335 8.005 -65111\n', ' TRP40NE1-HE1 130.204 10.294 -181131\n', ' ASN55N-HN 116.896 7.468 -105322\n' ] # Write the data out. file = DummyFileObject() write_list(file_prefix=file, res_names=res_names, res_nums=res_nums, atom1_names=atom1_names, atom2_names=atom2_names, w1=w1, w2=w2, data_height=heights) # Check the file data. lines = file.readlines() self.assertEqual(len(lines), len(file_data)) for i in range(len(lines)): self.assertEqual(lines[i], file_data[i])
# The rate. nomen = pA * pB * dw[spin_index]**2 * kex denom = omega_aeff2[spin_index] * omega_beff2[ spin_index] / omega_eff2[spin_index] + kex**2 rx = r1[spin_index, frq_index] * cos_theta2 + sin_theta2 * ( r1rho_prime[spin_index, frq_index] + nomen / denom) # The peak intensity. intensities.append(i0[spin_index, frq_index] * exp(-rx * times[time_index])) # Create a Sparky .list file. if time_index == 0 and spin_lock_index == 0: name = 'ref_%s' % frq_label[frq_index] elif time_index == 0: name = None else: name = 'nu_%s_%s' % (spin_lock[spin_lock_index], frq_label[frq_index]) if name: write_list(file_prefix=name, dir=None, res_names=res_names, res_nums=res_nums, atom1_names=atomN_names, atom2_names=atomH_names, w1=wN, w2=wH, data_height=intensities)
omega_beff2 = omega1**2 + delta_b**2 omega_eff2 = omega1**2 + delta_ave**2 # Loop over the relaxation times. for time_index in range(len(times)): # Loop over the spins. intensities = [] for spin_index in range(len(r1rho_prime)): # Spin dependent parameters. theta = atan(omega1 / delta_ave[spin_index]) sin_theta2 = sin(theta)**2 cos_theta2 = cos(theta)**2 # The rate. nomen = pA * pB * dw[spin_index]**2 * kex denom = omega_aeff2[spin_index] * omega_beff2[spin_index] / omega_eff2[spin_index] + kex**2 rx = r1[spin_index, frq_index] * cos_theta2 + sin_theta2 * (r1rho_prime[spin_index, frq_index] + nomen / denom) # The peak intensity. intensities.append(i0[spin_index, frq_index] * exp(-rx*times[time_index])) # Create a Sparky .list file. if time_index == 0 and spin_lock_index == 0: name = 'ref_%s' % frq_label[frq_index] elif time_index == 0: name = None else: name = 'nu_%s_%s' % (spin_lock[spin_lock_index], frq_label[frq_index]) if name: write_list(file_prefix=name, dir=None, res_names=res_names, res_nums=res_nums, atom1_names=atomN_names, atom2_names=atomH_names, w1=wN, w2=wH, data_height=intensities)