本文整理汇总了Python中simulation.Simulation.open_folder方法的典型用法代码示例。如果您正苦于以下问题:Python Simulation.open_folder方法的具体用法?Python Simulation.open_folder怎么用?Python Simulation.open_folder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simulation.Simulation
的用法示例。
在下文中一共展示了Simulation.open_folder方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_sims
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import open_folder [as 别名]
def parse_sims(folders, algorithm_list, parameters, sim_group, calc_dcj_distance=False, parse_time=False):
# if algorithm_list is None:
# # TODO: auto-detect?
# pass
all_results = collections.defaultdict(lambda: collections.defaultdict(list))
time_results = collections.defaultdict(lambda: collections.defaultdict(list))
for idx,folder in enumerate(folders):
sim = Simulation.open_folder(folder)
# set tree distances:
algorithms.set_all_tree_distances(sim.sim_tree)
# define simulation parameter label:
sim.sim_parameters.folder = folder
sim.sim_parameters.idx = idx
# indel perc
sim.sim_parameters.indel_p = sim.sim_parameters.insertion_p + sim.sim_parameters.deletion_p
sim_label = sim_group % sim.sim_parameters.__dict__
try:
for alg in algorithm_list:
label, method, location = alg.split(",")
# Get ancestral genomes:
reconstructed = file_ops.load_ancestral_genomes(folder, method, location)
algo_res = get_ancestral_stats(sim.ancestral_genomes, reconstructed, sim.sim_tree,
calc_tree_distances=True, calc_dcj_distance=calc_dcj_distance)
if parse_time:
# convention: timefile is method.time, for instance, "ringo.time" or "mgra.time"
time_results[label][sim_label].append(parse_filetime(os.path.join(folder,location,"%s.time" % method.lower())))
all_results[label][sim_label].extend(algo_res)
except (RuntimeError,KeyError,IOError):
print >> sys.stderr, "Results not present for all methods on folder %s, skipping..." % folder
return all_results, time_results
示例2: sum
# 需要导入模块: from simulation import Simulation [as 别名]
# 或者: from simulation.Simulation import open_folder [as 别名]
parser.add_argument("-sb", "--skip_balancing", action="store_true", default=False,
help="Uses the no balancing ILP.")
param = parser.parse_args()
# Ringo_config:
cfg = ringo_config.RingoConfig()
sim_cols = ["caller", "real_distance", "dup_length", "dup_prob", "del_prob"]
tree_events = ["%s_%s" % (g, event) for g in ["T1", "T2"] for event in EventType.all]
time_ortho = ["time", "gap", "ortho_TP", "ortho_FP", "ortho_FN"]
fields = sim_cols + tree_events + ["dcj_distance", "distance_diff", "dup_a", "dup_b"] + time_ortho + ["bal_A", "bal_B"]
results = collections.defaultdict(list)
results = []
for folder in param.folders:
# sim data:
sim = Simulation.open_folder(folder)
p = sim.sim_parameters
result = {
"dup_length": sim.sim_parameters.duplication_length,
"dup_prob": sim.sim_parameters.duplication_p,
"del_prob": sim.sim_parameters.deletion_p
}
# key = "L%(duplication_length)s_dup%(duplication_p)s_del%(deletion_p)s" % p.__dict__
# tree events:
tree_events = {"%s_%s" % (g, event): sim.sim_tree.find_node_with_label(g).edge.events[event] for g in
["T1", "T2"] for
event in EventType.all}
result.update(tree_events)
result["real_distance"] = sum(map(int, tree_events.values()))
# coser and nobal is the same until here: