def main( self, jobid, lines, atoms_hessian = ['CA'], frames = 50, cutoff_distance = 10., path_python = None, verbose = False, paralleldir = '', biomolecule = None, chains = [], model = None, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates(d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix(l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose = verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## ## visualize eigenvectors ## goodvibes_core.morph( eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary, ) ## ## do plots prior to perturbation ## ## goodvibes_core.pre_perturbation_plot( ## jobid,cutoff_distance,chains,d_secondary, ## eigenvectors_nonperturbed,eigenvectors_comb_nonperturbed, ## ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) prefix = 'wt' suffix = 'vmd' goodvibes_core.overlap2structure( eigenvectors_nonperturbed, eigenvectors_nonperturbed, d_coordinates,[],d_hessian,l_coordinates,prefix,suffix, ) stop ################################################################################ ## plotdata calculation section ## ################################################################################ ## loop over remres1 for remres1 in range(N): print remres1 ## continue the remres1 loop if another processor is running calculations for that value of remres1 filename = '%s/%s_residue%s.txt' %(paralleldir, jobid, remres1+1) datadic, Continue = goodvibes_core.multiple_cpus_read(datadic,filename,remres1) if Continue == True and remres1 not in [20,21,141,19,22,140,142,]: continue ## loop over remres2 for remres2 in range(remres1+1,N): if remres2 not in [20,21,141,19,22,140,142,]: continue print remres1, remres2 l_rem = [remres1,remres2] l_coordinates_perturbed = l_coordinates[:remres1]+l_coordinates[remres1+1:remres2]+l_coordinates[remres2+1:] matrix_hessian_perturbed = self.hessian_calculation( N-2, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates_perturbed, verbose = verbose, ) ( eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined, ) = goodvibes_core.eigenv_calccomb( matrix_hessian_perturbed, jobid, verbose ) eigenvectors_nonperturbed_aligned, eigenvectors_perturbed_aligned = goodvibes_core.align_vectors_of_different_length(eigenvectors_nonperturbed, eigenvectors_perturbed, l_rem = l_rem) eigenvectors_nonperturbed_aligned, eigenvectors_perturbed_combined_aligned = goodvibes_core.align_vectors_of_different_length(eigenvectors_nonperturbed, eigenvectors_perturbed_combined, l_rem = l_rem) ( overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_aligned, eigenvectors_nonperturbed_aligned, eigenvalues_perturbed, eigenvalues_nonperturbed, ) ( overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined_aligned, eigenvectors_nonperturbed_aligned, eigenvalues_perturbed, eigenvalues_nonperturbed, )[:-1] datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6,12): datadic[key]['data'][mode][remres1][remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][remres1] = overlaps_combined[-1] print overlaps_single[6] prefix = '%s' %(jobid) suffix = '%s_%s' %(remres1+1, remres2+1) goodvibes_core.overlap2structure( eigenvectors_nonperturbed, eigenvectors_perturbed, d_coordinates,l_rem,d_hessian,l_coordinates,prefix,suffix, ) prefix = '%s' %(jobid) suffix = '%s_%s' %(remres1+1, remres2+1) goodvibes_core.vmdarrow( eigenvectors_perturbed,d_hessian, prefix,suffix,l_rem=l_rem, ) if overlaps_single[6] > 0.9: print overlaps_single[6] print remres1+1, remres2+1 ## stop ## ## ## ## write data to txt files in case of crash during loop over residues/clusters ## ## ## filename = '%s/%s_residue%s.txt' %(paralleldir, jobid, remres1+1) ## goodvibes_core.multiple_cpus_write(datadic,filename,remres1) ## ## ## ## do plots for perturbation results ## ## ## if verbose == True: ## print 'generating plots' ## goodvibes_core.post_perturbation_plot( ## datadic, jobid, chains, cutoff_distance, d_hessian, N, d_secondary, d_coordinates, ## ) return
def main( self, jobid, lines, atoms_hessian = ['CA'], frames = 50, cutoff_distance = 10., path_html = None, path_python = None, verbose = False, paralleldir = '', chains = None, ): import goodvibes_core ## ## parse pdb ## ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates(d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix(l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose = verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_combined_nonperturbed = goodvibes_core.eigenv_calccomb(matrix_hessian, jobid, verbose) ## ## visualize eigenvectors ## goodvibes_core.morph(eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary) ## ## do plots prior to perturbation ## goodvibes_core.pre_perturbation_plot( jobid,cutoff_distance,chains,d_secondary, eigenvectors_nonperturbed,eigenvectors_combined_nonperturbed, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) ## ## loop over remres1 ## for remres1 in range(N-1): ## continue the remres1 loop if another processor is running calculations for that value of remres1 filename = '%s/%s_residue%s.txt' %(paralleldir, jobid, remres1+1) datadic, Continue = goodvibes_core.multiple_cpus_read(datadic,filename,remres1) if Continue == True: continue ## ## loop over remres2 ## for remres2 in range(remres1+1,N): print remres1, remres2 l_mod = [remres1,remres2] ## ## calculate hessian matrix ## matrix_hessian_perturbed = self.hessian_calculation( N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose = verbose, l_mod = l_mod, ) ## ## diagonalize hessian matrix and calculate eigenvectors ## ( eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined ) = goodvibes_core.eigenv_calccomb( matrix_hessian_perturbed, jobid, verbose ) ## ## calculate overlap between eigenvectors ## ( overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, ) ( overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, )[:-1] print overlaps_single[6] datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6,12): datadic[key]['data'][mode][remres1][remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][remres1] = overlaps_combined[-1] ## write data to txt files in case of crash during loop over residues/clusters filename = '%s/%s_residue%s.txt' %(paralleldir, jobid, remres1+1) goodvibes_core.multiple_cpus_write(datadic,filename,remres1) ## ## do plots for perturbation results ## if verbose == True: print 'generating plots' goodvibes_core.post_perturbation_plot( datadic, jobid, chains, cutoff_distance, d_hessian, N, d_secondary, d_coordinates, ) return
def main( self, jobid, lines, atoms_hessian=['CA'], frames=50, cutoff_distance=10., path_html=None, path_python=None, verbose=False, paralleldir='', chains=None, winsize=1, pre_perturbation_plot=True, polyhedron=None, ): import goodvibes_core ## ## parse pdb ## ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates( d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix( l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, matrix_distances, d_coordinates, float(cutoff_distance), l_coordinates, verbose=verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_combined_nonperturbed = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose) ## ## visualize eigenvectors ## goodvibes_core.morph(eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary) ## ## do plots prior to perturbation ## if pre_perturbation_plot == True: goodvibes_core.pre_perturbation_plot( jobid, cutoff_distance, chains, d_secondary, eigenvectors_nonperturbed, eigenvectors_combined_nonperturbed, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) d_vertices = { 'tetrahedron': 4, 'hexahedron': 8, 'octahedron': 6, 'icosahedron': 12, } ## ## loop over remres1 ## for remres1 in range((winsize - 1) / 2, N - winsize - (winsize - 1) / 2): resrange1 = range(remres1 - (winsize - 1) / 2, remres1 + (winsize - 1) / 2 + 1) l_c1 = [] for res1 in resrange1: c1 = l_coordinates[res1] l_c1 += goodvibes_core.platonicsolid(c1, polyhedron=polyhedron) ## continue the remres1 loop if another processor is running calculations for that value of remres1 filename = '%s/%s_residue%s.txt' % (paralleldir, jobid, remres1 + 1) datadic, Continue = goodvibes_core.multiple_cpus_read( datadic, filename, remres1) if Continue == True: continue ## ## loop over remres2 ## for remres2 in range(remres1 + 2 * (winsize - 1) / 2 + 1, N - (winsize - 1) / 2): print remres1, remres2 resrange2 = range(remres2 - (winsize - 1) / 2, remres2 + (winsize - 1) / 2 + 1) l_c2 = [] for res2 in resrange2: c2 = l_coordinates[res2] l_c2 += goodvibes_core.platonicsolid(c2, polyhedron=polyhedron) l_add = [] n_vertices = d_vertices[polyhedron] for i in range(n_vertices * (2 * winsize)): l_add += [N + i] l_coordinates_perturbed = l_coordinates + l_c1 + l_c2 matrix_hessian_perturbed = self.hessian_calculation( N, matrix_distances, d_coordinates, float(cutoff_distance), l_coordinates_perturbed, verbose=verbose, ) (eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined ) = goodvibes_core.eigenv_calccomb(matrix_hessian_perturbed, jobid, verbose) (overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_add=l_add) (overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_add=l_add, )[:-1] print overlaps_single[6] ## ## do vmd of perturbed structure ## self.morph(eigenvectors, frames, biomolecule, d_coordinates, atoms_hessian, cluster, matrix_hessian, jobid+'-'+str(xvalue)+'-'+str(yvalue), cutoff_distance) datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6, 12): datadic[key]['data'][mode][remres1][ remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][ remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][ remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][ remres1] = overlaps_combined[-1] ## write data to txt files in case of crash during loop over residues/clusters filename = '%s/%s_residue%s.txt' % (paralleldir, jobid, remres1 + 1) goodvibes_core.multiple_cpus_write(datadic, filename, remres1) ## ## do plots for perturbation results ## if verbose == True: print 'generating plots' goodvibes_core.post_perturbation_plot( datadic, jobid, chains, cutoff_distance, d_hessian, N, d_secondary, d_coordinates, winsize=winsize, ) return
def main( self, jobid, lines, atoms_hessian=['CA'], frames=50, cutoff_distance=10., path_python=None, verbose=False, paralleldir='', biomolecule=None, chains=[], model=None, winsize=1, pre_perturbation_plot=True, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates( d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix( l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose=verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## ## visualize eigenvectors ## goodvibes_core.morph( eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary, ) ## ## ## ## do plots prior to perturbation ## ## ## if pre_perturbation_plot == True: ## goodvibes_core.pre_perturbation_plot( ## jobid,cutoff_distance,chains,d_secondary, ## eigenvectors_nonperturbed,eigenvectors_comb_nonperturbed, ## ) return
def main( self, jobid, lines, atoms_hessian = ['CA'], frames = 50, cutoff_distance = 10., path_python = None, verbose = False, paralleldir = '', biomolecule = None, chains = [], model = None, winsize = 1, pre_perturbation_plot = True, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates(d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix(l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose = verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## ## visualize eigenvectors ## goodvibes_core.morph( eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary, ) ## ## ## ## do plots prior to perturbation ## ## ## if pre_perturbation_plot == True: ## goodvibes_core.pre_perturbation_plot( ## jobid,cutoff_distance,chains,d_secondary, ## eigenvectors_nonperturbed,eigenvectors_comb_nonperturbed, ## ) return
def main( self, jobid, lines, atoms_hessian=['CA'], frames=50, cutoff_distance=10., path_html=None, path_python=None, verbose=False, paralleldir='', chains=None, ): import goodvibes_core ## ## parse pdb ## ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates( d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix( l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose=verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_combined_nonperturbed = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose) ## ## visualize eigenvectors ## goodvibes_core.morph(eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary) ## ## do plots prior to perturbation ## goodvibes_core.pre_perturbation_plot( jobid, cutoff_distance, chains, d_secondary, eigenvectors_nonperturbed, eigenvectors_combined_nonperturbed, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) ## ## loop over remres1 ## for remres1 in range(N - 1): ## continue the remres1 loop if another processor is running calculations for that value of remres1 filename = '%s/%s_residue%s.txt' % (paralleldir, jobid, remres1 + 1) datadic, Continue = goodvibes_core.multiple_cpus_read( datadic, filename, remres1) if Continue == True: continue ## ## loop over remres2 ## for remres2 in range(remres1 + 1, N): print remres1, remres2 l_mod = [remres1, remres2] ## ## calculate hessian matrix ## matrix_hessian_perturbed = self.hessian_calculation( N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose=verbose, l_mod=l_mod, ) ## ## diagonalize hessian matrix and calculate eigenvectors ## (eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined ) = goodvibes_core.eigenv_calccomb(matrix_hessian_perturbed, jobid, verbose) ## ## calculate overlap between eigenvectors ## (overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, ) (overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, )[:-1] print overlaps_single[6] datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6, 12): datadic[key]['data'][mode][remres1][ remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][ remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][ remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][ remres1] = overlaps_combined[-1] ## write data to txt files in case of crash during loop over residues/clusters filename = '%s/%s_residue%s.txt' % (paralleldir, jobid, remres1 + 1) goodvibes_core.multiple_cpus_write(datadic, filename, remres1) ## ## do plots for perturbation results ## if verbose == True: print 'generating plots' goodvibes_core.post_perturbation_plot( datadic, jobid, chains, cutoff_distance, d_hessian, N, d_secondary, d_coordinates, ) return
def main( self, jobid, filename, atoms_hessian=['CA'], frames=50, cutoff_distance=10., path_python=None, verbose=False, paralleldir='', biomolecule=None, chains=[], model=None, winsize=1, pre_perturbation_plot=True, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] fd = open(filename, 'r') lines = fd.readlines() fd.close() ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates( d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix( l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose=verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) ## ## loop over remres1 ## for remres1 in range((winsize - 1) / 2, N - winsize - (winsize - 1) / 2): ## ## loop over remres2 ## for remres2 in range(remres1 + 2 * (winsize - 1) / 2 + 1, N - (winsize - 1) / 2): print remres1, remres2 l_rem = [] for i in range(-(winsize - 1) / 2, (winsize + 1) / 2): l_rem += [remres1 + i, remres2 + i] l_rem.sort() ## ## remove selected alpha carbon atoms!!! ## l_coordinates_perturbed = l_coordinates[:remres1 - ( winsize - 1) / 2] + l_coordinates[ remres1 + 1 + (winsize - 1) / 2:remres2 - (winsize - 1) / 2] + l_coordinates[remres2 + 1 + (winsize - 1) / 2:] matrix_hessian_perturbed = self.hessian_calculation( N - len(l_rem), d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates_perturbed, verbose=verbose, ) ( eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined, ) = goodvibes_core.eigenv_calccomb(matrix_hessian_perturbed, jobid, verbose) ( overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem) ( overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem, )[:-1] datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6, 12): datadic[key]['data'][mode][remres1][ remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][ remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][ remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][ remres1] = overlaps_combined[-1] print overlaps_single[6] l_averages = [] for remres1 in range(len(datadic['overlaps_single']['data'][6])): l_overlaps = [] for remres2 in range( len(datadic['overlaps_single']['data'][6][remres1])): overlap = datadic['overlaps_single']['data'][6][remres1][ remres2] l_overlaps += [overlap] l_averages += [sum(l_overlaps) / len(l_overlaps)] return l_averages
def main( self, jobid, lines, atoms_hessian = ['CA'], frames = 50, cutoff_distance = 10., path_python = None, verbose = False, paralleldir = '', biomolecule = None, chains = [], model = None, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates(d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix(l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose = verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## fd = open('/oxygenase_local/data/pdb/50/pdb150l.ent','r') fd = open('/oxygenase_local/data/pdb/lz/pdb2lzm.ent','r') lines = fd.readlines() fd.close() ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) N, d_hessian, l_coordinates2 = goodvibes_core.parse_dictionary_of_coordinates(d_coordinates, chains, atoms_hessian) if len(l_coordinates) != len(l_coordinates2): print len(l_coordinates), len(l_coordinates2) stop ## import geometry import sys sys.path.append('/home/people/tc/svn/Protool/trunk/') import geometry instance_geometry = geometry.geometry() ## superpose rmsd = instance_geometry.superpose(l_coordinates,l_coordinates2) tv1 = instance_geometry.fitcenter rm = instance_geometry.rotation tv2 = instance_geometry.refcenter print rmsd ## calculate differences l_differences = [] for i in range(len(l_coordinates)): coord1 = l_coordinates[i] coord2 = Numeric.matrixmultiply(l_coordinates2[i]-tv1,rm)+tv2 l_differences += [ coord1[0]-coord2[0], coord1[1]-coord2[1], coord1[2]-coord2[2], ] vector_difference = Numeric.array(l_differences) import math for mode in range(20): vector_nonperturbed = eigenvectors_nonperturbed[mode] overlap = math.fabs(goodvibes_core.cosangle(vector_nonperturbed, vector_difference)) overlaps = [] for i in range(0,164,3): numerator = ( vector_nonperturbed[i+0]*vector_difference[i+0]+ vector_nonperturbed[i+1]*vector_difference[i+1]+ vector_nonperturbed[i+2]*vector_difference[i+2] ) denominator = ( math.sqrt(vector_nonperturbed[i+0]**2+vector_nonperturbed[i+1]**2+vector_nonperturbed[i+2]**2)* math.sqrt(vector_difference[i+0]**2+vector_difference[i+1]**2+vector_difference[i+2]**2) ) overlaps += [numerator/denominator] if mode == 6: print sum(overlaps)/len(overlaps) print mode, overlap stop ## ## visualize eigenvectors ## goodvibes_core.morph( eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary, ) ## ## do plots prior to perturbation ## ## goodvibes_core.pre_perturbation_plot( ## jobid,cutoff_distance,chains,d_secondary, ## eigenvectors_nonperturbed,eigenvectors_comb_nonperturbed, ## ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) return
def main( self, jobid, lines, atoms_hessian=['CA'], frames=50, cutoff_distance=10., path_python=None, verbose=False, paralleldir='', biomolecule=None, chains=[], model=None, winsize=1, pre_perturbation_plot=True, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates( d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix( l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose=verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## ## visualize eigenvectors ## goodvibes_core.morph( eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary, ) ## ## do plots prior to perturbation ## if pre_perturbation_plot == True: goodvibes_core.pre_perturbation_plot( jobid, cutoff_distance, chains, d_secondary, eigenvectors_nonperturbed, eigenvectors_comb_nonperturbed, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## range2 = [ 0, 4, 8, 16, ] datadic = goodvibes_core.datadic_return( N, range2=range2, ) ## ## loop over remres1 ## for remres1 in range(N): ## ## continue the remres1 loop if another processor is running calculations for that value of remres1 ## filename = '%s/%s_residue%s.txt' % (paralleldir, jobid, remres1 + 1) datadic, Continue = goodvibes_core.multiple_cpus_read( datadic, filename, remres1) if Continue == True: continue ## ## loop over remres2 ## for remres2 in range2: sphere_radius = remres2 sq_sphere_radius = sphere_radius**2 print remres1, sphere_radius l_rem = [] for res in range(len(matrix_distances[remres1])): if matrix_distances[remres1][res] < sq_sphere_radius: l_rem += [res] l_rem.sort() ## ## remove selected alpha carbon atoms!!! ## l_coordinates_perturbed = [] for res in range(len(l_coordinates)): if res not in l_rem: l_coordinates_perturbed += [l_coordinates[res]] matrix_hessian_perturbed = self.hessian_calculation( N - len(l_rem), d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates_perturbed, verbose=verbose, ) ( eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined, ) = goodvibes_core.eigenv_calccomb(matrix_hessian_perturbed, jobid, verbose) ( overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem) ( overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem, )[:-1] datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6, 12): datadic[key]['data'][mode][remres1][ remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][ remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][ remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][ remres1] = overlaps_combined[-1] print overlaps_single[6] ## ## write data to txt files in case of crash during loop over residues/clusters ## filename = '%s/%s_residue%s.txt' % (paralleldir, jobid, remres1 + 1) goodvibes_core.multiple_cpus_write(datadic, filename, remres1) ## ## do plots for perturbation results ## if verbose == True: print 'generating plots' goodvibes_core.post_perturbation_plot( datadic, jobid, chains, cutoff_distance, d_hessian, N, d_secondary, d_coordinates, winsize=winsize, ) d_overlaps = {} for sphere in range2: d_overlaps[sphere] = [] for res in range(N): fd = open('2lzm_residue%s.txt' % (res + 1)) lines = fd.readlines() fd.close() parse = False for i in range(len(lines)): line = lines[i] if 'data overlaps_' in line: for sphere in range2: overlap = float(lines[i + 2 + sphere]) d_overlaps[sphere] += [overlap] break for sphere_radius in range2: l_overlaps = d_overlaps[sphere_radius] goodvibes_core.write_overlaps_to_pdb_file( d_coordinates, d_hessian, l_overlaps, 6, jobid + 'sphere%s' % (sphere_radius), winsize=winsize, ) return
def main( self, jobid, lines, atoms_hessian=["CA"], frames=50, cutoff_distance=10.0, path_html=None, path_python=None, verbose=False, paralleldir="", chains=None, winsize=1, pre_perturbation_plot=True, polyhedron=None, ): import goodvibes_core ## ## parse pdb ## ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates( d_coordinates, chains, atoms_hessian ) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix(l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation( N, matrix_distances, d_coordinates, float(cutoff_distance), l_coordinates, verbose=verbose ) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_combined_nonperturbed = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose ) ## ## visualize eigenvectors ## goodvibes_core.morph(eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary) ## ## do plots prior to perturbation ## if pre_perturbation_plot == True: goodvibes_core.pre_perturbation_plot( jobid, cutoff_distance, chains, d_secondary, eigenvectors_nonperturbed, eigenvectors_combined_nonperturbed, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) d_vertices = {"tetrahedron": 4, "hexahedron": 8, "octahedron": 6, "icosahedron": 12} ## ## loop over remres1 ## for remres1 in range((winsize - 1) / 2, N - winsize - (winsize - 1) / 2): resrange1 = range(remres1 - (winsize - 1) / 2, remres1 + (winsize - 1) / 2 + 1) l_c1 = [] for res1 in resrange1: c1 = l_coordinates[res1] l_c1 += goodvibes_core.platonicsolid(c1, polyhedron=polyhedron) ## continue the remres1 loop if another processor is running calculations for that value of remres1 filename = "%s/%s_residue%s.txt" % (paralleldir, jobid, remres1 + 1) datadic, Continue = goodvibes_core.multiple_cpus_read(datadic, filename, remres1) if Continue == True: continue ## ## loop over remres2 ## for remres2 in range(remres1 + 2 * (winsize - 1) / 2 + 1, N - (winsize - 1) / 2): print remres1, remres2 resrange2 = range(remres2 - (winsize - 1) / 2, remres2 + (winsize - 1) / 2 + 1) l_c2 = [] for res2 in resrange2: c2 = l_coordinates[res2] l_c2 += goodvibes_core.platonicsolid(c2, polyhedron=polyhedron) l_add = [] n_vertices = d_vertices[polyhedron] for i in range(n_vertices * (2 * winsize)): l_add += [N + i] l_coordinates_perturbed = l_coordinates + l_c1 + l_c2 matrix_hessian_perturbed = self.hessian_calculation( N, matrix_distances, d_coordinates, float(cutoff_distance), l_coordinates_perturbed, verbose=verbose ) ( eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined, ) = goodvibes_core.eigenv_calccomb(matrix_hessian_perturbed, jobid, verbose) ( overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_add=l_add, ) ( overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_add=l_add, )[ :-1 ] print overlaps_single[6] ## ## do vmd of perturbed structure ## self.morph(eigenvectors, frames, biomolecule, d_coordinates, atoms_hessian, cluster, matrix_hessian, jobid+'-'+str(xvalue)+'-'+str(yvalue), cutoff_distance) datadic_loop = { "eigenvalues_perturbed": eigenvalues_perturbed, "emo": delta_perturbed_eigenvalues_of_max_overlap, "overlaps_single": overlaps_single, "overlaps_max": max_overlaps_single, "mmo": perturbed_modes_of_max_overlap_single, "overlaps_combined": overlaps_combined, } for key in datadic: for mode in range(6, 12): datadic[key]["data"][mode][remres1][remres2] = datadic_loop[key][mode] datadic[key]["data"][mode][remres2][remres1] = datadic_loop[key][mode] datadic["overlaps_combined"]["data"][-1][remres1][remres2] = overlaps_combined[-1] datadic["overlaps_combined"]["data"][-1][remres2][remres1] = overlaps_combined[-1] ## write data to txt files in case of crash during loop over residues/clusters filename = "%s/%s_residue%s.txt" % (paralleldir, jobid, remres1 + 1) goodvibes_core.multiple_cpus_write(datadic, filename, remres1) ## ## do plots for perturbation results ## if verbose == True: print "generating plots" goodvibes_core.post_perturbation_plot( datadic, jobid, chains, cutoff_distance, d_hessian, N, d_secondary, d_coordinates, winsize=winsize ) return
def main( self, jobid, lines, atoms_hessian = ['CA'], frames = 50, cutoff_distance = 10., path_python = None, verbose = False, paralleldir = '', biomolecule = None, chains = [], model = None, winsize = 1, pre_perturbation_plot = True, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates(d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix(l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose = verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## ## visualize eigenvectors ## goodvibes_core.morph( eigenvectors_nonperturbed, frames, chains, d_coordinates, jobid, d_primary, ) ## ## do plots prior to perturbation ## if pre_perturbation_plot == True: goodvibes_core.pre_perturbation_plot( jobid,cutoff_distance,chains,d_secondary, eigenvectors_nonperturbed,eigenvectors_comb_nonperturbed, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## range2 = range(1,13,2) datadic = goodvibes_core.datadic_return(N,range2=range2,) ## ## loop over remres1 ## for remres1 in range(N): ## ## continue the remres1 loop if another processor is running calculations for that value of remres1 ## filename = '%s/%s_residue%s.txt' %(paralleldir, jobid, remres1+1) datadic, Continue = goodvibes_core.multiple_cpus_read(datadic,filename,remres1) if Continue == True: continue ## ## loop over winsize ## for remres2 in range2: winsize = remres2 print remres1, winsize if remres1-(winsize-1)/2 < 0 or remres1+(winsize-1)/2 > N-1: continue l_rem = range(remres1-(winsize-1)/2,remres1+(winsize+1)/2) print '*****', l_rem ## ## remove selected alpha carbon atoms!!! ## l_coordinates_perturbed = [] for res in range(len(l_coordinates)): if res not in l_rem: l_coordinates_perturbed += [l_coordinates[res]] matrix_hessian_perturbed = self.hessian_calculation( N-len(l_rem), d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates_perturbed, verbose = verbose, ) ( eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined, ) = goodvibes_core.eigenv_calccomb( matrix_hessian_perturbed, jobid, verbose ) ( overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem = l_rem, ) ( overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem = l_rem, )[:-1] datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6,12): datadic[key]['data'][mode][remres1][remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][remres1] = overlaps_combined[-1] print overlaps_single[6] ## ## write data to txt files in case of crash during loop over residues/clusters ## filename = '%s/%s_residue%s.txt' %(paralleldir, jobid, remres1+1) goodvibes_core.multiple_cpus_write(datadic,filename,remres1) ## ## do plots for perturbation results ## if verbose == True: print 'generating plots' goodvibes_core.post_perturbation_plot( datadic, jobid, chains, cutoff_distance, d_hessian, N, d_secondary, d_coordinates, winsize = winsize, ) return
def main( self, jobid, filename, atoms_hessian = ['CA'], frames = 50, cutoff_distance = 10., path_python = None, verbose = False, paralleldir = '', biomolecule = None, chains = [], model = None, winsize = 1, pre_perturbation_plot = True, ): ''' Use first model if no model specified by user. chain(s): Y, biomolecule: Y; parse chains specified by user and apply transformation chain(s): Y, biomolecule: N; parse chains specified by user but don't apply transformation chain(s): N, biomolecule: Y; parse chains of biomolecule and apply transformation chain(s): N, biomolecule: N; parse chains of first biomolecule and apply transformation ''' import os, Numeric, goodvibes_core results = [] fd = open(filename,'r') lines = fd.readlines() fd.close() ## parse pdb ( d_REMARK350, d_primary, ## i.e. SEQRES, MODRES d_secondary, ## i.e. HELIX, SHEET d_coordinates, ## i.e. ATOM, HETATM, TER, MODEL, ENDMDL d_ligands, ) = goodvibes_core.parse_pdb(lines, chains) ## assume multimeric biological unit if chains not specified by user if chains == []: chains = d_coordinates['chains'].keys() chains.sort() ## ## calculate N and convert coordinates from dic to list ## N, d_hessian, l_coordinates = goodvibes_core.parse_dictionary_of_coordinates(d_coordinates, chains, atoms_hessian) ## ## calculate distance matrix ## matrix_distances = goodvibes_core.calculate_distance_matrix(l_coordinates) ## ## calculate hessian matrix ## matrix_hessian = self.hessian_calculation(N, d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates, verbose = verbose) ## ## diagonalize hessian matrix ## eigenvectors_nonperturbed, eigenvalues_nonperturbed, eigenvectors_comb_nonperturbed, = goodvibes_core.eigenv_calccomb( matrix_hessian, jobid, verbose, ) ## ## set data lists and append matrices to be plotted for each combination of modes 6-12 before initiating loops over the two axes of the plot ## datadic = goodvibes_core.datadic_return(N) ## ## loop over remres1 ## for remres1 in range((winsize-1)/2,N-winsize-(winsize-1)/2): ## ## loop over remres2 ## for remres2 in range(remres1+2*(winsize-1)/2+1,N-(winsize-1)/2): print remres1, remres2 l_rem = [] for i in range(-(winsize-1)/2,(winsize+1)/2): l_rem += [remres1+i,remres2+i] l_rem.sort() ## ## remove selected alpha carbon atoms!!! ## l_coordinates_perturbed = l_coordinates[:remres1-(winsize-1)/2]+l_coordinates[remres1+1+(winsize-1)/2:remres2-(winsize-1)/2]+l_coordinates[remres2+1+(winsize-1)/2:] matrix_hessian_perturbed = self.hessian_calculation( N-len(l_rem), d_coordinates, chains, atoms_hessian, float(cutoff_distance), d_secondary, matrix_distances, l_coordinates_perturbed, verbose = verbose, ) ( eigenvectors_perturbed, eigenvalues_perturbed, eigenvectors_perturbed_combined, ) = goodvibes_core.eigenv_calccomb( matrix_hessian_perturbed, jobid, verbose ) ( overlaps_single, max_overlaps_single, perturbed_modes_of_max_overlap_single, delta_perturbed_eigenvalues_of_max_overlap, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem ) ( overlaps_combined, max_overlaps_combined, perturbed_modes_of_max_overlap_combined, ) = goodvibes_core.overlap_calculation( eigenvectors_perturbed_combined, eigenvectors_nonperturbed, eigenvalues_perturbed, eigenvalues_nonperturbed, l_rem, )[:-1] datadic_loop = { 'eigenvalues_perturbed': eigenvalues_perturbed, 'emo': delta_perturbed_eigenvalues_of_max_overlap, 'overlaps_single': overlaps_single, 'overlaps_max': max_overlaps_single, 'mmo': perturbed_modes_of_max_overlap_single, 'overlaps_combined': overlaps_combined } for key in datadic: for mode in range(6,12): datadic[key]['data'][mode][remres1][remres2] = datadic_loop[key][mode] datadic[key]['data'][mode][remres2][remres1] = datadic_loop[key][mode] datadic['overlaps_combined']['data'][-1][remres1][remres2] = overlaps_combined[-1] datadic['overlaps_combined']['data'][-1][remres2][remres1] = overlaps_combined[-1] print overlaps_single[6] l_averages = [] for remres1 in range(len(datadic['overlaps_single']['data'][6])): l_overlaps = [] for remres2 in range(len(datadic['overlaps_single']['data'][6][remres1])): overlap = datadic['overlaps_single']['data'][6][remres1][remres2] l_overlaps += [overlap] l_averages += [sum(l_overlaps)/len(l_overlaps)] return l_averages