当前位置: 首页>>代码示例>>Python>>正文


Python utils.Atom_utils类代码示例

本文整理汇总了Python中utils.Atom_utils的典型用法代码示例。如果您正苦于以下问题:Python Atom_utils类的具体用法?Python Atom_utils怎么用?Python Atom_utils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Atom_utils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testNonBondedComponents

    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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:25,代码来源:test_xcamshift_a4.py

示例2: test_component_shifts_sidechain

    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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:29,代码来源:test_xcamshift_gb3.py

示例3: _test_non_bonded_shifts

    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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:29,代码来源:test_xcamshift_a4.py

示例4: _test_non_bonded_forces

    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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:59,代码来源:test_xcamshift_a4.py

示例5: get_atom_index

    def get_atom_index(self, key):
        residue_type = Atom_utils._get_residue_type(key[0], key[1])

        atom_name = key[2]

        residue_key = list(key)
        residue_key[2] =  self.translations.setdefault((residue_type,atom_name),atom_name)
        residue_key = tuple(residue_key)

        target_atom_index = Atom_utils.find_atom(*residue_key)[0].index()
        return target_atom_index
开发者ID:locsmith,项目名称:xcamshift,代码行数:11,代码来源:timings.py

示例6: test_non_bonded_component_shifts

    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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:48,代码来源:test_xcamshift_gb3.py

示例7: get_key_for_atom_index

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
开发者ID:locsmith,项目名称:xcamshift,代码行数:7,代码来源:util_for_testing.py

示例8: _test_force_sets

    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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:27,代码来源:test_xcamshift_a4.py

示例9: _do_test_component_shifts

    def _do_test_component_shifts(self, xcamshift, component_shifts):
        xcamshift._prepare(TARGET_ATOM_IDS_CHANGED, None)
        xcamshift._prepare(ROUND_CHANGED, None)
        component_shifts_keys = component_shifts.keys()
        component_shifts_keys.sort()
        for i, key in enumerate(component_shifts_keys):
            segment, residue_number, atom, sub_potential = key
            sub_potential = xcamshift.get_named_sub_potential(sub_potential)
            atom_ids = Atom_utils.find_atom_ids(segment, residue_number, atom)
            if len(atom_ids) > 0:

                xcamshift._prepare(TARGET_ATOM_IDS_CHANGED, atom_ids)
                shift = sub_potential._calc_single_atom_shift(atom_ids[0])
                expected_shift = component_shifts[key]
                residue_type = Atom_utils._get_residue_type_from_atom_id(atom_ids[0])
                self.assertAlmostEqual(shift, expected_shift, self.DEFAULT_DECIMAL_PLACES - 2, msg=`key` + " " + residue_type)
开发者ID:locsmith,项目名称:xcamshift,代码行数:16,代码来源:test_xcamshift_gb3.py

示例10: testDisulphidePotential

    def testDisulphidePotential(self):
        initStruct("test_data/acaggaca/acaggaca.psf") 
        
        disulphide_calculator = Disulphide_shift_calculator(self.get_single_member_ensemble_simulation())
        result = self.make_result_array() 
        expected  = self.make_result_array()
        for elem in acaggaca_ss_shifts:
            index = Atom_utils.find_atom_ids(*elem)[0]
            expected[index] += acaggaca_ss_shifts[elem]
        
        for elem in acaggaca_ss_sidechain_corrections:
            index = Atom_utils.find_atom_ids(*elem)[0]
            expected[index] -= acaggaca_ss_shifts[elem]

        disulphide_calculator.set_shifts(result)
        self.assertSequenceAlmostEqual(expected, result, self.DEFAULT_DECIMAL_PLACES)
开发者ID:locsmith,项目名称:xcamshift,代码行数:16,代码来源:test_xcamshift_acaggaca.py

示例11: testDisulphideComponents

 def testDisulphideComponents(self):
     
     disulphide_calculator = Disulphide_shift_calculator(self.get_single_member_ensemble_simulation())
     components = disulphide_calculator._get_component_list('ATOM')
     
     expected = [(Atom_utils.find_atom_ids(*elem)[0],acaggaca_ss_shifts[elem]) for elem in acaggaca_ss_shifts]
     expected.sort()  
     self.assertSequenceEqual([elem[0] for elem in components], [elem[0] for elem in expected])
开发者ID:locsmith,项目名称:xcamshift,代码行数:8,代码来源:test_xcamshift_acaggaca.py

示例12: dump_observed_shifts

 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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:8,代码来源:observed_chemical_shifts.py

示例13: test_component_shifts_ring

    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)
开发者ID:locsmith,项目名称:xcamshift,代码行数:43,代码来源:test_xcamshift_gb3.py

示例14: test_ring_bb_atoms

    def test_ring_bb_atoms(self):
        ring_potential = self.make_ring_potential()



        ring_table = Table_manager.get_default_table_manager().get_ring_table('PHE')
        target_atoms = ring_table.get_target_atoms()

        all_component_names = ring_potential._get_component_list('ATOM').get_all_components()
        all_component_names_index = dict((i,atom_name) for i,atom_name in enumerate(target_atoms))
        for atom_id,atom_type_id in all_component_names:
            segment,residue_number,atom_name = Atom_utils._get_atom_info_from_index(atom_id)
            self.assertEqual(segment, '')
            self.assertEqual(residue_number, 2)
            atom_name  = Atom_utils._get_atom_name_from_index(atom_id)
            self.assertEqual(all_component_names_index[atom_type_id], atom_name)

            del all_component_names_index[atom_type_id]
        self.assertEmpty(all_component_names_index)
开发者ID:locsmith,项目名称:xcamshift,代码行数:19,代码来源:test_xcamshift_afa.py

示例15: translate_atom_key

def translate_atom_key(atom_key):
    global inverted_translations
    if inverted_translations == None:
        inverted_translations = invert_translations(translations)
    res_type = Atom_utils._get_residue_type(*atom_key[:2])
    key = res_type, atom_key[2]
    if key in inverted_translations:
        atom_key = list(atom_key)
        atom_key[2] = inverted_translations[key]
        atom_key = tuple(atom_key)
    return atom_key
开发者ID:locsmith,项目名称:xcamshift,代码行数:11,代码来源:util_for_testing.py


注:本文中的utils.Atom_utils类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。