|
41 | 41 | second discrete trajectory must have the same shape as the first |
42 | 42 | discrete trajectory. |
43 | 43 | -o |
44 | | - Output filename. |
| 44 | + Output filename of the file containing the back-jump probabilities. |
| 45 | +--norm-out |
| 46 | + Output filename of the file containing the normalization factors |
| 47 | + (optional). Multiplying the back-jump probabilities with the |
| 48 | + normalization factors yields the total number of back jumps. |
45 | 49 | -b |
46 | 50 | First frame to read from the discrete trajectory. Frame numbering |
47 | 51 | starts at zero. Default: ``0``. |
|
148 | 152 | dest="OUTFILE", |
149 | 153 | type=str, |
150 | 154 | required=True, |
151 | | - help="Output filename.", |
| 155 | + help=( |
| 156 | + "Output filename of the file containing the back-jump" |
| 157 | + " probabilities." |
| 158 | + ), |
| 159 | + ) |
| 160 | + parser.add_argument( |
| 161 | + "--norm-out", |
| 162 | + dest="OUTFILE_NORM", |
| 163 | + type=str, |
| 164 | + required=False, |
| 165 | + default=None, |
| 166 | + help=( |
| 167 | + "Output filename of the file containing the normalization factors" |
| 168 | + " (optional)." |
| 169 | + ), |
152 | 170 | ) |
153 | 171 | parser.add_argument( |
154 | 172 | "-b", |
|
300 | 318 | continuous=args.CONTINUOUS, |
301 | 319 | discard_neg=args.DISCARD_NEG, |
302 | 320 | discard_neg_btw=args.DISCARD_NEG_BTW, |
| 321 | + return_norm=args.OUTFILE_NORM is not None, |
303 | 322 | verbose=True, |
304 | 323 | ) |
| 324 | + if args.OUTFILE_NORM is not None: |
| 325 | + prob, norm = prob |
305 | 326 | del dtrj1, dtrj2 |
306 | 327 | print("Elapsed time: {}".format(datetime.now() - timer)) |
307 | 328 | print("Current memory usage: {:.2f} MiB".format(mdt.rti.mem_usage(proc))) |
308 | 329 |
|
309 | 330 | print("\n") |
310 | 331 | print("Creating output...") |
311 | 332 | timer = datetime.now() |
312 | | - header = ( |
| 333 | + header_prob = ( |
313 | 334 | "Back-jump probability: Probability to return to the initial state\n" |
314 | 335 | + "after a state transition as function of the time that has passed\n" |
315 | 336 | + "since the state transition resolved with respect to the states in\n" |
316 | 337 | + "a second discrete trajectory.\n" |
317 | | - + "\n\n" |
| 338 | + ) |
| 339 | + header_base = ( |
| 340 | + "\n\n" |
318 | 341 | + "intermittency_1: {}\n".format(args.INTERMITTENCY1) |
319 | 342 | + "intermittency_2: {}\n".format(args.INTERMITTENCY2) |
320 | 343 | + "continuous: {}\n".format(args.CONTINUOUS) |
321 | 344 | + "discard_neg: {}\n".format(args.DISCARD_NEG) |
322 | 345 | + "discard_neg_btw: {}\n".format(args.DISCARD_NEG_BTW) |
323 | 346 | + "\n\n" |
324 | 347 | ) |
325 | | - header += dtrj1_trans_info_str |
326 | | - header += "\n\n" |
327 | | - header += ( |
| 348 | + header_base += dtrj1_trans_info_str |
| 349 | + header_base += "\n\n" |
| 350 | + header_prob = header_prob + header_base |
| 351 | + header_prob += ( |
328 | 352 | "The first column contains the lag times (in trajectory steps).\n" |
329 | 353 | "The first row contains the states of the second discrete trajectory\n" |
330 | 354 | "that were used to discretize the back-jump probability.\n" |
|
333 | 357 | ) |
334 | 358 | lag_times = np.arange(0, prob.shape[1] * EVERY, EVERY, dtype=np.uint32) |
335 | 359 | mdt.fh.savetxt_matrix( |
336 | | - args.OUTFILE, prob.T, var1=lag_times, var2=dtrj2_states, header=header |
| 360 | + args.OUTFILE, |
| 361 | + prob.T, |
| 362 | + var1=lag_times, |
| 363 | + var2=dtrj2_states, |
| 364 | + header=header_prob, |
337 | 365 | ) |
338 | 366 | print("Created {}".format(args.OUTFILE)) |
| 367 | + if args.OUTFILE_NORM is not None: |
| 368 | + header_norm = ( |
| 369 | + "Normalization factors used to normalize the back-jump\n" |
| 370 | + "probabilities.\n" |
| 371 | + "Multiplying the back-jump probabilities with the normalization\n" |
| 372 | + "factors yields the total number of back jumps.\n" |
| 373 | + ) |
| 374 | + header_norm = header_norm + header_base |
| 375 | + header_norm += ( |
| 376 | + "The first column contains the lag times (in trajectory steps).\n" |
| 377 | + "The first row contains the states of the second discrete" |
| 378 | + " trajectory\n" |
| 379 | + "that were used to discretize the back-jump probability.\n" |
| 380 | + "The remaining matrix elements are the normalization factors.\n" |
| 381 | + ) |
| 382 | + mdt.fh.savetxt_matrix( |
| 383 | + args.OUTFILE_NORM, |
| 384 | + norm.T, |
| 385 | + var1=lag_times, |
| 386 | + var2=dtrj2_states, |
| 387 | + header=header_norm, |
| 388 | + ) |
| 389 | + print("Created {}".format(args.OUTFILE_NORM)) |
339 | 390 | print("Elapsed time: {}".format(datetime.now() - timer)) |
340 | 391 | print("Current memory usage: {:.2f} MiB".format(mdt.rti.mem_usage(proc))) |
341 | 392 |
|
|
0 commit comments