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


Python cmd.alter函数代码示例

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


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

示例1: test_sets_ranges

 def test_sets_ranges(self):
     cmd.fab('ACDEFGHIKL')
     cmd.alter('resi 9', 'resi="9A"') # insertion code
     self.assertEqual(3, cmd.count_atoms('guide & resi 2-4'))
     self.assertEqual(3, cmd.count_atoms('guide & resi 2:4'))
     self.assertEqual(2, cmd.count_atoms('guide & resi 2+4'))
     self.assertEqual(4, cmd.count_atoms('guide & resi 2-4+6'))
     self.assertEqual(6, cmd.count_atoms('guide & resi 2-4+6-8'))
     self.assertEqual(0, cmd.count_atoms('guide & resi 9'))
     self.assertEqual(1, cmd.count_atoms('guide & resi 9A'))
     self.assertEqual(1, cmd.count_atoms('guide & resi 10'))
     self.assertEqual(0, cmd.count_atoms('guide & resi 10A'))
     self.assertEqual(2, cmd.count_atoms('guide & resi 9-10'))
     self.assertEqual(2, cmd.count_atoms('guide & resi 9A-10A'))
     self.assertEqual(10 + 9, cmd.count_atoms('name CA+CB'))
     self.assertEqual(10 + 9, cmd.count_atoms('name CA+CB+XYZ'))
     self.assertEqual(10, cmd.count_atoms('name C'))
     self.assertEqual(50, cmd.count_atoms('name C*'))
     self.assertEqual(10, cmd.count_atoms('name H'))
     self.assertEqual(24, cmd.count_atoms('name H*'))
     self.assertEqual(10, cmd.count_atoms('name *H'))
     self.assertEqual(74, cmd.count_atoms('name *H*'))
     self.assertEqual(20, cmd.count_atoms('name C+N'))
     self.assertEqual(23, cmd.count_atoms('name C+N*'))
     self.assertEqual(60, cmd.count_atoms('name C*+N'))
     self.assertEqual(63, cmd.count_atoms('name C*+N*'))
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:26,代码来源:selecting.py

示例2: loadBfacts

def loadBfacts (mol,startaa=1,source="/Users/student/Box Sync/PUBS/Pymol-practice.txt", visual="Y"):
	"""
	Replaces B-factors with a list of values contained in a plain txt file
 
	usage: loadBfacts mol, [startaa, [source, [visual]]]
 
	mol = any object selection (within one single object though)
	startaa = number of first amino acid in 'new B-factors' file (default=1)
	source = name of the file containing new B-factor values (default=newBfactors.txt)
	visual = redraws structure as cartoon_putty and displays bar with min/max values (default=Y)
 
	example: loadBfacts 1LVM and chain A
	"""
	obj=cmd.get_object_list(mol)[0]
	cmd.alter(mol,"b=-1.0")
	inFile = open(source, 'r')
	counter=int(startaa)
	bfacts=[]
	for line in inFile.readlines():	
		bfact=float(line)
		bfacts.append(bfact)
		cmd.alter("%s and resi %s and n. CA"%(mol,counter), "b=%s"%bfact)
		counter=counter+1
	if visual=="Y":
		cmd.show_as("cartoon",mol)
		cmd.cartoon("putty", mol)
		cmd.set("cartoon_putty_scale_min", min(bfacts),obj)
		cmd.set("cartoon_putty_scale_max", max(bfacts),obj)
		cmd.set("cartoon_putty_transform", 0,obj)
		cmd.set("cartoon_putty_radius", 0.2,obj)
		cmd.spectrum("b","rainbow", "%s and n. CA " %mol)
		cmd.ramp_new("count", obj, [min(bfacts), max(bfacts)], "rainbow")
		cmd.recolor()
开发者ID:yuliyabirman,项目名称:pynd-pubs,代码行数:33,代码来源:pymol_fitness.py

示例3: useOccRadii

def useOccRadii(sel="all"):
	for a in cmd.get_model(sel).atom:
		q = a.q
		if q >= 3:
			print "shrik radius"
			q <- 0.1
		cmd.alter("%s and resi %s and name %s"%(sel,a.resi,a.name),"vdw=%f"%(q))
开发者ID:willsheffler,项目名称:lib,代码行数:7,代码来源:setRadii.py

