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


Python cmd.count_atoms函数代码示例

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


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

示例1: testCifMissing

    def testCifMissing(self):
        N = 7
        cmd.fragment('gly', 'm1')
        cmd.alter('all', '(chain, segi, resv, alt) = ("?", ".", 5, "")')

        s = cmd.get_str('cif')
        self.assertTrue("'?'" in s or '"?"' in s) # chain
        self.assertTrue("'.'" in s or '"."' in s) # segi
        self.assertTrue(' ? ' in s) # e.g. pdbx_PDB_ins_code
        self.assertTrue(' . ' in s) # e.g. label_alt_id

        cmd.delete('*')
        cmd.set('cif_keepinmemory')
        cmd.load(s, 'm2', format='cifstr')
        self.assertEqual(['?'], cmd.get_chains())
        self.assertEqual(cmd.count_atoms('segi .'), N)
        self.assertEqual(cmd.count_atoms('alt ""'), N)  # no alt
        self.assertEqual(cmd.count_atoms('resi 5'), N)  # no ins_code

        from pymol.querying import cif_get_array
        self.assertEqual(cif_get_array("m2", "_atom_site.type_symbol"), list('NCCOHHH'))
        self.assertEqual(cif_get_array("m2", "_atom_site.id", "i"),     list(range(1, N + 1)))
        self.assertEqual(cif_get_array("m2", "_atom_site.auth_asym_id"),        ['?'] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.label_asym_id"),       ['.'] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.pdbx_pdb_ins_code"),   [None] * N)
        self.assertEqual(cif_get_array("m2", "_atom_site.label_alt_id"),        [None] * N)
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:26,代码来源:importing.py

示例2: test_polyala

def test_polyala():
    cmd.reinitialize()
    cmd.fab('EFG', 'm1')
    psico.editing.polyala()
    assert cmd.count_atoms('name CA') == 3
    assert cmd.count_atoms('name CB') == 2
    assert cmd.count_atoms('name CG+CD+CD1+CD2+2HG+3HG+1HD+2HD') == 0
开发者ID:speleo3,项目名称:pymol-psico,代码行数:7,代码来源:test_editing.py

示例3: testUndoAfterRemoveAtomOnDiscrete

 def testUndoAfterRemoveAtomOnDiscrete(self, discr):
     cmd.set('suspend_undo', 0)
     cmd.load(self.datafile('ligs3d.sdf'), discrete=discr)
     natms = cmd.count_atoms()
     cmd.remove("index 1")
     cmd.undo()
     self.assertEqual(natms, cmd.count_atoms())
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:7,代码来源:PYMOL-1697.py

示例4: testMultifilesave

    def testMultifilesave(self):
        import glob

        for name in ['ala', 'gly', 'his', 'arg']:
            cmd.fragment(name)

        # multistate
        for i in range(2, 11):
            cmd.create('ala', 'ala', 1, i)

        for fmt in ['{}-{:02}.cif', '{}-{state}.cif']:
            with testing.mkdtemp() as dirname:
                cmd.multifilesave(os.path.join(dirname, fmt), 'ala', 0)
                filenames = [os.path.basename(p) for p in glob.glob(os.path.join(dirname, '*.cif'))]
                self.assertEqual(len(filenames), 10)
                self.assertTrue('ala-03.cif' in filenames)

        with testing.mkdtemp() as dirname:
            cmd.multifilesave(os.path.join(dirname, '{}.pdb'), 'a* g*')
            filenames_full = sorted(glob.glob(os.path.join(dirname, '*.pdb')))
            filenames = [os.path.basename(p) for p in filenames_full]
            self.assertEqual(filenames, ['ala.pdb', 'arg.pdb', 'gly.pdb'])

            cmd.delete('*')
            cmd.load(filenames_full[0])
            self.assertEqual(cmd.count_atoms(), 10)

            cmd.delete('*')
            cmd.load(filenames_full[1])
            self.assertEqual(cmd.count_atoms(), 24)
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:30,代码来源:exporting.py

