本文整理汇总了Python中utils.Atom_utils._get_atom_info_from_index方法的典型用法代码示例。如果您正苦于以下问题:Python Atom_utils._get_atom_info_from_index方法的具体用法?Python Atom_utils._get_atom_info_from_index怎么用?Python Atom_utils._get_atom_info_from_index使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类utils.Atom_utils
的用法示例。
在下文中一共展示了Atom_utils._get_atom_info_from_index方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testNonBondedComponents
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def testNonBondedComponents(self):
non_bonded_potential = self._get_non_bonded_potential()
non_bonded_potential.update_non_bonded_list()
target_components = non_bonded_potential._get_component_list('ATOM')
remote_components = non_bonded_potential._get_component_list('NBRM')
expected_components = dict(ala_4.ala_components_non_bond)
for component in non_bonded_potential._get_all_components('NBLT'):
#TODO: remove need for component?
for exponent in (1,-3):
target_component_index, remote_component_index = component[1:3]
target_atom_id = target_components[target_component_index][0]
remote_atom_id = remote_components[remote_component_index][0]
target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)
expected_shift_key = target_atom_key,remote_atom_key,int(exponent)
self.assertElemeInSet(expected_shift_key, expected_components)
del expected_components[expected_shift_key]
self.assertEmpty(expected_components)
示例2: _test_non_bonded_shifts
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def _test_non_bonded_shifts(self, non_bonded_potential, non_bonded_shifts):
non_bonded_potential.update_non_bonded_list()
target_components = non_bonded_potential._get_component_list('ATOM')
remote_components = non_bonded_potential._get_component_list('NBRM')
for i, component in enumerate( non_bonded_potential._get_all_components('NBLT')):
target_component_index, remote_component_index = component[1:3]
target_atom_id = target_components[target_component_index][0]
remote_atom_id = remote_components[remote_component_index][0]
expected_shift = 0.0
key_good = False
for j, exponent in enumerate((1,-3)):
target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)
expected_shift_key = target_atom_key, remote_atom_key, int(exponent)
if expected_shift_key in non_bonded_shifts:
expected_shift += non_bonded_shifts[expected_shift_key]
key_good=True
elif j == 0:
distance = Atom_utils._calculate_distance(target_atom_id, remote_atom_id)
self.assertTrue(distance >= 5.0, expected_shift_key)
if key_good:
calculated_shift = non_bonded_potential._calc_component_shift(i)
self.assertAlmostEqual(expected_shift, calculated_shift, self.DEFAULT_DECIMAL_PLACES, expected_shift_key)
示例3: test_component_shifts_sidechain
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def test_component_shifts_sidechain(self):
xcamshift = self._get_xcamshift()
sidechain_subpotential = xcamshift.get_named_sub_potential(SIDE_CHAIN)
expected_sidechain_shifts = dict(gb3_component_shifts_sc)
expected_component_keys = expected_sidechain_shifts.keys()
for component_index, component in enumerate(sidechain_subpotential._get_component_list()):
from_atom_id, to_atom_id = component[0:2]
from_atom_key = Atom_utils._get_atom_info_from_index(from_atom_id)
to_atom_key = Atom_utils._get_atom_info_from_index(to_atom_id)
# print from_atom_key, to_atom_key
if from_atom_key[2] == 'HA1':
from_atom_key = from_atom_key[0],from_atom_key[1],'HA'
expected_key = from_atom_key, to_atom_key
self.assertIn(expected_key, expected_component_keys, `expected_key` + " exists")
shift = sidechain_subpotential._calc_component_shift(component_index)
self.assertAlmostEqual(expected_sidechain_shifts[expected_key], shift, places=self.DEFAULT_DECIMAL_PLACES - 2, msg=`expected_key`)
del expected_sidechain_shifts[expected_key]
self.remove_zero_valued_keys(expected_sidechain_shifts)
self.assertEmpty(expected_sidechain_shifts)
示例4: _test_non_bonded_forces
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def _test_non_bonded_forces(self, non_bonded_potential, non_bonded_forces, active_shifts, factors):
components = dict(non_bonded_potential._get_components())
nb_interaction_list = components['NBLT']
active_array = allocate_array(1,'i')
components['ACTI'] = active_array
#TODO: make this less invasive of the potentials encapsulation
components['OFFS'] = 0
non_bonded_potential._force_calculator._set_components(components)
for i, component in enumerate(nb_interaction_list):
zero_array(active_array)
active_array[0] = i
target_atom_id = non_bonded_potential._get_component_list('ATOM')[component[1]][0]
remote_atom_id = non_bonded_potential._get_component_list('NBRM')[component[2]][0]
target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)
if active_shifts[target_atom_key] == 0:
continue
#
distance = Atom_utils._calculate_distance(target_atom_id, remote_atom_id)
if distance < 5.0:
for exponent_index, exponent in enumerate((1,-3)):
expected_key = target_atom_key, remote_atom_key, int(exponent)
factor = factors[target_atom_key]
non_bonded_potential._force_calculator._build_component(i,exponent_index)
factor = factors[target_atom_key]
out_array = self.make_out_array()
non_bonded_potential._force_calculator._calc_single_force_set(0, factor,out_array)
forces = out_array.add_forces_to_result()
target_force_triplet = forces[target_atom_id]
remote_force_triplet = forces[remote_atom_id]
expected_target_forces = non_bonded_forces[expected_key]
expected_remote_forces = [-elem for elem in expected_target_forces]
#TODO: check change from 7 to 5 dp is ok also improve assertSequenceAlmostEqual ro take a places argument
self.assertSequenceAlmostEqual(target_force_triplet, expected_target_forces,delta= 1e-1**self.DEFAULT_DECIMAL_PLACES)
self.assertSequenceAlmostEqual(remote_force_triplet, expected_remote_forces,delta= 1e-1**self.DEFAULT_DECIMAL_PLACES)
atom_ids = [target_atom_id,remote_atom_id]
atom_ids.sort(reverse=True)
for atom_id in atom_ids:
del forces[atom_id]
forces = self.remove_almost_zero_force_elems_from_list(forces)
self.assertEmpty(forces)
del non_bonded_forces[expected_key]
self.assertEmpty(non_bonded_forces)
示例5: test_non_bonded_component_shifts
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def test_non_bonded_component_shifts(self):
xcamshift = self._get_xcamshift()
sub_potential = xcamshift.get_named_sub_potential(NON_BONDED)
sub_potential.update_non_bonded_list()
components = sub_potential._get_component_list('NBLT')
target_atom_ids = [component[0] for component in components]
xcamshift._prepare(TARGET_ATOM_IDS_CHANGED,target_atom_ids)
xcamshift._prepare(ROUND_CHANGED,None)
non_bonded_components = dict(gb3.gb3_component_shifts_non_bonded)
target_components = sub_potential._get_component_list('ATOM')
remote_components = sub_potential._get_component_list('NBRM')
for i,(target_atom_id, target_index, remote_index, component_index) in enumerate(components):
target_atom_id = target_components[target_index][0]
target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
remote_atom_id = remote_components[remote_index][0]
remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)
if target_atom_key[2]== 'HA1':
target_atom_key = list(target_atom_key)
target_atom_key[2]= 'HA'
target_atom_key = tuple(target_atom_key)
if Atom_utils._calculate_distance(target_atom_id, remote_atom_id) > 5.0:
continue
shift = sub_potential._calc_component_shift(i)
expected_shift = 0.0
seen_keys = []
for exponent_key in 0,1:
non_bonded_component_key = (target_atom_key, remote_atom_key, exponent_key)
seen_keys.append(non_bonded_component_key)
expected_shift += non_bonded_components[non_bonded_component_key]
self.assertAlmostEqual(shift,expected_shift,self.DEFAULT_DECIMAL_PLACES-2,`i` + ' ' + `non_bonded_component_key`)
for seen_key in seen_keys:
del non_bonded_components[seen_key]
self.assertEmpty(non_bonded_components)
示例6: get_key_for_atom_index
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def get_key_for_atom_index(atom_id):
atom_key = Atom_utils._get_atom_info_from_index(atom_id)
atom_key = translate_atom_key(atom_key)
return atom_key
示例7: _test_force_sets
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def _test_force_sets(self, xcamshift, expected_energy, expected_forces):
expected_forces = dict(expected_forces)
number_atoms = Segment_Manager().get_number_atoms()
derivs = DerivList()
derivs.init(self.get_single_member_ensemble_simulation())
energy = xcamshift.calcEnergyAndDerivs(derivs)
derivs = self.deriv_list_as_array(derivs, self.get_single_member_ensemble_simulation())
for atom_id in range(number_atoms):
atom_key = Atom_utils._get_atom_info_from_index(atom_id)
if atom_key in expected_forces:
force_triplet = derivs[atom_id]
if force_triplet == None:
force_triplet = (0.0,0.0,0.0)
expected_force_triplet = expected_forces[atom_key]
self.assertSequenceAlmostEqual(force_triplet, expected_force_triplet, self.DEFAULT_DECIMAL_PLACES)
del expected_forces[atom_key]
self.remove_almost_zero_force_elems(expected_forces, self.DEFAULT_DECIMAL_PLACES)
self.assertEmpty(expected_forces)
#TODO: improve accuracy of test energy
self.assertAlmostEqual(energy, expected_energy, self.DEFAULT_DECIMAL_PLACES-1)
示例8: dump_observed_shifts
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def dump_observed_shifts(self):
results = []
for atom_index in self._chemical_shifts:
sub_result = []
results.append(sub_result)
sub_result.append(Atom_utils._get_atom_info_from_index(atom_index))
sub_result.append(self._chemical_shifts[atom_index])
return tupleit(results)
示例9: test_component_shifts_ring
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def test_component_shifts_ring(self):
xcamshift = self._get_xcamshift()
xcamshift._prepare(TARGET_ATOM_IDS_CHANGED, xcamshift._get_all_component_target_atom_ids())
xcamshift._prepare(ROUND_CHANGED,None)
ring_subpotential = xcamshift.get_named_sub_potential(RING)
expected_ring_shifts = dict(gb3_component_shifts_ring)
expected_component_keys = expected_ring_shifts.keys()
for component_index, component in enumerate(ring_subpotential._get_component_list()):
from_atom_id, atom_type_id = component
from_atom_info_list = ring_subpotential._get_component_list('COEF').get_components_for_atom_id(atom_type_id)
# print Atom_utils._get_atom_info_from_index(from_atom_id), from_atom_info_list
from_atom_key = list(Atom_utils._get_atom_info_from_index(from_atom_id))
if from_atom_key[2] == 'HA1':
from_atom_key[2] = 'HA'
from_atom_key = tuple(from_atom_key)
for sub_component_index, from_atom_info in enumerate(from_atom_info_list):
from_atom_type, ring_id, coefficent = from_atom_info
ring_info = ring_subpotential._get_component_list('RING').get_components_for_atom_id(ring_id)
ring_atoms = ring_info[0][1]
ring_residue_type = Atom_utils._get_residue_type_from_atom_id(ring_atoms[1])
ring_residue = Atom_utils._get_atom_info_from_index(ring_atoms[0])[1]
expected_key = from_atom_key,(ring_residue,ring_residue_type,len(ring_atoms))
self.assertIn(expected_key, expected_component_keys, `expected_key`)
shift = ring_subpotential._shift_calculator._calc_sub_component_shift(from_atom_id, ring_id,coefficent)
self.assertAlmostEqual(expected_ring_shifts[expected_key], shift, places=self.DEFAULT_DECIMAL_PLACES - 2, msg=`expected_key`)
if abs(expected_ring_shifts[expected_key] - shift) > 0.001:
print 'fail', expected_key, expected_ring_shifts[expected_key], shift, Atom_utils._get_residue_type_from_atom_id(from_atom_id)
print
del expected_ring_shifts[expected_key]
self.remove_zero_valued_keys(expected_ring_shifts)
self.assertEmpty(expected_ring_shifts)
示例10: test_non_bonded_components
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def test_non_bonded_components(self):
#TODO: add common loading method for xcamshift
print 'WARNING using zero shifts with test_non_bonded_components as a hack to get _active_target_atom_ids correct!'
xcamshift = self._setup_xcamshift_with_shifts_table(gb3.gb3_zero_shifts)
sub_potential = xcamshift.get_named_sub_potential(NON_BONDED)
xcamshift._prepare(TARGET_ATOM_IDS_CHANGED,None)
xcamshift._prepare(ROUND_CHANGED,None)
components = sub_potential._get_component_list('NBLT')
non_bonded_components = dict(gb3.gb3_component_shifts_non_bonded)
target_components = sub_potential._get_component_list('ATOM')
remote_components = sub_potential._get_component_list('NBRM')
for target_atom_id, target_index, remote_index, component_index in components:
target_atom_id = target_components[target_index][0]
target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
remote_atom_id = remote_components[remote_index][0]
remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)
if target_atom_key[2]== 'HA1':
target_atom_key = list(target_atom_key)
target_atom_key[2]= 'HA'
target_atom_key = tuple(target_atom_key)
if Atom_utils._calculate_distance(target_atom_id, remote_atom_id) > 5.0:
continue
for exponent_key in 0,1:
non_bonded_component_key = (target_atom_key, remote_atom_key, exponent_key)
self.assertIn(non_bonded_component_key, non_bonded_components, `non_bonded_component_key`)
del non_bonded_components[non_bonded_component_key]
self.assertEmpty(non_bonded_components)
示例11: test_calc_component_shift
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def test_calc_component_shift(self):
ring_potential = self.make_ring_potential()
self._prepare_potential(ring_potential)
target_components = self._get_potential_target_components(ring_potential)
for i, component in enumerate(target_components):
component_shift = ring_potential._calc_component_shift(i)
#TODO: this looks inside the object too much
atom_id = component[0]
atom_key = Atom_utils._get_atom_info_from_index(atom_id)
expected_shift = AFA.expected_ring_shifts[atom_key]
#TODO: is the difference in error down to coordinates?
self.assertAlmostEqual(component_shift, expected_shift, places=self.DEFAULT_DECIMAL_PLACES)
示例12: print_force_component_diffs
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def print_force_component_diffs(self, potential_name, target_atom_key, expected_forces, result_forces):
diffs = []
for i, (result_force, expected_force) in enumerate(zip(result_forces, expected_forces)):
if result_force == None and expected_force == None:
continue
if (result_force == None) and (max(expected_force) < 0.0000001):
continue
if (expected_force == None) and (max(result_force) < 0.0000001):
continue
if result_force == None or expected_force == None:
print 'BAD!', potential_name, i, target_atom_key, Atom_utils._get_atom_info_from_index(i),result_force,expected_force
continue
# print 'here', result_force, expected_force
current_diffs = []
for num_1,num_2 in zip(result_force,expected_force):
# print num_1,num_2,abs(num_1-num_2)
diffs.append(abs(num_1-num_2))
current_diffs.append(abs(num_1-num_2))
if max(current_diffs) > 0.01:
print 'BAD!!', potential_name, i, target_atom_key, Atom_utils._get_atom_info_from_index(i),max(current_diffs),result_force,expected_force
continue
else:
print 'OK!!'
示例13: _test_non_bonded_force_factors
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def _test_non_bonded_force_factors(self, non_bonded_potential, non_bonded_force_factors, active_shifts, factors):
components = dict(non_bonded_potential._get_components())
nb_interaction_list = components['NBLT']
active_array = allocate_array(1,'i')
components['ACTI'] = active_array
components['OFFS'] = 0
non_bonded_potential._force_calculator._set_components(components)
for i, component in enumerate(nb_interaction_list):
zero_array(active_array)
active_array[0] = i
target_atom_id = non_bonded_potential._get_component_list('ATOM')[component[1]][0]
remote_atom_id = non_bonded_potential._get_component_list('NBRM')[component[2]][0]
target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
remote_atom_key = Atom_utils._get_atom_info_from_index(remote_atom_id)
if active_shifts[target_atom_key] == 0:
continue
#
distance = Atom_utils._calculate_distance(target_atom_id, remote_atom_id)
if distance < 5.0:
for exponent_index, exponent in enumerate((1,-3)):
expected_key = target_atom_key, remote_atom_key, int(exponent)
factor = factors[target_atom_key]
non_bonded_potential._force_calculator._build_component(i,exponent_index)
force_factor = non_bonded_potential._force_calculator._calc_single_force_factor(0, factor)
#TODO: check change from 7 to 5 dp is ok
self.assertAlmostEqual(force_factor, non_bonded_force_factors[expected_key],places=self.DEFAULT_DECIMAL_PLACES)
del non_bonded_force_factors[expected_key]
self.assertEmpty(non_bonded_force_factors)
示例14: test_calc_component_forces
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def test_calc_component_forces(self):
ring_potential = self.make_ring_potential()
ring_potential._setup_ring_calculator(ring_potential._force_calculator)
ring_potential._force_calculator._set_components(ring_potential._get_components())
for target_atom_id,atom_type_id in ring_potential._get_component_list('ATOM'):
for ring_id,ring_atom_ids in ring_potential._get_component_list('RING'):
target_atom_key = Atom_utils._get_atom_info_from_index(target_atom_id)
force_factor_key = target_atom_key
force_factor = AFA.force_factors_harmonic[force_factor_key]
#TODO: these should not be needed
ring_potential._get_component_list('RING')
ring_potential._build_ring_data_cache()
out_array = self.make_out_array()
force_terms = ring_potential._force_calculator._build_force_terms(target_atom_id, ring_id)
ring_potential._force_calculator._calc_target_atom_forces(target_atom_id, force_factor, force_terms, out_array)
forces =out_array.add_forces_to_result()
target_atom_forces = forces[target_atom_id]
expected_forces = AFA.target_forces_harmonic[force_factor_key]
self.assertSequenceAlmostEqual(target_atom_forces, expected_forces, self.DEFAULT_DECIMAL_PLACES)
out_array = self.make_out_array()
ring_potential._force_calculator._calculate_ring_forces(atom_type_id, ring_id, force_factor, force_terms, out_array)
forces =out_array.add_forces_to_result()
for ring_atom_id in ring_atom_ids:
ring_atom_key = Atom_utils._get_atom_info_from_index(ring_atom_id)
ring_force_key =target_atom_key,ring_atom_key
expected_ring_forces = AFA.ring_forces_harmonic[ring_force_key]
ring_atom_forces = forces[ring_atom_id]
self.assertSequenceAlmostEqual(ring_atom_forces, expected_ring_forces, self.DEFAULT_DECIMAL_PLACES)
示例15: test_component_shifts_bb
# 需要导入模块: from utils import Atom_utils [as 别名]
# 或者: from utils.Atom_utils import _get_atom_info_from_index [as 别名]
def test_component_shifts_bb(self):
xcamshift = self._get_xcamshift()
bb_subpotential = xcamshift.get_named_sub_potential(BACK_BONE)
expected_bb_shifts = dict(aga_component_shifts_bb)
expected_component_keys = expected_bb_shifts.keys()
for component_index, component in enumerate(bb_subpotential._get_component_list()):
from_atom_id, to_atom_id = component[0:2]
from_atom_key = Atom_utils._get_atom_info_from_index(from_atom_id)
to_atom_key = Atom_utils._get_atom_info_from_index(to_atom_id)
expected_key = from_atom_key, to_atom_key
# distance = Atom_utils._calculate_distance(from_atom_id, to_atom_id)
self.assertIn(expected_key, expected_component_keys, `expected_key` + " exists")
shift = bb_subpotential._calc_component_shift(component_index)
# print expected_key,aga_component_shifts_bb[expected_key],shift
self.assertAlmostEqual(expected_bb_shifts[expected_key], shift, places=self.DEFAULT_DECIMAL_PLACES - 1)
del expected_bb_shifts[expected_key]
self.remove_zero_valued_keys(expected_bb_shifts)