def replica_path(filenames, replicakind="lambda"): """ Extract replica path from a set of results files Parameters ---------- filenames : list of strings the files to read replicakind : string the type of replica, at the moment only lambda is allowed Returns ------- numpy array the labeled replica path list list of the labels for all input files """ if replicakind == "lambda": replica_attr = "lambdareplica" label_attr = "lam" elif replicakind == "temperature": replica_attr = "temperaturereplica" label_attr = "temperature" elif replicakind == "rest": replica_attr = "temperaturereplica" label_attr = "efftemperature" elif replicakind == "global": replica_attr = "globalreplica" label_attr = None elif replicakind == "B": replica_attr = "gcmcreplica" label_attr = "bvalue" else: raise simulationobjects.SetupError( "Have not implemented replica path analysis for %s" % replicakind) # Build of list of replica ids in each output file # also produce a list of labels, e.g. lambda or temperature rawpaths = [] labels = [] for ind, filename in enumerate(filenames): results_file = simulationobjects.ResultsFile() results_file.read(filename=filename) if hasattr(results_file.snapshots[0], replica_attr): path = np.zeros(len(results_file.snapshots), int) - 1 label = ind + 1 if label_attr: label = getattr(results_file.snapshots[0], label_attr) for i, snap in enumerate(results_file.snapshots): path[i] = getattr(snap, replica_attr) rawpaths.append(path) labels.append(label) # Now find the path for each lambda/temperature value rawpaths = np.array(rawpaths, dtype=int) labeled_paths = [[] for l in labels] # Loop over each possible lambda/temperature value, i.e. label id for i in range(rawpaths.shape[0]): # We will try to fill up an array that is as long as the simulation while len(labeled_paths[i]) < rawpaths.shape[1]: # This is the current point in time we will be looking # for replica with id = i k = len(labeled_paths[i]) # Look in the list of each output file as built above for j, path in enumerate(rawpaths): # If the replica id at the current time, k is equal to the # label id we are on (i), add the label of file j to # the list and break if path[k] == i + 1: labeled_paths[i].append(labels[j]) break return np.asarray(labeled_paths), labels
help="prefix of the output file") parser.add_argument('--gaff', default="gaff16", help="the version of GAFF to use for ligand") return parser # # If this is run from the command-line # if __name__ == '__main__': args = get_arg_parser().parse_args() # Setup the logger logger = sim.setup_logger("make_single_py.log") if None in (args.tem0, args.tem1, args.pdb0, args.pdb1): sim.SetupError("Not all four necessary input files given. Cannot setup single-topology") eletem,vdwtem,combtem,cmap = make_single(args.tem0,args.tem1,args.pdb0,args.pdb1,args.map,gaffversion=args.gaff) eletem.write(args.out+"_ele.tem") vdwtem.write(args.out+"_vdw.tem") combtem.write(args.out+"_comb.tem") if args.map is None: write_map(cmap,args.out+"_cmap.dat") # Write out a summary summarize_single(eletem,vdwtem,logger.info)
'--path', help="Where the input should be found and the output printed. " "Default = ./", default="./") return parser if __name__ == '__main__': args = get_arg_parser().parse_args() # Make sure that the input file exists and get the prefix commonprefix = _get_prefix(args.input) commonfile = os.path.join(args.path, commonprefix + ".pdb") if os.path.isfile(commonfile): "The file %s will be divided in individual pdbs" % commonfile else: msg = "pdb file %s.pdb could not be found" % commonprefix print(msg) raise simulationobjects.SetupError(msg) # Get the prefix of the output files outprefix = _get_prefix(args.output) outpathprefix = os.path.join(args.path, outprefix) # Divide input into individual pdb objects divide_print(commonfile, outpathprefix)
# Setup a parser of the command-line arguments parser = argparse.ArgumentParser( description="Program merge a series of ProtoMS template files") parser.add_argument('-f', '--files', nargs="+", help="the name of the template files") parser.add_argument('-o', '--out', help="the name of the merged template file") return parser if __name__ == "__main__": args = get_arg_parser().parse_args() # Setup the logger logger = simulationobjects.setup_logger("merge_templates_py.log") if args.files is None: raise simulationobjects.SetupError( "Nothing to do! No template files provided. Exiting.") if args.out is None: raise simulationobjects.SetupError( "A name for the merged template file needs to be provided!") tem = merge_templates(args.files) if isinstance(tem, simulationobjects.TemplateFile): tem.write(args.out)
'-p', '--plotname', help="the start of the filename for the plots generated. " "Default='theta_dist'", default="theta_dist") parser.add_argument( '--skip', help="the number of results snapshots to skip, Default = 0", default="0") return parser # # If this is run from the command-line # if __name__ == '__main__': args = get_arg_parser().parse_args() try: skip_steps = int(args.skip) except (ValueError, TypeError): simulationobjects.SetupError( "Snapshots to skip needs to be an integer. The argument %s" " could not be interpreted." % args.skip) thetas_dic = find_solute_theta(args.molecule, args.restart, args.results, skip_steps) plot_dist(thetas_dic, plotname=args.plotname)