本文整理汇总了Python中msmbuilder.arglib.die_if_path_exists函数的典型用法代码示例。如果您正苦于以下问题:Python die_if_path_exists函数的具体用法?Python die_if_path_exists怎么用?Python die_if_path_exists使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了die_if_path_exists函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: entry_point
def entry_point():
args = parser.parse_args()
T = scipy.io.mmread(args.tProb)
U = np.loadtxt(args.starting).astype(int)
F = np.loadtxt(args.ending).astype(int)
# deal with case where have single start or end state
# TJL note: This should be done in the library now... but leaving it
if U.shape == ():
tmp = np.zeros(1, dtype=int)
tmp[0] = int(U)
U = tmp.copy()
if F.shape == ():
tmp = np.zeros(1, dtype=int)
tmp[0] = int(F)
F = tmp.copy()
# Check output isn't taken
output_list = ["committors.dat", "net_flux.mtx"]
output_flist = [os.path.join(args.output_dir, f) for f in output_list]
arglib.die_if_path_exists(output_flist)
Fc, NFlux = run(T, U, F)
np.savetxt(output_flist[0], Fc)
scipy.io.mmwrite(output_flist[1], NFlux)
logger.info("Saved output to %s", ', '.join(output_flist))
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:28,代码来源:CalculateTPT.py
示例2: run
def run(MinLagtime, MaxLagtime, Interval, NumEigen, AssignmentsFn, symmetrize, nProc, output):
arglib.die_if_path_exists(output)
# Setup some model parameters
try:
Assignments = io.loadh(AssignmentsFn, "arr_0")
except KeyError:
Assignments = io.loadh(AssignmentsFn, "Data")
NumStates = max(Assignments.flatten()) + 1
if NumStates <= NumEigen - 1:
NumEigen = NumStates - 2
logger.warning(
"Number of requested eigenvalues exceeds the rank of the transition matrix! Defaulting to the maximum possible number of eigenvalues."
)
del Assignments
logger.info("Getting %d eigenvalues (timescales) for each lagtime...", NumEigen)
lagTimes = range(MinLagtime, MaxLagtime + 1, Interval)
logger.info("Building MSMs at the following lag times: %s", lagTimes)
# Get the implied timescales (eigenvalues)
impTimes = msm_analysis.get_implied_timescales(
AssignmentsFn, lagTimes, n_implied_times=NumEigen, sliding_window=True, symmetrize=symmetrize, n_procs=nProc
)
numpy.savetxt(output, impTimes)
return
开发者ID:jimsnyderjr,项目名称:msmbuilder,代码行数:28,代码来源:CalculateImpliedTimescales.py
示例3: entry_point
def entry_point():
args = parser.parse_args()
arglib.die_if_path_exists(args.output)
if args.atom_indices.lower() == 'all':
atom_indices = None
else:
atom_indices = np.loadtxt(args.atom_indices).astype(int)
project = Project.load_from(args.project)
SASA = run(project, atom_indices, args.traj_fn)
io.saveh(args.output, SASA)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:12,代码来源:CalculateProjectSASA.py
示例4: entry_point
def entry_point():
args = parser.parse_args()
# load args
try:
assignments = io.loadh(args.assignments, 'arr_0')
except KeyError:
assignments = io.loadh(args.assignments, 'Data')
tProb = scipy.io.mmread(args.tProb)
# workaround for arglib funniness?
if args.do_minimization in ["False", "0"]:
args.do_minimization = False
else:
args.do_minimization = True
if args.algorithm == 'PCCA':
MacroAssignmentsFn = os.path.join(
args.output_dir, "MacroAssignments.h5")
MacroMapFn = os.path.join(args.output_dir, "MacroMapping.dat")
arglib.die_if_path_exists([MacroAssignmentsFn, MacroMapFn])
MAP, assignments = run_pcca(args.num_macrostates, assignments, tProb)
np.savetxt(MacroMapFn, MAP, "%d")
io.saveh(MacroAssignmentsFn, assignments)
logger.info("Saved output to: %s, %s", MacroAssignmentsFn, MacroMapFn)
elif args.algorithm == 'PCCA+':
MacroAssignmentsFn = os.path.join(
args.output_dir, "MacroAssignments.h5")
MacroMapFn = os.path.join(args.output_dir, "MacroMapping.dat")
ChiFn = os.path.join(args.output_dir, 'Chi.dat')
AFn = os.path.join(args.output_dir, 'A.dat')
arglib.die_if_path_exists([MacroAssignmentsFn, MacroMapFn, ChiFn, AFn])
chi, A, MAP, assignments = run_pcca_plus(args.num_macrostates,
assignments, tProb, args.flux_cutoff, objective_function=args.objective_function,
do_minimization=args.do_minimization)
np.savetxt(ChiFn, chi)
np.savetxt(AFn, A)
np.savetxt(MacroMapFn, MAP, "%d")
io.saveh(MacroAssignmentsFn, assignments)
logger.info('Saved output to: %s, %s, %s, %s',
ChiFn, AFn, MacroMapFn, MacroAssignmentsFn)
else:
raise Exception()
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:50,代码来源:PCCA.py
示例5: run
def run(lagtime, assignments, symmetrize='MLE', input_mapping="None", trim=True, out_dir="./Data/"):
# set the filenames for output
FnTProb = os.path.join(out_dir, "tProb.mtx")
FnTCounts = os.path.join(out_dir, "tCounts.mtx")
FnMap = os.path.join(out_dir, "Mapping.dat")
FnAss = os.path.join(out_dir, "Assignments.Fixed.h5")
FnPops = os.path.join(out_dir, "Populations.dat")
# make sure none are taken
outputlist = [FnTProb, FnTCounts, FnMap, FnAss, FnPops]
arglib.die_if_path_exists(outputlist)
# Check for valid lag time
assert lagtime > 0, 'Please specify a positive lag time.'
# if given, apply mapping to assignments
if input_mapping != "None":
MSMLib.apply_mapping_to_assignments(assignments, input_mapping)
n_assigns_before_trim = len(np.where(assignments.flatten() != -1)[0])
counts = MSMLib.get_count_matrix_from_assignments(assignments, lag_time=lagtime, sliding_window=True)
rev_counts, t_matrix, populations, mapping = MSMLib.build_msm(counts, symmetrize=symmetrize, ergodic_trimming=trim)
if trim:
MSMLib.apply_mapping_to_assignments(assignments, mapping)
n_assigns_after_trim = len(np.where(assignments.flatten() != -1)[0])
# if had input mapping, then update it
if input_mapping != "None":
mapping = mapping[input_mapping]
# Print a statement showing how much data was discarded in trimming
percent = (1.0 - float(n_assigns_after_trim) / float(n_assigns_before_trim)) * 100.0
logger.warning("Ergodic trimming discarded: %f percent of your data", percent)
else:
logger.warning("No ergodic trimming applied")
# Save all output
np.savetxt(FnPops, populations)
np.savetxt(FnMap, mapping, "%d")
scipy.io.mmwrite(str(FnTProb), t_matrix)
scipy.io.mmwrite(str(FnTCounts), rev_counts)
io.saveh(FnAss, assignments)
for output in outputlist:
logger.info("Wrote: %s", output)
return
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:49,代码来源:BuildMSM.py
示例6: check_paths
def check_paths(args):
if args.alg == 'hierarchical':
die_if_path_exists(args.hierarchical_save_zmatrix)
else:
die_if_path_exists(args.generators)
if args.stride == 1:
die_if_path_exists(args.assignments)
die_if_path_exists(args.distances)
开发者ID:jimsnyderjr,项目名称:msmbuilder,代码行数:8,代码来源:Cluster.py
示例7: entry_point
def entry_point():
args = parser.parse_args()
k = int(args.num_states) if args.num_states != 'none' else None
d = float(args.cutoff_distance) if args.cutoff_distance != 'none' else None
arglib.die_if_path_exists(args.assignments)
if k is None and d is None:
logger.error(
'You need to supply either a number of states or a cutoff distance')
sys.exit(1)
project = Project.load_from(args.project)
assignments = main(
k, d, args.hierarchical_clustering_zmatrix, args.stride, project)
io.saveh(args.assignments, assignments)
logger.info('Saved assignments to %s', args.assignments)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:15,代码来源:AssignHierarchical.py
示例8: entry_point
def entry_point():
args = parser.parse_args()
arglib.die_if_path_exists(args.output)
try:
assignments = io.loadh(args.assignments, 'arr_0')
distances = io.loadh(args.distances, 'arr_0')
except KeyError:
assignments = io.loadh(args.assignments, 'Data')
distances = io.loadh(args.distances, 'Data')
trimmed = run(assignments, distances, args.rmsd_cutoff)
io.saveh(args.output, trimmed)
logger.info('Saved output to %s', args.output)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:16,代码来源:TrimAssignments.py
示例9: entry_point
def entry_point():
args, metric = parser.parse_args()
arglib.die_if_path_exists(args.output)
project = Project.load_from(args.project)
pdb = md.load(args.pdb)
if args.traj_fn.lower() == 'all':
traj_fn = None
else:
traj_fn = args.traj_fn
distances = run(project, pdb, metric, traj_fn)
io.saveh(args.output, distances)
logger.info('Saved to %s', args.output)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:16,代码来源:CalculateProjectDistance.py
示例10: run_pcca
def run_pcca(num_macrostates, assignments, tProb, output_dir):
MacroAssignmentsFn = os.path.join(output_dir, "MacroAssignments.h5")
MacroMapFn = os.path.join(output_dir, "MacroMapping.dat")
arglib.die_if_path_exists([MacroAssignmentsFn, MacroMapFn])
logger.info("Running PCCA...")
MAP = lumping.PCCA(tProb, num_macrostates)
# MAP the new assignments and save, make sure don't
# mess up negaitve one's (ie where don't have data)
MSMLib.apply_mapping_to_assignments(assignments, MAP)
np.savetxt(MacroMapFn, MAP, "%d")
msmbuilder.io.saveh(MacroAssignmentsFn, assignments)
logger.info("Saved output to: %s, %s", MacroAssignmentsFn, MacroMapFn)
开发者ID:jimsnyderjr,项目名称:msmbuilder,代码行数:16,代码来源:PCCA.py
示例11: run
def run(LagTime, assignments, Symmetrize='MLE', input_mapping="None", Prior=0.0, OutDir="./Data/"):
# set the filenames for output
FnTProb = os.path.join(OutDir, "tProb.mtx")
FnTCounts = os.path.join(OutDir, "tCounts.mtx")
FnMap = os.path.join(OutDir, "Mapping.dat")
FnAss = os.path.join(OutDir, "Assignments.Fixed.h5")
FnPops = os.path.join(OutDir, "Populations.dat")
# make sure none are taken
outputlist = [FnTProb, FnTCounts, FnMap, FnAss, FnPops]
arglib.die_if_path_exists(outputlist)
# if given, apply mapping to assignments
if input_mapping != "None":
MSMLib.apply_mapping_to_assignments(assignments, input_mapping)
n_states = np.max(assignments.flatten()) + 1
n_assigns_before_trim = len( np.where( assignments.flatten() != -1 )[0] )
rev_counts, t_matrix, populations, mapping = MSMLib.build_msm(assignments,
lag_time=LagTime, symmetrize=Symmetrize,
sliding_window=True, trim=True)
MSMLib.apply_mapping_to_assignments(assignments, mapping)
n_assigns_after_trim = len( np.where( assignments.flatten() != -1 )[0] )
# if had input mapping, then update it
if input_mapping != "None":
mapping = mapping[input_mapping]
# Print a statement showing how much data was discarded in trimming
percent = (1.0 - float(n_assigns_after_trim) / float(n_assigns_before_trim)) * 100.0
logger.warning("Ergodic trimming discarded: %f percent of your data", percent)
# Save all output
np.savetxt(FnPops, populations)
np.savetxt(FnMap, mapping,"%d")
scipy.io.mmwrite(str(FnTProb), t_matrix)
scipy.io.mmwrite(str(FnTCounts), rev_counts)
msmbuilder.io.saveh(FnAss, assignments)
for output in outputlist:
logger.info("Wrote: %s", output)
return
开发者ID:jimsnyderjr,项目名称:msmbuilder,代码行数:46,代码来源:BuildMSM.py
示例12: entry_point
def entry_point():
args = parser.parse_args()
arglib.die_if_path_exists(args.output)
LagTimes = args.lagtime.split(',')
MinLagtime = int(LagTimes[0])
MaxLagtime = int(LagTimes[1])
# Pass the symmetric flag
if args.symmetrize in ["None", "none", None]:
args.symmetrize = None
impTimes = run(
MinLagtime, MaxLagtime, args.interval, args.eigvals, args.assignments,
(not args.notrim), args.symmetrize, args.procs)
np.savetxt(args.output, impTimes)
logger.info("Saved output to %s", args.output)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:17,代码来源:CalculateImpliedTimescales.py
示例13: entry_point
def entry_point():
args, prep_metric = parser.parse_args()
arglib.die_if_path_exists(args.output)
if args.atom_indices.lower() == 'all':
atom_indices = None
else:
atom_indices = np.loadtxt(args.atom_indices).astype(int)
project = Project.load_from(args.project)
min_length = int(float(args.min_length))
# need to convert to float first because int can't
# convert a string that is '1E3' for example...weird.
tica_obj = run(
prep_metric, project, args.delta_time, atom_indices=atom_indices,
output=args.output, min_length=min_length, stride=args.stride)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:17,代码来源:tICA_train.py
示例14: run_pcca_plus
def run_pcca_plus(num_macrostates, assignments, tProb, output_dir, flux_cutoff=0.0,objective_function="crispness",do_minimization=True):
MacroAssignmentsFn = os.path.join(output_dir, "MacroAssignments.h5")
MacroMapFn = os.path.join(output_dir, "MacroMapping.dat")
ChiFn = os.path.join(output_dir, 'Chi.dat')
AFn = os.path.join(output_dir, 'A.dat')
arglib.die_if_path_exists([MacroAssignmentsFn, MacroMapFn, ChiFn, AFn])
logger.info("Running PCCA+...")
A, chi, vr, MAP = lumping.pcca_plus(tProb, num_macrostates, flux_cutoff=flux_cutoff,
do_minimization=do_minimization, objective_function=objective_function)
MSMLib.apply_mapping_to_assignments(assignments, MAP)
np.savetxt(ChiFn, chi)
np.savetxt(AFn, A)
np.savetxt(MacroMapFn, MAP,"%d")
msmbuilder.io.saveh(MacroAssignmentsFn, assignments)
logger.info('Saved output to: %s, %s, %s, %s', ChiFn, AFn, MacroMapFn, MacroAssignmentsFn)
开发者ID:jimsnyderjr,项目名称:msmbuilder,代码行数:18,代码来源:PCCA.py
示例15: entry_point
def entry_point():
args = parser.parse_args()
T = scipy.io.mmread(args.tProb)
state = int(args.state)
print(args.state, state)
# Check output isn't taken
if state == -1:
base_filename = "PairwiseMFPTs.dat"
else:
base_filename = "MFPTs_%d.dat" % state
output_filename = os.path.join(args.output_dir, base_filename)
arglib.die_if_path_exists(output_filename)
MFPTs = run(T, state)
np.savetxt(output_filename, MFPTs)
logger.info("Saved output to %s" % output_filename)
开发者ID:AgnesHH,项目名称:msmbuilder,代码行数:20,代码来源:CalculateMFPTs.py
示例16: main
def main():
parser = arglib.ArgumentParser(description='Assign data using a hierarchical clustering')
parser.add_argument('hierarchical_clustering_zmatrix', default='./Data/Zmatrix.h5',
help='Path to hierarchical clustering zmatrix' )
parser.add_argument('num_states', help='Number of States', default='none')
parser.add_argument('cutoff_distance', help='Maximum cophenetic distance', default='none')
parser.add_argument('assignments', type=str)
args = parser.parse_args()
k = int(args.num_states) if args.num_states != 'none' else None
d = float(args.cutoff_distance) if args.cutoff_distance != 'none' else None
if k is None and d is None:
logger.error('You need to supply either a number of states or a cutoff distance')
sys.exit(1)
arglib.die_if_path_exists(args.assignments)
assignments = hierarchical_clustering_zmatrix.get_assignments(k=k, cutoff_distance=d)
msmbuilder.io.saveh(args.assignments, assignments)
logger.info('Saved assignments to %s', args.assignments)
开发者ID:jimsnyderjr,项目名称:msmbuilder,代码行数:21,代码来源:AssignHierarchical.py
示例17: save
def save(confs_by_state, states, style, format, outdir):
"Save the results to disk"
if style == 'sep':
for i, trj in enumerate(confs_by_state):
for j in xrange(len(trj)):
fn = os.path.join(outdir, 'State%d-%d.%s' % (states[i], j,
format))
arglib.die_if_path_exists(fn)
logger.info("Saving file: %s" % fn)
trj[j].save(fn)
elif style == 'tps':
for i, trj in enumerate(confs_by_state):
fn = os.path.join(outdir, 'State%d.%s' % (states[i], format))
arglib.die_if_path_exists(fn)
logger.info("Saving file: %s" % fn)
trj.save(fn)
elif style == 'one':
fn = os.path.join(outdir, 'Confs.%s' % format)
arglib.die_if_path_exists(fn)
logger.info("Saving file: %s" % fn)
concatenate_trajectories(confs_by_state).save(fn)
else:
raise ValueError('Invalid style: %s' % style)
开发者ID:lilipeng,项目名称:msmbuilder,代码行数:31,代码来源:SaveStructures.py
示例18: main
def main(args, metric):
if args.alg == "sclarans" and args.stride != 1:
logger.error(
"""You don't want to use a stride with sclarans. The whole point of
sclarans is to use a shrink multiple to accomplish the same purpose, but in parallel with
stochastic subsampling. If you cant fit all your frames into memory at the same time, maybe you
could stride a little at the begining, but its not recommended."""
)
sys.exit(1)
# if we have a metric that explicitly operates on a subset of indices,
# then we provide the option to only load those indices into memory
# WARNING: I also do something a bit dirty, and inject `None` for the
# RMSD.atomindices to get the metric to not splice
if isinstance(metric, metrics.RMSD):
atom_indices = metric.atomindices
metric.atomindices = None # probably bad...
logger.info("RMSD metric - loading only the atom indices required")
else:
atom_indices = None
# In case the clustering / algorithm needs extra arguments, use
# this dictionary
extra_kwargs = {}
# Check to be sure we won't overwrite any data
if args.alg == "hierarchical":
zmatrix_fn = os.path.join(args.output_dir, "ZMatrix.h5")
die_if_path_exists(zmatrix_fn)
extra_kwargs["zmatrix_fn"] = zmatrix_fn
else:
generators_fn = os.path.join(args.output_dir, "Gens.lh5")
die_if_path_exists(generators_fn)
if args.stride == 1:
assignments_fn = os.path.join(args.output_dir, "Assignments.h5")
distances_fn = os.path.join(args.output_dir, "Assignments.h5.distances")
die_if_path_exists([assignments_fn, distances_fn])
trajs = load_trajectories(args.project, args.stride, atom_indices)
logger.info("Loaded %d trajs", len(trajs))
clusterer = cluster(metric, trajs, args, **extra_kwargs)
if not isinstance(clusterer, clustering.Hierarchical):
generators = clusterer.get_generators_as_traj()
logger.info("Saving %s", generators_fn)
generators.save_to_lhdf(generators_fn)
if args.stride == 1:
assignments = clusterer.get_assignments()
distances = clusterer.get_distances()
logger.info("Since stride=1, Saving %s", assignments_fn)
logger.info("Since stride=1, Saving %s", distances_fn)
io.saveh(assignments_fn, assignments)
io.saveh(distances_fn, distances)
开发者ID:kyleabeauchamp,项目名称:msmbuilder-legacy,代码行数:56,代码来源:Cluster.py
示例19: main_extract
def main_extract(args):
"main method for the extract subcommand"
project = Project.load_from(args.project_info)
close = int(args.close)
stride = int(args.stride)
if args.far < 0:
far = None
else:
far = args.far
die_if_path_exists(args.output)
if args.extract_method == 'rmsd':
atomindices = np.loadtxt(args.atomindices, dtype=int)
AtoB, AtoC = triplets.extract_rmsd(project, close, stride, atomindices, far)
elif args.extract_method == 'dihedral':
if 'types' in args:
AtoB, AtoC = triplets.extract_dihedral(project, close, stride, types=args.types, far=far)
else:
indices = np.loadtxt(args.indices, dtype=int)
AtoB, AtoC = triplets.extract_dihedral(project, close, stride, indices=indices, far=far)
elif args.extract_method == 'recipcontact':
AtoB, AtoC = triplets.extract_recipcontact(project, close, stride, far=far)
elif args.extract_method == 'drmsd':
indices = np.loadtxt(args.indices, dtype=int)
AtoB, AtoC, atom_pairs = triplets.extract_drmsd(project, close, stride, indices=indices, far=far)
io.saveh(args.output, atom_pairs=atom_pairs)
else:
raise NotImplementedError("Sorry, we don't have that metric")
#Serializer({'AtoB': AtoB, 'AtoC': AtoC, 'metric': args.extract_method}).SaveToHDF(args.output)
io.saveh(args.output, AtoB=AtoB, AtoC=AtoC, metric=np.array(list(args.extract_method)))
print 'Saved triplets to {}'.format(args.output)
开发者ID:mpharrigan,项目名称:KDML,代码行数:36,代码来源:KDML.py
示例20: entry_point
def entry_point():
args = parser.parse_args()
F = np.loadtxt(args.ending).astype(int)
U = np.loadtxt(args.starting).astype(int)
tprob = scipy.io.mmread(args.tprob)
# deal with case where have single start or end state
# TJL note: this should be taken care of in library now... keeping it just
# in case
if F.shape == ():
tmp = np.zeros(1, dtype=int)
tmp[0] = int(F)
F = tmp.copy()
if U.shape == ():
tmp = np.zeros(1, dtype=int)
tmp[0] = int(U)
U = tmp.copy()
arglib.die_if_path_exists(args.output)
paths, bottlenecks, fluxes = run(tprob, U, F, args.number)
io.saveh(args.output, Paths=paths, Bottlenecks=bottlenecks, fluxes=fluxes)
logger.info('Saved output to %s', args.output)
开发者ID:flalix,项目名称:msmbuilder-legacy,代码行数:24,代码来源:FindPaths.py
注:本文中的msmbuilder.arglib.die_if_path_exists函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论