def calculate_binned_contacts_vs_q(args):
    trajsfile = args.trajs
    function = args.function
    coordfile = args.coordfile
    coordname = coordfile.split(".")[0]
    bins = args.bins
    chunksize = args.chunksize
    topology = args.topology
    periodic = args.periodic

    # Data source
    trajfiles = ["%s" % x.rstrip("\n") for x in open(trajsfile, "r").readlines()]
    dir = os.path.dirname(trajfiles[0])

    # Parameterize contact-based reaction coordinate
    pairs, contact_params = util.get_contact_params(dir, args)
    coord_sources = ["%s/%s" % (os.path.dirname(trajfiles[i]), coordfile) for i in range(len(trajfiles))]

    if not all([os.path.exists(x) for x in coord_sources]):
        # Parameterize contact-based reaction coordinate
        contact_function = util.get_sum_contact_function(pairs, function, contact_params, periodic=periodic)

        # Calculate contact function over directories
        contacts = util.calc_coordinate_multiple_trajs(
            trajfiles,
            contact_function,
            topology,
            chunksize,
            save_coord_as=args.coordfile,
            savepath=args.savepath,
            collect=True,
        )
    else:
        # Load precalculated coordinate
        contacts = [np.loadtxt(coord_sources[i]) for i in range(len(coord_sources))]

    # Parameterize pairwise contact function
    pairwise_contact_function = util.get_pair_contact_function(pairs, function, contact_params, periodic=periodic)

    # Calculate pairwise contacts over directories
    bin_edges, avgqi_by_bin = util.bin_multiple_coordinates_for_multiple_trajs(
        trajfiles, contacts, pairwise_contact_function, pairs.shape[0], bins, topology, chunksize
    )

    return bin_edges, avgqi_by_bin
Exemple #2
0
            help='Directory to save in.')

    args = parser.parse_args()
    return args

if __name__ == "__main__":
    args = get_args()

    trajsfile = args.trajs
    function = args.function 
    topology = args.topology
    chunksize = args.chunksize
    periodic = args.periodic

    # Data source
    trajfiles = [ "%s" % x.rstrip("\n") for x in open(trajsfile,"r").readlines() ]
    dir = os.path.dirname(trajfiles[0])

    if args.saveas is None:
        save_coord_as = {"step":"Q.dat","tanh":"Qtanh.dat","w_tanh":"Qtanh_w.dat"}[function]
    else:
        save_coord_as = args.saveas

    # Parameterize contact-based reaction coordinate
    pairs, contact_params = util.get_contact_params(dir,args)
    contact_function = util.get_sum_contact_function(pairs,function,contact_params,periodic=periodic)

    # Calculate contact function over directories
    util.calc_coordinate_multiple_trajs(trajfiles,contact_function,topology,chunksize,save_coord_as=save_coord_as,savepath=args.savepath)