我想知道如何从ispell私有字典中删除一个(错误插入的)条目/单词.
编辑
经过更多的挖掘,我仍然无法从默认字典中删除条目,但我认为解决方案可能是围绕buildhash程序.问题是生成要删除的条目列表...我找不到一个简单的例子.
我有一个如下所示的出租车列表:
1204725
2162
1300163
420247
Run Code Online (Sandbox Code Playgroud)
我希望从上面的出租车中获取一个带有分类标准的文件:
kingdom_id phylum_id class_id order_id family_id genus_id species_id
Run Code Online (Sandbox Code Playgroud)
我正在使用" ete3 " 包.我使用工具ete-ncbiquery来告诉你上面的id的谱系.(我使用下面的命令从我的linux笔记本电脑上运行它)
ete3 ncbiquery --search 1204725 2162 13000163 420247 --info
Run Code Online (Sandbox Code Playgroud)
结果如下:
# Taxid Sci.Name Rank Named Lineage Taxid Lineage
2162 Methanobacterium formicicum species root,cellular organisms,Archaea,Euryarchaeota,Methanobacteria,Methanobacteriales,Methanobacteriaceae,Methanobacterium,Methanobacterium formicicum 1,131567,2157,28890,183925,2158,2159,2160,2162
1204725 Methanobacterium formicicum DSM 3637 no rank root,cellular organisms,Archaea,Euryarchaeota,Methanobacteria,Methanobacteriales,Methanobacteriaceae,Methanobacterium,Methanobacterium formicicum,Methanobacterium formicicum DSM 3637 1,131567,2157,28890,183925,2158,2159,2160,2162,1204725
420247 Methanobrevibacter smithii ATCC 35061 no rank root,cellular organisms,Archaea,Euryarchaeota,Methanobacteria,Methanobacteriales,Methanobacteriaceae,Methanobrevibacter,Methanobrevibacter smithii,Methanobrevibacter smithii ATCC 350611,131567,2157,28890,183925,2158,2159,2172,2173,420247
Run Code Online (Sandbox Code Playgroud)
我不知道哪些项目(IDS)对应于我要找的东西(如果有的话)
我正在尝试使一些数据适合对数正态分布,并使用优化的参数从中生成随机的对数正态分布。经过一番搜索,我找到了一些解决方案,但没有令人信服的解决方案:
使用fit函数的solution1:
import numpy as np
from scipy.stats import lognorm
mydata = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,8,8,8,8,8,9,9,9,10,10,11,12,13,14,14,15,19,19,21,23,25,27,28,30,31,36,41,45,48,52,55,60,68,75,86,118,159,207,354]
shape, loc, scale = lognorm.fit(mydata)
rnd_log = lognorm.rvs (shape, loc=loc, scale=scale, size=100)
Run Code Online (Sandbox Code Playgroud)
或使用原始数据中的mu和sigma的解决方案2:
import numpy as np
from scipy.stats import lognorm
mydata = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,6,6,6,6,6,7,7,7,8,8,8,8,8,9,9,9,10,10,11,12,13,14,14,15,19,19,21,23,25,27,28,30,31,36,41,45,48,52,55,60,68,75,86,118,159,207,354]
mu = np.mean([np.log(i) for i in mydata])
sigma = np.std([np.log(i) for i in mydata])
distr = lognorm(mu, sigma)
rnd_log = distr.rvs (size=100)
Run Code Online (Sandbox Code Playgroud)
这些解决方案都不适合:
import pylab
pylab.plot(sorted(mydata, reverse=True), 'ro')
pylab.plot(sorted(rnd_log, reverse=True), 'bx')
Run Code Online (Sandbox Code Playgroud)
我不确定我是否了解使用发行版的方式,或者是否缺少其他内容...
我在这里找到解决方案:是否有人使用scipy.stats.distributions的示例代码? 但是我无法从数据中获取形状...我是否在使用fit函数时缺少某些东西?
谢谢
编辑:
这是一个例子,以便更好地理解我的问题:
print 'solution 1:'
means = …Run Code Online (Sandbox Code Playgroud) 我有一个通过运行创建的向量列表:
import hcluster
import numpy as np
from ete2 import Tree
vecs = [np.array(i) for i in document_list]
Run Code Online (Sandbox Code Playgroud)
其中document_list是我正在分析的Web文档的集合.然后我执行分层聚类:
Z = hcluster.linkage(vecs, metric='cosine')
Run Code Online (Sandbox Code Playgroud)
这会生成一个ndarray,例如:
[[ 12. 19. 0. 1. ]
[ 15. 21. 0. 3. ]
[ 18. 22. 0. 4. ]
[ 3. 16. 0. 7. ]
[ 8. 23. 0. 6. ]
[ 5. 27. 0. 6. ]
[ 1. 28. 0. 7. ]
[ 0. 21. 0. 2. ]
[ 5. 29. 0.18350472 2. ]
[ 2. …Run Code Online (Sandbox Code Playgroud) 有没有办法在Python 2.5中做这样的事情:
b = ('{!s}'*3)
b.format(*[i for i in xrange (3)])
Run Code Online (Sandbox Code Playgroud)
因为这不起作用:
b = ('%s'*3)
b % (*[i for i in xrange (3)])
Run Code Online (Sandbox Code Playgroud) 我试图为下面的HTML表配置一个解析树,但是无法形成它.我想看看树结构是什么样的!有人可以帮助我吗?
# <html>
# <head>
# <title>
# The Dormouse's story
# </title>
# </head>
# <body>
# <p class="title">
# <b>
# The Dormouse's story
# </b>
# </p>
# <p class="story">
# Once upon a time there were three little sisters; and their names were
# <a class="sister" href="http://example.com/elsie" id="link1">
# Elsie
# </a>
# ,
# <a class="sister" href="http://example.com/lacie" id="link2">
# Lacie
# </a>
# and
# <a class="sister" href="http://example.com/tillie" id="link2">
# Tillie
# </a>
# ; …Run Code Online (Sandbox Code Playgroud) ETE2(用于系统发育树探索的Python环境)有一个.phonehome()可以在树/节点类对象上调用的方法.返回:
== Calling home... Got answer!
He11o alien,
How is everything in the Earth?
We miss you in Brodo Asogi.
I see you are in shape.
No updates are available.
== Do you want to leave any message?
(Press enter to finish)
Run Code Online (Sandbox Code Playgroud)
如果您想自己测试一下,请尝试:
from ete2 import Tree
t = Tree() # generate random Tree
t.phonehome() # communicate with Aliens!
Run Code Online (Sandbox Code Playgroud)
这是一个复活节彩蛋吗?
python ×5
etetoolkit ×4
dendrogram ×1
emacs ×1
flyspell ×1
hcluster ×1
ispell ×1
messaging ×1
ncbi ×1
numpy ×1
parse-tree ×1
phylogeny ×1
python-2.7 ×1
scipy ×1
taxonomy ×1
tuples ×1