- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
设计并编写一个可以检测跨膜域的程序,称为TMscanner.py
。该程序应调用您编写的其他两个函数: getProteinRegion
应返回十个氨基酸窗口(最初抓取氨基酸 1-10,下次抓取 2-20,等等)。 TMscanner
还应重复调用名为 testForTM
的第二个函数,该函数应计算并返回这十个非极性氨基酸的小数部分。非极性氨基酸为[A,V,L,I,P,M,F,W]
示例:
protein = 'AVLIPMFWGSTNQYDEKRH' #Only the first 9 are nonpolar
results = tmScanner(protein)
print "Results are", results
它应该打印出:
Results are [.8, .7, .6, .5, .4, .3, .2, .1, 0, 0]
-- #测试代码
def getProteinRegion(protein, start):
#return first 10 aa in protein
return protein[start:start+10]
def testForTM(protein):
#return ratio of nonpolar aa from a sample of first 10; move them up one step and repeat
nonpolar = 0
for aa in getProteinRegion(protein, start):
if aa in ['A', 'V', 'L', 'I', 'P', 'M', 'F', 'W']:
nonpolar = nonpolar + 1.0
return nonpolar / 10.0
def tmSCANNER(protein):
#while the tested in testForTM is less than 10, append testforTM function to results; print results
results = []
start = 0
while start <= 10:
results = results.append(testForTM(protein))
return results
start = start + 1
##TESTING
#print getProteinRegion('AVLIPMFWGSTCNQYDEKRH')
#print testForTM('AVLIPMFW')
print tmSCANNER('AVLIPMFWGSTCNQYDEKRH')
--
Traceback (most recent call last):
File "TMscanner.py", line 29, in <module>
print tmSCANNER('AVLIPMFWGSTCNQYDEKRH')
File "TMscanner.py", line 21, in tmSCANNER
results = results.append(testForTM(protein))
File "TMscanner.py", line 10, in testForTM
for aa in getProteinRegion(protein, start):
NameError: global name 'start' is not defined
最佳答案
您的函数 testForTM
不采用 start
参数,也不声明名为 start
的局部变量,但它调用 getProteinRegion(蛋白质,开始)
。因此,Python 假定您必须使用全局变量,但您也没有具有该名称的全局变量。所以它引发了一个异常。
您可能想要添加 start
作为参数:
def testForTM(protein, start):
然后,在 tmSCANNER
内部的调用代码中,您确实有一个名为 start
的局部变量,这可能就是您想要的值作为 start
参数传递:
results = results.append(testForTM(protein, start))
关于python - 生物信息学 - "global name ' start'未定义”?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49473671/
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我在 BioJava 中搜索一种方法以从 PDB 文件中获取 Atom 序列。我看了 BioJava API,但对于 getAtomSequence() 它捕获了氨基酸。我在 BioJava 中尝试了
我有两个字符串 A 和 B,比如说 A = AATCGGATATAG B = CGATA 你们中的一些人可能知道两种类型的对齐: Global Alignment Local Alignment 但我
设计并编写一个可以检测跨膜域的程序,称为TMscanner.py。该程序应调用您编写的其他两个函数: getProteinRegion 应返回十个氨基酸窗口(最初抓取氨基酸 1-10,下次抓取 2-2
生物学家使用字母 A、C、T 和 G 的序列来模拟基因组。基因是基因组的子序列,起始于三联体 ATG 之后,结束于三联体 TAG、TAA 或 TGA 之前。此外,基因串的长度是3的倍数,并且该基因不包
我安装了生物信息学工具Picard 2.20在我的 HPC 集群中对我的基因组对齐文件运行一些指标。 Picard 2.20 需要 JDK 1.8,而我们的集群有 1.6,所以我安装了 JDK 1.8
我是一名优秀的程序员,十分优秀!