示例4: testExportStyle

    def testExportStyle(self):
        cmd.fab('ACDEF', 'm1')
        cmd.hide()
        cmd.show('cartoon', 'resi 1-3')
        cmd.show('lines', 'resn CYS')
        cmd.show('sticks', 'resn ASP+PHE')
        cmd.show('spheres', 'resn GLU')
        cmd.set('stick_ball', 1, 'resn PHE')
        cmd.set('stick_ball_ratio', 1.5, 'm1')
        testlabel = 'Hello "World"'
        cmd.label('name SG', repr(testlabel))

        with testing.mktemp('.mae') as filename:
            cmd.save(filename)
            cmd.delete('*')
            cmd.load(filename, 'm2')

        g_labels = []
        cmd.iterate('name SG', 'g_labels.append(label)', space=locals())
        cmd.alter('*', 'b = 1 if s.stick_ball else 0')

        self._assertCountEqual('rep cartoon & guide', 'resi 1-3 & guide')
        self._assertCountEqual('rep lines', 'resn CYS', delta=1)
        self._assertCountEqual('rep sticks', 'resn ASP+PHE')
        self._assertCountEqual('rep spheres', 'resn GLU')
        self._assertCountEqual('b > 0.5', 'resn PHE')
        self.assertTrue(cmd.get_setting_float('stick_ball_ratio', 'm2') > 1.1)
        self.assertEqual(g_labels[0], testlabel)
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:28,代码来源:load_mae.py

示例5: test_wildcard_sets_ranges

    def test_wildcard_sets_ranges(self):
        for i in range(10): cmd.pseudoatom('m%d' % i, chain=chr(65 + i))
        cmd.alter('m5', 'chain = "AB"')
        cmd.alter('m6', 'chain = "BA"')
        cmd.alter('m7', 'chain = "CC"')
        cmd.alter('m8', 'chain = "ZA"')
        cmd.alter('m9', 'chain = "ABA"')
        # A patterns
        self.assertEqual(1, cmd.count_atoms('chain A'))
        self.assertEqual(3, cmd.count_atoms('chain A*'))
        self.assertEqual(4, cmd.count_atoms('chain *A'))
        self.assertEqual(5, cmd.count_atoms('chain *A*'))
        self.assertEqual(1, cmd.count_atoms('chain A*A'))
        # B patterns
        self.assertEqual(2, cmd.count_atoms('chain B*'))
        self.assertEqual(2, cmd.count_atoms('chain *B'))
        self.assertEqual(4, cmd.count_atoms('chain *B*'))
        # X patterns (no matches)
        self.assertEqual(0, cmd.count_atoms('chain X*'))
        self.assertEqual(0, cmd.count_atoms('chain *X'))
        self.assertEqual(0, cmd.count_atoms('chain *X*'))
        # list with wildcards
        self.assertEqual(5, cmd.count_atoms('chain B*+A*'))
        self.assertEqual(3, cmd.count_atoms('chain B*+A*A'))
        self.assertEqual(3, cmd.count_atoms('chain B*+A*A+*X'))

        # lexicographical alpha ranges, A:C, will match AB (A <= AB <= C) but not CC (C < CC)
        # no wildcards in alpha ranges possible
        self.assertEqual(6, cmd.count_atoms('chain A:C'))
        self.assertEqual(6, cmd.count_atoms('chain A:CA'))
        self.assertEqual(7, cmd.count_atoms('chain A:CX')) # include CC
        self.assertEqual(6, cmd.count_atoms('chain A:C+Z'))
        self.assertEqual(7, cmd.count_atoms('chain A:C+Z*'))
开发者ID:schrodinger,项目名称:pymol-testing,代码行数:33,代码来源:selecting.py

示例6: sequential_residues

def sequential_residues(sel1, offset=1):
    """
        PURPOSE: renumbers the selected residues sequentially, regardless of gaps
        USAGE: sequential_residues protName    # first residue is 1
        USAGE: sequential_residues protName, 5 # first residue is 5
        EXAMPLE: sequential_residues *
        """
    offset = int(offset)

    # A counter from offset up
    stored.offset = int(offset) - 1
    stored.curr_res = None

    cmd.alter(
        sel1,
        """
if stored.curr_res != int(resi):
    stored.offset=stored.offset + 1
    stored.curr_res=int(resi)
    resi=stored.offset
else:
    resi=stored.offset
""",
    )
    cmd.sort()
开发者ID:sbliven,项目名称:dotfiles,代码行数:25,代码来源:sequential_residues.py

示例7: useRosettaRadii

