简体   繁体   English

在PyMOL中,如何使“ resi”选择与变量一起使用?

[英]In PyMOL, how can I make the “resi” selection work with variables?

If I want to select a residue on a protein (let's say the tenth residue), when writing a PyMOL script, I can use the following code to assign it to a variable "pep" 如果我想选择蛋白质上的一个残基(假设是第十个残基),那么在编写PyMOL脚本时,可以使用以下代码将其分配给变量“ pep”

select pep, (resi 10) 

However, if I try to use a predefined variable in place of the numbers in the selection, no atoms are assigned to the selection. 但是,如果我尝试使用预定义变量来代替选择中的数字,则不会为选择分配任何原子。

    a=10
    select pep, (resi a)

No error is returned and no atoms are assigned to the selection. 没有错误返回,并且没有原子分配给选择。 I've tried typecasting the variable as a string and as an integer, but neither one has worked. 我尝试过将变量作为字符串和整数进行类型转换,但没有一个起作用。 If I use the variable a elsewhere, such as a print statement or addition, it works perfectly fine. 如果我在其他地方(例如打印语句或加法)使用变量a ,则它可以很好地工作。 Does anyone know how to make the resi selection work with variables? 有谁知道如何使resi选择与变量一起使用? I'm trying to use this to color amino acids differently based on some data we collected and I don't want to hard code the residues each time I analyze a new set of data. 我试图根据收集到的一些数据使用这种方法对氨基酸进行不同的着色,并且我不想在每次分析一组新数据时对残留物进行硬编码。

The following is equivalent to select pep, (resi 10) : 以下等效于select pep, (resi 10)

a=10
cmd.select("pep", "resi " + str(a))

or 要么

cmd.select("pep", "resi %i"%(a))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM