How to use the prody.writePDB function in ProDy

To help you get started, we’ve selected a few ProDy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github corredD / ePMV / demo / testPrody.py View on Github external
anm.buildHessian(p38ca)
anm.calcModes()

#traverseMode() function generates conformations along a single normal mode. 
#Conformations are generated in both directions along the given mode. 
#rmsd argument is used to set the RMSD distance to the farthest conformation.
#Let’s generate 10 conformations along ANM mode 1:
trajectory = prody.traverseMode(anm[0], p38ca, n_steps=5, rmsd=2.0)
coords=trajectory.getCoordsets()
#conformation...

#dumb->read in epmv or read on the fly?
p38traj = p38ca.copy()
p38traj.delCoordset(0)
p38traj.addCoordset( trajectory )
prody.writePDB('p38_mode1_trajectory.pdb', p38traj)
def computeNormalMode(userfilenamein="",userfilenameout="NMA.pdb", usermode=0,userrmsd=0.8, usernbconf=5, conf="allatom", usercutoff=15.0, usergamma=1.0) : 
	mystruct = prody.parsePDB(userfilenamein, model=1)
	mystruct_ca = mystruct.select('protein and name CA')

	anm = prody.ANM(userfilenamein+str(usermode))
	anm.buildHessian(mystruct_ca, gamma=usergamma, cutoff=usercutoff)
	anm.calcModes()
	
	bb_anm, bb_atoms = extrapolateModel(anm, mystruct_ca, mystruct.select(conf))
	ensemble = sampleModes(bb_anm[usermode], bb_atoms, n_confs=usernbconf, rmsd=userrmsd)
	nmastruct = mystruct.copy( bb_atoms )
	nmastruct.addCoordset(ensemble)
			
	writePDB(userfilenameout, nmastruct)
github prody / ProDy / prody / dynamics / saxs.py View on Github external
sys.stdout.write("\b" * (numFrames+2)) # return to start of line, after '['
    LOGGER.timeit('_intplt_mode')
    invEigVal = (1.0/eigenvalue)
    for j in range((-numFrames/2), ((numFrames/2)+1)):
        coeff = j*scalCoeff*invEigVal*2.0/numFrames
        
        newCoords = calphas.getCoords().flatten()+(coeff*eigenvector)
        calphas.setCoords(newCoords.reshape((numCalphas, 3), order='C'))
        calcSaxsPerModel(calphas, I_model, Q_exp)
        chi = calcSaxsChi(Q_exp, I_q_exp, sigma_q, Q_exp, I_model)
        chi_list.append(chi)
        frames_list.append(j)
        if(chi < max_chi):
            max_chi = chi
            mod_num = i
            writePDB(out_pdb_file, calphas)
#           extendModel(calphas, 'calphas', protein)
#           writePDB('best_model.pdb', protein)

            #Reset coordinates to the original values
        calphas.setCoords(origCoords)
            
        sys.stdout.write('#')
        sys.stdout.flush()
    sys.stdout.write("\n")
    LOGGER.report('SAXS profile calculations were performed in %2fs.', '_intplt_mode')
    
    return chi_list, frames_list
github prody / ProDy / prody / scripts.py View on Github external
pdb = args[0]
    prefix, biomol = opt.prefix, opt.biomol
        
    pdb, header = prody.parsePDB(pdb, header=True)
    if prefix == '':
        prefix = pdb.getTitle()
        
    biomols = prody.buildBiomolecules(header, pdb, biomol=biomol)
    if not isinstance(biomols, list):
        biomols = [biomols]
    
    for i, biomol in enumerate(biomols):
        if isinstance(biomol, prody.Atomic):
            outfn = '{0:s}_biomol_{1:d}.pdb'.format(prefix, i+1)
            LOGGER.info('Writing {0:s}'.format(outfn))
            prody.writePDB(outfn, biomol)
        elif isinstance(biomol, tuple):
            for j, part in enumerate(biomol):
                outfn = ('{0:s}_biomol_{1:d}_part_{2:d}.pdb'
                         .format(prefix, i+1, j+1))
                LOGGER.info('Writing {0:s}'.format(outfn))
                prody.writePDB(outfn, part)