def useRosettaRadii():
	cmd.alter("element C", "vdw=2.00")
	cmd.alter("element N", "vdw=1.75")
	cmd.alter("element O", "vdw=1.55")
	cmd.alter("element H", "vdw=1.00")
	cmd.alter("element P", "vdw=1.90")
	cmd.set("sphere_scale", 1.0)
开发者ID:d8vela,项目名称:pymol_scripts,代码行数:7,代码来源:PackingMeasureUtils.py

示例8: corexProtectionFactorUpdateB

def corexProtectionFactorUpdateB(obj, infoFile, pfFile):
    """Sets the B-factor column to the protection factors.
    infoFile is used to establish the mapping between pdb and corex numbers
        (*.info).
    pfFile gives the protection factors (*.Protection_Factors).
    """
    pf = CorexProtectionFactors(pfFile)
    info = CorexAtomInfo(infoFile)

    if info is None:
        print "Error parsing %s" % infoFile
        return
    if pf is None:
        print "Error parsing %s" % exchangeRateFile
        return

    assignPDBNums(
            [atom.res for atom in info.getAtoms() if not atom.isHet],
            pf.getResidues()
        )

    cmd.alter(obj, "b = -10")
    for res in pf.getResidues():
        if res.pdbNum is not None and res.modifiedProtectionFactor is not None:
            sel = "%s and i. %s and chain %s" % (
                    obj,  res.pdbNum, res.chain)
            cmd.alter( sel, "b = %f" % res.modifiedProtectionFactor)
    cmd.sort(obj)
开发者ID:sbliven,项目名称:dotfiles,代码行数:28,代码来源:corex.py

示例9: loadFitnessFactors

def loadFitnessFactors (mol,startaa=1,source="/Users/student/Box Sync/PUBS/Pymol-practice.txt", visual="Y"):
        # adapted from http://www.pymolwiki.org/index.php/Load_new_B-factors
        """
        Replaces B-factors with a list of fitness factor values contained in a plain txt file
 
        usage: loadFitnessFactors mol, [startaa, [source, [visual]]]
 
        mol = any object selection (within one single object though)
        startaa = number of first amino acid in 'new Fitness-factors' file (default=1)
        source = name of the file containing new Fitness-factor values (default=newFitnessFactors.txt)
        visual = redraws structure as cartoon_putty and displays bar with min/max values (default=Y)
 
        example: loadFitnessFactors 1LVM and chain A
        """
        obj=cmd.get_object_list(mol)[0]
        cmd.alter(mol,"b=-1.0")
        inFile = open(source, 'r')
        counter=int(startaa)
        fitnessFacts=[]
        for line in inFile.readlines():
                fitnessFact=float(line)
                fitnessFacts.append(fitnessFact)
                cmd.alter("%s and resi %s and n. CA"%(mol,counter), "b=%s"%fitnessFact)
                counter=counter+1
        if visual=="Y":
                cmd.show_as("cartoon",mol)
                cmd.cartoon("putty", mol)
#                cmd.set("cartoon_putty_scale_min", min(fitnessFacts),obj)
#                cmd.set("cartoon_putty_scale_max", max(fitnessFacts),obj)
                cmd.set("cartoon_putty_transform", 0,obj)
                cmd.set("cartoon_putty_radius", 0.2,obj)
                cmd.spectrum("b","red_white_blue", "%s and n. CA " %mol)
                cmd.ramp_new("count", obj, [min(fitnessFacts), (min(fitnessFacts)+max(fitnessFacts))/2, max(fitnessFacts)], color = ["blue", "white", "red"])
                cmd.recolor()
开发者ID:yuliyabirman,项目名称:pynd-pubs,代码行数:34,代码来源:map_fitness_to_Ub.py

示例10: corexDiffSAUpdateB

def corexDiffSAUpdateB(obj, corex1, corex2):
    """Sets the B-factor column to the difference in surface areas between
    files corex1-corex2
    """
    corex1 = CorexAtomInfo(corex1)
    if corex1 is None:
        print "Error parsing %s" % corex1
        return

    corex2 = CorexAtomInfo(corex2)
    if corex2 is None:
        print "Error parsing %s" % corex2
        return

    atoms1 = corex1.getAtoms()
    atoms2 = corex2.getAtoms()

    if len(atoms1) != len(atoms2):
        print "Error: Corex files must have identical atoms"
        #TODO line up atoms1 and atoms2 somehow
    for i in xrange(len(atoms1)):
        sel = "%s and n. %s and i. %s and chain %s" % (
                obj, atoms1[i].name, atoms1[i].res.pdbNum, atoms1[i].res.chain)
        cmd.alter( sel, "b = %f" % (atoms1[i].sa-atoms2[i].sa))
        print "b = %f" % (atoms1[i].sa-atoms2[i].sa)
    cmd.sort(obj)