示例5: testLoadAlnMatchingIds

 def testLoadAlnMatchingIds(self):
     cmd.fab('ACDEFGHIKLMNPQRS', 'seq1')
     cmd.fab('ACDIKLMNP', 'seq2')
     cmd.fab('GHIKPQRS', 'seq3')
     cmd.load(self.datafile('alignment.aln'), 'aln')
     self.assertEqual(cmd.count_atoms('guide & aln & seq1'), 11)
     self.assertEqual(cmd.count_atoms('guide & aln & seq2'), 7)
     self.assertEqual(cmd.count_atoms('guide & aln & seq3'), 6)
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:8,代码来源:seqalign.py

示例6: test_attach

 def test_attach(self):
     cmd.pseudoatom()
     cmd.edit('first all')
     cmd.attach('C', 1, 1)
     self.assertEqual(2, cmd.count_atoms())
     cmd.attach('C', 1, 1)
     self.assertEqual(3, cmd.count_atoms())
     self.assertEqual(['C01', 'C02', 'PS1'], sorted(get_atom_names()))
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:8,代码来源:editing.py

示例7: test_protein_nucleic

 def test_protein_nucleic(self):
     npro = 340
     nnuc = 112
     cmd.load(self.datafile("1oky-frag.pdb"), "1p")
     cmd.load(self.datafile('1ehz-5.pdb'), "1n")
     self.assertEqual(cmd.count_atoms('polymer'), npro + nnuc)
     self.assertEqual(cmd.count_atoms('polymer.protein'), npro)
     self.assertEqual(cmd.count_atoms('polymer.nucleic'), nnuc)
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:8,代码来源:selecting.py

示例8: testLoadMMTF

 def testLoadMMTF(self):
     cmd.load(self.datafile("3njw.mmtf.gz"))
     self.assertEqual(169, cmd.count_atoms())
     self.assertEqual(36, cmd.count_atoms('ss S'))
     self.assertEqual(25, cmd.count_atoms('solvent'))
     symmetry = cmd.get_symmetry()
     self.assertArrayEqual(symmetry[:6], [19.465, 21.432, 29.523, 90.0, 90.0, 90.0], delta=1e-4)
     self.assertEqual(symmetry[6], 'P 21 21 21')
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:8,代码来源:importing.py

示例9: runStride

    def runStride(self):
        """
        """
        # delete old results
        self.sel_obj_list = []
        self.stride_rlt_dict = {}
        self.SSE_res_dict = {}
        self.SSE_sel_dict = {}

        pdb_fn = None
        sel_name = None
        sel = self.pymol_sel.get()

        if len(sel) > 0:  # if any pymol selection/object is specified
            all_sel_names = cmd.get_names('all')  # get names of all selections
            if sel in all_sel_names:
                if cmd.count_atoms(sel) == 0:
                    err_msg = 'ERROR: The selection %s is empty.' % (sel,)
                    print('ERROR: %s' % (err_msg,))
                    tkMessageBox.showinfo(title='ERROR', message=err_msg)
                    return False
                else:
                    sel_name = sel
            # no selection/object with the input name is found
            # we assume either a single-word selector or
            # some other selection-expression is uesd
            else:
                print('The selection/object you specified is not found.')
                print('Your input will be interpreted as a selection-expression.')
                tmpsel = self.randomSeleName(prefix='your_sele_')
                cmd.select(tmpsel, sel)
                if cmd.count_atoms(tmpsel) == 0:
                    cmd.delete(tmpsel)
                    err_msg = 'ERROR: The selection %s is empty.' % (sel,)
                    print('ERROR: %s' % (err_msg,))
                    tkMessageBox.showinfo(title='ERROR', message=err_msg)
                    return False
                else:
                    sel_name = tmpsel

        else:   # what structure do you want Stride to work on?
            err_msg = 'No PyMOL selection/object specified!'
            print('ERROR: %s' % (err_msg,))
            tkMessageBox.showinfo(title='ERROR', message=err_msg)
            return False

        # each object in the selection is treated as an independent struc
        objlist = cmd.get_object_list(sel_name)
        self.ss_asgn_prog = 'Stride'
        print('Starting %s ...' % (self.ss_asgn_prog, ))

        for objname in objlist:
            self.sel_obj_list.append('%s and %s' % (sel_name, objname))
            self.runStrideOneObj(self.sel_obj_list[-1])

        return True