github victor-gil-sepulveda / pyProCT / pyproct / protocol / saveTools.py View on Github external
"""
    results_directory = workspace_handler["results"]

    # Merge pdbs (in order)
    temporary_merged_trajectory_path = os.path.join(workspace_handler["tmp"],"tmp_merged_trajectory.pdb")

#===========================================================
    # THIS DOES NOT WORK IF USING DCD FILES
#     merge_pdbs(trajectory_holder,
#                temporary_merged_trajectory_path,
#                do_merged_files_have_correlative_models)

    # TEMPORARY HACK TO OVERCOME DCD MERGING BUG

    merged_pdb = trajectory_holder.getMergedStructure()
    prody.writePDB(temporary_merged_trajectory_path, merged_pdb)
#==========================================================

    # Extract frames from the merged pdb
    file_handler_in = open(temporary_merged_trajectory_path,"r")
    file_handler_out = open(os.path.join(results_directory,"%s.pdb"%pdb_name),"w")

    pdb_tools.extract_frames_from_trajectory_sequentially (file_handler_in = file_handler_in,
                                             number_of_frames = pdb_tools.get_number_of_frames(temporary_merged_trajectory_path),
                                             file_handler_out = file_handler_out,
                                             frames_to_save = representatives,
                                             write_frame_number_instead_of_correlative_model_number = write_frame_number_instead_of_correlative_model_number,
                                             keep_header = keep_remarks)
    file_handler_in.close()
    file_handler_out.close()

    return os.path.join(results_directory,"%s.pdb"%pdb_name)
github victor-gil-sepulveda / pyProCT / validation / conformations / generateTrajectoryWithDiffuseClusters.py View on Github external
numatoms = len(base_coordinates)
        for j in range(len(cluster_frames)):
            if i!= j:
                directions = input_coordsets[j] - base_coordinates

                displacement_magnitudes = numpy.random.exponential(scale = 1, size = 20)
                displacement_magnitudes /= numpy.max(displacement_magnitudes)
                displacement_magnitudes *= (MAX_SIMILARITY-MIN_SIMILARITY)
                displacement_magnitudes += MIN_SIMILARITY

                step = (MAX_SIMILARITY-MIN_SIMILARITY) / MAX_TRIES
                for k in range(MAX_TRIES):
                    pdb.addCoordset(numpy.array([((MIN_SIMILARITY+(step*k))*directions.T).T+base_coordinates]))

    print_matrix(pdb.select("name CA").getCoordsets(), output+"_big")
    prody.writePDB(output+".pdb", pdb)
github victor-gil-sepulveda / pyProCT / scripts / gpcr / plotDistancesLikeShaw.py View on Github external
fittingCoordsets = ca_coordsets.getCoordsets(),
                 calculationCoordsets = arg131_leu272.getCoordsets())

    residues_rmsd_array, rearranged_coords, residues_rearranged_coords = calculator.oneVsTheOthers(
                                             conformation_number = 0,
                                             get_superposed_coordinates = True)

    residue_distances = []
    for conf in residues_rearranged_coords:
        arg131 = conf[0]
        leu272 = conf[1]
        r = conf[0] - conf[1]
        residue_distances.append(math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]))

    prody.writePDB("ca_atoms", ca_coordsets)
    prody.writePDB("motif", motif_coordsets)
    prody.writePDB("residues", arg131_leu272)

    print len(motif_rmsd), len(residue_distances)

    matplotlib.pyplot.scatter(residue_distances[1:], motif_rmsd)

    matplotlib.pyplot.show()
github prody / ProDy / prody / routines / routines.py View on Github external
import prody
    LOGGER = prody.LOGGER
    prefix, biomol = opt.prefix, opt.biomol
    pdb, header = prody.parsePDB(opt.pdb, header=True)
    if not prefix:
        prefix = pdb.getTitle()
        
    biomols = prody.buildBiomolecules(header, pdb, biomol=biomol)
    if not isinstance(biomols, list):
        biomols = [biomols]
    
    for i, biomol in enumerate(biomols):
        if isinstance(biomol, prody.Atomic):
            outfn = '{0:s}_biomol_{1:d}.pdb'.format(prefix, i+1)
            LOGGER.info('Writing {0:s}'.format(outfn))
            prody.writePDB(outfn, biomol)
        elif isinstance(biomol, tuple):
            for j, part in enumerate(biomol):
                outfn = ('{0:s}_biomol_{1:d}_part_{2:d}.pdb'
                         .format(prefix, i+1, j+1))
                LOGGER.info('Writing {0:s}'.format(outfn))
                prody.writePDB(outfn, part)
github victor-gil-sepulveda / pyProCT / scripts / gpcr / plotDistancesLikeShaw.py View on Github external
calculationCoordsets = arg131_leu272.getCoordsets())

    residues_rmsd_array, rearranged_coords, residues_rearranged_coords = calculator.oneVsTheOthers(
                                             conformation_number = 0,
                                             get_superposed_coordinates = True)

    residue_distances = []
    for conf in residues_rearranged_coords:
        arg131 = conf[0]
        leu272 = conf[1]
        r = conf[0] - conf[1]
        residue_distances.append(math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]))

    prody.writePDB("ca_atoms", ca_coordsets)
    prody.writePDB("motif", motif_coordsets)
    prody.writePDB("residues", arg131_leu272)

    print len(motif_rmsd), len(residue_distances)

    matplotlib.pyplot.scatter(residue_distances[1:], motif_rmsd)

    matplotlib.pyplot.show()
github prody / ProDy / prody / apps / prody_apps / prody_contacts.py View on Github external
outfn = lambda fn: title + suffix + '_' + fn + '.pdb'
    else:
        outfn = lambda fn: title + suffix + '.pdb'
    for pdb in ligands:
        ligand = prody.parsePDB(pdb)
        sel = contacts(radius, ligand)
        if sel:
            LOGGER.info('{0} atoms from {1} contact {2}.'
                        .format(len(sel), pdb, str(target)))
            if extend:
                sel = target.select('same ' + extend + ' as sel', sel=sel)
                LOGGER.info('Selection is extended to {0} atoms of the same '
                            '{1}(s).'.format(len(sel), extend))
            pdbfn = outfn(ligand.getTitle())
            LOGGER.info('Writing contacts into ' + pdbfn)
            prody.writePDB(pdbfn, sel)
github prody / ProDy / prody / apps / prody_apps / prody_biomol.py View on Github external
import prody
    LOGGER = prody.LOGGER
    prefix, biomol = kwargs.get('prefix',None), kwargs.get('biomol')
    pdb, header = prody.parsePDB(pdbname, header=True)
    if not prefix:
        prefix = pdb.getTitle()

    biomols = prody.buildBiomolecules(header, pdb, biomol=biomol)
    if not isinstance(biomols, list):
        biomols = [biomols]

    for i, biomol in enumerate(biomols):
        if isinstance(biomol, prody.Atomic):
            outfn = '{0}_biomol_{1}.pdb'.format(prefix, i+1)
            LOGGER.info('Writing {0}'.format(outfn))
            prody.writePDB(outfn, biomol)
        elif isinstance(biomol, tuple):
            for j, part in enumerate(biomol):
                outfn = ('{0}_biomol_{1}_part_{2}.pdb'
                         .format(prefix, i+1, j+1))
                LOGGER.info('Writing {0}'.format(outfn))
                prody.writePDB(outfn, part)