本文整理汇总了Python中jcvi.formats.sizes.Sizes.iter_names方法的典型用法代码示例。如果您正苦于以下问题:Python Sizes.iter_names方法的具体用法?Python Sizes.iter_names怎么用?Python Sizes.iter_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类jcvi.formats.sizes.Sizes
的用法示例。
在下文中一共展示了Sizes.iter_names方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: score
# 需要导入模块: from jcvi.formats.sizes import Sizes [as 别名]
# 或者: from jcvi.formats.sizes.Sizes import iter_names [as 别名]
def score(args):
"""
%prog score main_results/ cached_data/ contigsfasta
Score the current LACHESIS CLM.
"""
p = OptionParser(score.__doc__)
p.set_cpus()
opts, args = p.parse_args(args)
if len(args) != 3:
sys.exit(not p.print_help())
mdir, cdir, contigsfasta = args
orderingfiles = natsorted(iglob(mdir, "*.ordering"))
sizes = Sizes(contigsfasta)
contig_names = list(sizes.iter_names())
contig_ids = dict((name, i) for (i, name) in enumerate(contig_names))
oo = []
# Load contact matrix
glm = op.join(cdir, "all.GLM")
N = len(contig_ids)
M = np.zeros((N, N), dtype=int)
fp = open(glm)
for row in fp:
if row[0] == '#':
continue
x, y, z = row.split()
if x == 'X':
continue
M[int(x), int(y)] = int(z)
fwtour = open("tour", "w")
def callback(tour, gen, oo):
fitness = tour.fitness if hasattr(tour, "fitness") else None
label = "GA-{0}".format(gen)
if fitness:
fitness = "{0}".format(fitness).split(",")[0].replace("(", "")
label += "-" + fitness
print_tour(fwtour, tour, label, contig_names, oo)
return tour
for ofile in orderingfiles:
co = ContigOrdering(ofile)
for x in co:
contig_id = contig_ids[x.contig_name]
oo.append(contig_id)
pf = op.basename(ofile).split(".")[0]
print pf
print oo
tour, tour_sizes, tour_M = prepare_ec(oo, sizes, M)
# Store INIT tour
print_tour(fwtour, tour, "INIT", contig_names, oo)
# Faster Cython version for evaluation
from .chic import score_evaluate_M
callbacki = partial(callback, oo=oo)
toolbox = GA_setup(tour)
toolbox.register("evaluate", score_evaluate_M,
tour_sizes=tour_sizes, tour_M=tour_M)
tour, tour.fitness = GA_run(toolbox, npop=100, cpus=opts.cpus,
callback=callbacki)
print tour, tour.fitness
break
fwtour.close()