到目前为止,如果我想知道迭代器中有多少次迭代(在我的情况下,文件中有多少蛋白质序列)我做了:
count = 0
for stuff in iterator:
count += 1
print count
Run Code Online (Sandbox Code Playgroud)
但是,我想将迭代器分成两半,所以我需要知道迭代的总量.有没有办法知道没有循环遍历迭代器的迭代量?
我正在尝试编译一个我从别人那里得到的c ++程序.它是在windows上开发的,g ++给出了一些编译错误.其中一个是
#include <random>
Run Code Online (Sandbox Code Playgroud)
这给出了以下错误:CandidateSolution.cpp:2:18: error: random: No such file or directory.我试图找到我从哪里可以得到error.h文件,但我找不到它.我怎样才能让它发挥作用?
我有一个python脚本,它可以创建一个GUI.当在此GUI中按下"运行"按钮时,它会从导入的包(我制作)中运行一个函数
from predictmiP import predictor
class MiPFrame(wx.Frame):
[...]
def runmiP(self, event):
predictor.runPrediction(self.uploadProtInterestField.GetValue(), self.uploadAllProteinsField.GetValue(), self.uploadPfamTextField.GetValue(), \
self.edit_eval_all.Value, self.edit_eval_small.Value, self.saveOutputField)
Run Code Online (Sandbox Code Playgroud)
当我直接从python运行GUI时,它运行良好,程序写入一个输出文件.然而,当我进入应用程序时,GUI启动,但是当我按下按钮时没有任何反应.predictmiP确实包含在build/bdist.macosx-10.3-fat/python2.7-standalone/app/collect /中,就像我正在使用的所有其他导入一样(虽然它是空的,但是和所有其他导入一样我有).
如何获取多个python文件,或导入的包与py2app一起使用?
我的setup.py:
msgstr"""这是py2applet生成的setup.py脚本
用法:python setup.py py2app"""
from setuptools import setup
APP = ['mip3.py']
DATA_FILES = []
OPTIONS = {'argv_emulation': True}
setup(
app=APP,
data_files=DATA_FILES,
options={'py2app': OPTIONS},
setup_requires=['py2app'],
)
Run Code Online (Sandbox Code Playgroud)
编辑:
它看起来很有效,但它只能起作用.从我的GUI我打电话
blast.makeBLASTdb(self.uploadAllProteinsField.GetValue(), 'allDB')
# to test if it's working
dlg = wx.MessageDialog( self, "werkt"+self.saveOutputField, "werkt", wx.OK)
dlg.ShowModal() # Show it
dlg.Destroy() # finally destroy it when finished.
Run Code Online (Sandbox Code Playgroud)
blast.makeBLASTdb看起来像这样:
def makeBLASTdb(proteins_file, database_name):
subprocess.call(['/.'+os.path.realpath(__file__).rstrip(__file__.split('/')[-1])+'blast/makeblastdb', …Run Code Online (Sandbox Code Playgroud) 我想从屏蔽数组中删除列,其中列中的每个值都被屏蔽。所以在下面的例子中:
>>> import numpy as np
>>> test = np.array([[1,0,0],[0,3,0],[1,4,0]])
>>> test = np.ma.masked_equal(test,0)
>>> test
[[1 -- --]
[-- 3 --]
[1 4 --]],
>>> np.somefunction(test)
[[1 --]
[-- 3 ]
[1 4 ]]
Run Code Online (Sandbox Code Playgroud)
np.somefunction() 应该是什么来获得给定的输出?
我正在尝试使用Mathematica找到最小的跨越树,我想使用Combinatorica中的MinimumSpanningTree函数.我正在使用以下代码.
Needs["Combinatorica`"]
MinimumSpanningTree[GraphPlot[m]]
Run Code Online (Sandbox Code Playgroud)
其中m是矩阵.但是,MinimumSpanningTree变为红色并且不起作用.输出给出
out = MinimumSpanningTree[<maximum spanned tree>] //can't show the tree here
Run Code Online (Sandbox Code Playgroud)
如何使MinimumSpanningTree工作?它为什么变成红色?
我正在研究远程桌面服务器,Windows XP Profesional.大约2小时前,numpy还在那里工作.我试图使用for循环使用mulitprocessing.Pool()并且我一定做错了,因为在很短的时间之后运行了100个python.exe进程.我花了一些时间重新进入服务器,我想测试为什么所有这些进程都已完成.但是,我遇到了以下错误:
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 154, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module
>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <modu
le>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 45, in <modu
le>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 8, in <mo
dule>
from unittest import …Run Code Online (Sandbox Code Playgroud) 我有一个数据框df,我想为其制作一些行的直方图。我可以选择行并df["row1",]得到(显示 114 列中的 4 列):
X3432_re X232_fa X212_lf X634_fv
row1 5.1 4.3 3.7 3.7
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试时hist(df["row1",]),我收到'x' must be numeric错误。我尝试过hist(as.vector(df["row1",]))但遇到了同样的问题。如何制作数据帧行的直方图?
我有一个test.sh通过文本文件 awks 的文件test.bed:
1 31 431
1 14 1234
1 54 134
2 435 314
2 314 414
Run Code Online (Sandbox Code Playgroud)
和
while read line;do
echo $line
# ... more code ... #
done < <(awk -F '\t' '$1 == 1 {print $0}' test.bed )
Run Code Online (Sandbox Code Playgroud)
用bash test.sh作品运行它,但sh test.sh它会产生语法错误。我怎么能用sh而不是做上面的事情bash?
它给出的错误是
test.sh: line 5: syntax error near unexpected token `<'
test.sh: line 5: `done < <(awk -F '\t' '$1 == 1 {print $0}' …Run Code Online (Sandbox Code Playgroud) 我有一个用 VennDiagram 包制作的维恩图。数字超过100,000。
我希望中间的数字是 150,001,用逗号分隔,或者 150,000,中间有一个小空格。这可能与 VennDiagram 有关吗?
这是我的例子
library(VennDiagram)
venn.diagram(x = list(A = 1:200000,B = 50000:300000), filename = "../example.tiff")
Run Code Online (Sandbox Code Playgroud) 我想创建一个命名列表,其中每个名称都有多个值。如果每个名称都有一个值,我只能找到如何执行此操作。我现在使用的解决方案是
df <- data.frame(col1=c('a','a','b','b'), col2=c(1,2,3,4))
l <- list()
for(letter in unique(df$col1)){
l[[letter]] <- df[df$col1==letter,]$col2
}
> l
$a
[1] 1 2
$b
[1] 3 4
Run Code Online (Sandbox Code Playgroud)
但有什么更好的方法可以做到这一点?