开发者ID:Pymol-Scripts,项目名称:Pymol-script-repo,代码行数:56,代码来源:dssp_stride.py

示例10: fSumWMCLast

def fSumWMCLast(molecule, SGNameAngle, chain, residue, MCNeighbour, DieElecMC, MCchargeN, MCchargeH, MCchargeProCA, MCchargeProCD, MCchargeProN, AmideName, printMC):
	#print "Last", MCNeighbour
	SumWMCLast = 0.0
	SGnameselect = "/"+SGNameAngle+"//"+"/"+"/SG"
	NBnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)
	cmd.select("MC", NBnameselect)
	MCpdbstr = cmd.get_pdbstr("MC")
	MCsplit = MCpdbstr.split()
	residueName = MCsplit[3]
	#print NBnameselect, residueName
	if residueName == "PRO":
		### Proline CA
		CAnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/CA"
		ResDist = cmd.dist(residue+'distLastProCA', SGnameselect,CAnameselect)
		WMC = fWMC(MCchargeProCA, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC ProCA ", MCNeighbour, " ", MCchargeProCA, " ", DieElecMC, " ", ResDist, " ", WMC
		### Proline CD
		CDnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/CD"
		ResDist = cmd.dist(residue+'distLastProCD', SGnameselect,CDnameselect)
		WMC = fWMC(MCchargeProCD, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC ProCD ", MCNeighbour, " ", MCchargeProCD, " ", DieElecMC, " ", ResDist, " ", WMC
		### Proline N
		Nnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/N"
		ResDist = cmd.dist(residue+'distLastProN', SGnameselect,Nnameselect)
		WMC = fWMC(MCchargeProN, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC ProN ", MCNeighbour, " ", MCchargeProN, " ", DieElecMC, " ", ResDist, " ", WMC
	else:
		AmideProt = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/H01"
		Hnameselect = "/"+AmideName+"//"+chain+"/"+str(MCNeighbour)+"/H01"
		if cmd.count_atoms(AmideProt) == 0 and cmd.count_atoms(Hnameselect) == 0:
			HbuildSelect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/N"
			cmd.h_add(HbuildSelect)
			cmd.create(AmideName, AmideName+" + "+AmideProt)
			cmd.remove(AmideProt)
		### Mainchain AmideH
		ResDist = cmd.dist(residue+'distLastH', SGnameselect,Hnameselect)
		WMC = fWMC(MCchargeH, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC H ", MCNeighbour, " ", MCchargeH, " ", DieElecMC, " ", ResDist, " ", WMC
		### Mainchain N
		Nnameselect = "/"+molecule+"//"+chain+"/"+str(MCNeighbour)+"/N"
		ResDist = cmd.dist(residue+'distLastN', SGnameselect,Nnameselect)
		WMC = fWMC(MCchargeN, DieElecMC, ResDist)
		SumWMCLast = SumWMCLast + WMC
		if printMC == 'yes': print "MC N ", MCNeighbour, " ", MCchargeN, " ", DieElecMC, " ", ResDist, " ", WMC
	cmd.delete(residue+'distLastProCA')
	cmd.delete(residue+'distLastProCD')
	cmd.delete(residue+'distLastProN')
	cmd.delete(residue+'distLastH')
	cmd.delete(residue+'distLastN')
	cmd.show("nb_spheres", AmideName)
	cmd.delete("MC")
	return SumWMCLast
开发者ID:8848,项目名称:Pymol-script-repo,代码行数:56,代码来源:cyspka.py

示例11: test_remove_alt

def test_remove_alt():
    cmd.reinitialize()
    cmd.fab('AC', 'm1')
    cmd.alter('resn ALA', 'alt="A"')
    cmd.alter('resn CYS', 'alt="B"')
    cmd.create('m2', 'm1')
    psico.editing.remove_alt('m1')
    psico.editing.remove_alt('m2', keep='B')
    assert cmd.count_atoms('m1') == 10
    assert cmd.count_atoms('m2') == 11
开发者ID:speleo3,项目名称:pymol-psico,代码行数:10,代码来源:test_editing.py

示例12: testShow

    def testShow(self):
        if testing.PYMOL_VERSION[1] > 1.84:
            cmd.set('auto_show_classified', 0)

        cmd.fragment('ala')
        self.assertEqual(cmd.count_atoms('rep sticks'), 0)
        cmd.show('sticks')
        self.assertEqual(cmd.count_atoms('rep sticks'), 10)
        cmd.hide('lines', 'not elem C')
        self.assertEqual(cmd.count_atoms('rep lines'), 3)
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:10,代码来源:viewing.py

示例13: testNumeric

 def testNumeric(self):
     cmd.fragment('ala')
     cmd.alter_state(1, 'all', 'p.x, p.y, p.index = x, y, index')
     cmd.select('sele_p_x', 'p.x < 0')
     cmd.select('sele_p_y', 'p.y > 0')
     cmd.select('sele_p_i', 'p.index = 3')
     cmd.select('sele_x', 'x < 0.0')
     cmd.select('sele_y', 'y > 0.0')
     cmd.select('sele_i', 'index 3')
     counts = [
         cmd.count_atoms('sele_p_x'),
         cmd.count_atoms('sele_x'),
         cmd.count_atoms('sele_x & sele_p_x'),
     ]
     self.assertEqual(counts[0], 8)
     self.assertEqual(counts[0], counts[1])
     self.assertEqual(counts[0], counts[2])
     counts = [
         cmd.count_atoms('sele_p_y'),
         cmd.count_atoms('sele_y'),
         cmd.count_atoms('sele_y & sele_p_y'),
     ]
     self.assertEqual(counts[0], 6)
     self.assertEqual(counts[0], counts[1])
     self.assertEqual(counts[0], counts[2])
     counts = [
         cmd.count_atoms('sele_i'),
         cmd.count_atoms('sele_p_i'),
         cmd.count_atoms('sele_i & sele_p_i'),
     ]
     self.assertEqual(counts[0], 1)
     self.assertEqual(counts[0], counts[1])
     self.assertEqual(counts[0], counts[2])
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:33,代码来源:test_select.py

示例14: testSdfV3000

    def testSdfV3000(self):
        cmd.load(self.datafile('1rx1.pdb'))
        with testing.mktemp('.sdf') as filename:
            cmd.save(filename)
            cmd.delete('*')
            cmd.load(filename)
        self.assertEqual(cmd.count_atoms(), 1435)

        # check for capitalized element symbols
        cmd.set('ignore_case', 0)
        self.assertEqual(cmd.count_atoms('elem Ca'), 1)
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:11,代码来源:PYMOL-1840.py

示例15: test_load_hypothesis_phypo

 def test_load_hypothesis_phypo(self):
     from epymol import ph4
     ph4.load_phypo(
             self.datafile('phase/ADHHRR_1_trans.phypo'),
             'g1', zoom=-1, mimic=1, atom_props='', _self=cmd)
     self.assertEqual(cmd.count_atoms('g1.ADHHRR_1 and name A2+H6'), 2)
     self.assertEqual(cmd.count_atoms('g1.endo-1'), 35)
     self.assertEqual(cmd.count_atoms('g1.endo-2'), 37)
     self.assertEqual(cmd.count_atoms('g1.endo-36'), 28)
     self.assertEqual(cmd.count_atoms('g1.ADHHRR_1_xvol'), 936)
     self.assertTrue('g1.ADHHRR_1_cgo' in cmd.get_names_of_type('object:cgo'))
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:11,代码来源:epymol_ph4.py


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