开发者ID:sbliven,项目名称:dotfiles,代码行数:26,代码来源:corex.py

示例11: corexHDXRateUpdateB

def corexHDXRateUpdateB(obj, infoFile, exchangeRateFile):
    """Sets the B-factor column to the HDX rate.
    infoFile is used to establish the mapping between pdb and corex numbers
        (*.info).
    exchangeRateFile gives the HDX rates (*.Exchange_Rates).
    """
    hdx = CorexExchangeRates(exchangeRateFile)
    info = CorexAtomInfo(infoFile)

    if info is None:
        print "Error parsing %s" % infoFile
        return
    if hdx is None:
        print "Error parsing %s" % exchangeRateFile
        return

    assignPDBNums(
            [atom.res for atom in info.getAtoms() if not atom.isHet],
            hdx.getResidues()
        )

    cmd.alter(obj, "b = -10")
    for res in hdx.getResidues():
        if res.pdbNum is not None and res.exchangeRate is not None:
            sel = "%s and i. %s and chain %s" % (
                    obj,  res.pdbNum, res.chain)
            cmd.alter( sel, "b = %f" % res.exchangeRate)
    cmd.sort(obj)
开发者ID:sbliven,项目名称:dotfiles,代码行数:28,代码来源:corex.py

示例12: test_msms_surface

def test_msms_surface():
    eps = 1e-3
    cmd.reinitialize()
    cmd.fragment('ala', 'm1')
    # default
    psico.msms.msms_surface(name='surf1')
    extent = cmd.get_extent('surf1')
    assert extent[0] == approx([-2.705, -3.208, -2.413], rel=eps)
    assert extent[1] == approx([3.530, 2.907, 2.676], rel=eps)
    # global solvent_radius
    cmd.set('solvent_radius', 3.5)
    psico.msms.msms_surface(name='surf2')
    extent = cmd.get_extent('surf2')
    assert extent[0] == approx([-2.705, -3.169, -2.436], rel=eps)
    assert extent[1] == approx([3.530, 2.907, 2.676], rel=eps)
    # object-level solvent_radius
    cmd.set('solvent_radius', 2.8, 'm1')
    psico.msms.msms_surface(name='surf3')
    extent = cmd.get_extent('surf3')
    assert extent[0] == approx([-2.705, -3.161, -2.427], rel=eps)
    assert extent[1] == approx([3.530, 2.907, 2.676], rel=eps)
    # modified atom radii
    cmd.alter('m1', 'vdw = 3.0')
    psico.msms.msms_surface(name='surf4')
    extent = cmd.get_extent('surf4')
    assert extent[0] == approx([-4.605, -5.162, -4.418], rel=eps)
    assert extent[1] == approx([5.030, 4.861, 4.681], rel=eps)
开发者ID:speleo3,项目名称:pymol-psico,代码行数:27,代码来源:test_msms.py

示例13: 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

示例14: RefreshDisplay

    def RefreshDisplay(self):
        
        try:
            # Display the atoms spheres
            cmd.show('spheres', self.LigDisplay)
            cmd.refresh()

            cmd.alter(self.LigDisplay,'vdw=0.25')
            cmd.rebuild(self.LigDisplay)
            cmd.refresh()

            util.cbag(self.LigDisplay)
            cmd.refresh()
            
            if self.AnchorAtom != -1:
                AtomSel = self.LigDisplay + ' & id ' + str(self.AnchorAtom)
                cmd.color('white',AtomSel)
                cmd.refresh()

                cmd.alter(AtomSel ,'vdw=0.30')
                cmd.rebuild(AtomSel)
                cmd.refresh()
                        
        except:
            self.ErrorCode = 1

        return self.ErrorCode
开发者ID:NRGlab,项目名称:NRGsuite,代码行数:27,代码来源:Anchor.py

示例15: useTempRadii

def useTempRadii(sel="all"):
	for a in cmd.get_model(sel).atom:
		bfac = a.b
		if bfac >= 3:
			print "shrik radius"
			bfac <- 0.1
		cmd.alter("%s and resi %s and name %s"%(sel,a.resi,a.name),"vdw=%f"%(bfac))
开发者ID:willsheffler,项目名称:lib,代码行数:7,代码来源:setRadii.py


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