def get_divergence_trajectory_local(pname, fragment, block_length=150, VERBOSE=0): '''Get local divergence trajectory''' from hivwholeseq.patients.filenames import get_divergence_trajectories_local_filename fn = get_divergence_trajectories_local_filename(pname, fragment) npz = np.load(fn) return (npz['dg'], npz['ind'], npz['block_length'], npz['L'])
if use_sliding: (x, dg, ds) = get_divergence_diversity_sliding(aft, block_length, VERBOSE=VERBOSE) else: (x, dg, ds) = get_divergence_diversity_blocks(aft, block_length, VERBOSE=VERBOSE) # FIXME: avoid this var to get different conv and aft indices times = patient.times[ind] dgs[(pname, fragment)] = (patient.times[ind], dg) dss[(pname, fragment)] = (patient.times[ind], ds) if save_to_file: from hivwholeseq.patients.filenames import \ get_divergence_trajectories_local_filename, \ get_diversity_trajectories_local_filename # savez does not support masked arrays dg_save = np.array(dg).copy() dg_save[dg.mask] = -1 ds_save = np.array(ds).copy() ds_save[ds.mask] = -1 L = aft.shape[2] fn_out = get_divergence_trajectories_local_filename(pname, fragment) np.savez(fn_out, ind=ind, dg=dg_save, L=L, block_length=[block_length]) fn_out = get_diversity_trajectories_local_filename(pname, fragment) np.savez(fn_out, ind=ind, ds=ds_save, L=L, block_length=[block_length]) if VERBOSE >= 1: print 'saved to file'
dgs[(pname, fragment)] = (patient.times[ind], dg) dss[(pname, fragment)] = (patient.times[ind], ds) if save_to_file: from hivwholeseq.patients.filenames import \ get_divergence_trajectories_local_filename, \ get_diversity_trajectories_local_filename # savez does not support masked arrays dg_save = np.array(dg).copy() dg_save[dg.mask] = -1 ds_save = np.array(ds).copy() ds_save[ds.mask] = -1 L = aft.shape[2] fn_out = get_divergence_trajectories_local_filename( pname, fragment) np.savez(fn_out, ind=ind, dg=dg_save, L=L, block_length=[block_length]) fn_out = get_diversity_trajectories_local_filename( pname, fragment) np.savez(fn_out, ind=ind, ds=ds_save, L=L, block_length=[block_length]) if VERBOSE >= 1: print 'saved to file'