How to use the prody.parsePDB 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 prody / ProDy / prody / routines / routines.py View on Github external
def prody_align(opt):
    """Align models in a PDB file or a PDB file onto others."""
            
    import prody
    LOGGER = prody.LOGGER

    args = opt.pdb
    if len(args) == 1:
        pdb = args[0]
        LOGGER.info('Aligning multiple models in: ' + pdb)
        selstr, prefix, model = opt.select, opt.prefix, opt.model
        pdb = prody.parsePDB(pdb)
        pdbselect = pdb.select(selstr)
        if pdbselect is None:
            LOGGER.warning('Selection "{0:s}" do not match any atoms.'
                           .format(selstr))
            sys.exit(-1)
        LOGGER.info('{0:d} atoms will be used for alignment.'
                               .format(len(pdbselect)))
        pdb.setACSIndex(model-1)
        prody.alignCoordsets(pdb, selstr=selstr)
        rmsd = prody.calcRMSD(pdb)
        LOGGER.info('Max RMSD: {0:0.2f} Mean RMSD: {1:0.2f}'
              .format(rmsd.max(), rmsd.mean()))
        if prefix == '':
            prefix = pdb.getTitle() + '_aligned'
        outfn = prefix + '.pdb'
        LOGGER.info('Writing file: ' + outfn)
github victor-gil-sepulveda / pyProCT / pyproct / data / handler / protein / ensembleLoader.py View on Github external
if isinstance(file_info, basestring):
            # Then is a path, and must be a pdb
            path = file_info
            structure_info["source"] = path

            name, ext = os.path.splitext(path)

            self.check_extension(ext)

            if ext == ".dcd":
                common.print_and_flush( "[ERROR TrajectoryHandler::get_structure] Path format can only be used with pdb files. Exiting...\n")
                self.notify("SHUTDOWN", "Fatal error reading pdbs.")
                exit()
            else:
                structure = prody.parsePDB(path)
                structure_info["number of conformations"] = structure.numCoordsets()
                structure_info["number of atoms"] = structure.numAtoms()
                return  structure, structure_info
        else:
            # {"file":  , "selection":  } object or
            # {"file": , "atoms_file":, "selection"} if the file is a dcd file
            path = file_info["file"]
            structure_info["source"] = path
            name, ext = os.path.splitext(path)
            self.check_extension(ext)

            if ext == ".dcd":
                structure_info["source of atoms"] = file_info["atoms_file"]

                structure = prody.parsePDB(file_info["atoms_file"])
                removeAllCoordsetsFromStructureLeavingFirst(structure)
github prody / ProDy / prody / scripts.py View on Github external
parser.print_help()
        print "\nError: PDB missing\n"
        sys.exit(-1)
        
    import numpy as np
    import prody
    LOGGER = prody.LOGGER

    if opt.silent:
        prody.setVerbosity('warning')
        
    if len(args) == 1:
        pdb = args[0]
        LOGGER.info('Aligning multiple models in: ' + pdb)
        selstr, prefix, model = opt.select, opt.prefix, opt.model
        pdb = prody.parsePDB(pdb)
        pdbselect = pdb.select(selstr)
        if pdbselect is None:
            LOGGER.warning('Selection "{0:s}" do not match any atoms.'
                           .format(selstr))
            sys.exit(-1)
        LOGGER.info('{0:d} atoms will be used for alignment.'
                               .format(len(pdbselect)))
        pdb.setACSIndex(model-1)
        prody.alignCoordsets(pdb, selstr=selstr)
        rmsd = prody.calcRMSD(pdb)
        LOGGER.info('Max RMSD: {0:0.2f} Mean RMSD: {1:0.2f}'
              .format(rmsd.max(), rmsd.mean()))
        if prefix == '':
            prefix = pdb.getTitle() + '_aligned'
        outfn = prefix + '.pdb'
        LOGGER.info('Writing file: ' + outfn)
github victor-gil-sepulveda / pyProCT / pyproct / driver / handlers / trajectoryHandler.py View on Github external
structure = prody.parsePDB(path)
                structure_info["number of conformations"] = structure.numCoordsets()
                structure_info["number of atoms"] = structure.numAtoms()
                return  structure, structure_info
        else:
            # {"file":  , "selection":  } object or
            # {"file": , "atoms_file":, "selection"} if the file is a dcd file
            path = file_info["file"]
            structure_info["source"] = path
            name, ext = os.path.splitext(path)
            self.check_extension(ext)

            if ext == ".dcd":
                structure_info["source of atoms"] = file_info["atoms_file"]

                structure = prody.parsePDB(file_info["atoms_file"])
                removeAllCoordsetsFromStructureLeavingFirst(structure)
                dcd_data = prody.DCDFile(path)
                coordsets = dcd_data.getCoordsets()

                for coordset in coordsets:
                    structure.addCoordset(coordset)
            else:
                structure = prody.parsePDB(path)

            if "base_selection" in file_info and file_info["base_selection"] !=  "":
                structure = structure.select(file_info["base_selection"])
                structure_info["base selection"]=file_info["base_selection"]

            structure_info["number of conformations"] = structure.numCoordsets()
            structure_info["number of atoms"] = structure.numAtoms()
            return  structure, structure_info
github prody / ProDy / prody / apps / prody_apps / prody_biomol.py View on Github external
def prody_biomol(pdbname,**kwargs):
    """Generate biomolecule coordinates.

    :arg pdb:  PDB identifier or filename

    :arg prefix: prefix for output files, default is :file:`_biomol`

    :arg biomol: index of the biomolecule, by default all are generated"""

    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))
github victor-gil-sepulveda / pyProCT / pyproct / driver / handlers / trajectoryHandler.py View on Github external
structure_info["source"] = path
            name, ext = os.path.splitext(path)
            self.check_extension(ext)

            if ext == ".dcd":
                structure_info["source of atoms"] = file_info["atoms_file"]

                structure = prody.parsePDB(file_info["atoms_file"])
                removeAllCoordsetsFromStructureLeavingFirst(structure)
                dcd_data = prody.DCDFile(path)
                coordsets = dcd_data.getCoordsets()

                for coordset in coordsets:
                    structure.addCoordset(coordset)
            else:
                structure = prody.parsePDB(path)

            if "base_selection" in file_info and file_info["base_selection"] !=  "":
                structure = structure.select(file_info["base_selection"])
                structure_info["base selection"]=file_info["base_selection"]

            structure_info["number of conformations"] = structure.numCoordsets()
            structure_info["number of atoms"] = structure.numAtoms()
            return  structure, structure_info
github prody / ProDy / prody / routines / routines.py View on Github external
outdir = opt.outdir
    if not os.path.isdir(outdir):
        opt.subparser.error('{0:s} is not a valid path'.format(outdir))
        
    import numpy as np
    import prody
    LOGGER = prody.LOGGER


    pdb = opt.pdb
    prefix = opt.prefix
    cutoff, gamma = opt.cutoff, opt.gamma, 
    nmodes, selstr, model = opt.nmodes, opt.select, opt.model
    
    pdb = prody.parsePDB(pdb, model=model)
    if prefix == '_anm':
        prefix = pdb.getTitle() + '_anm'

    select = pdb.select(selstr)
    if select is None:
        opt.subparser('Selection "{0:s}" do not match any atoms.'
                       .format(selstr))
    LOGGER.info('{0:d} atoms will be used for ANM calculations.'
                .format(len(select)))

    anm = prody.ANM(pdb.getTitle())
    anm.buildHessian(select, cutoff, gamma)
    anm.calcModes(nmodes)
    LOGGER.info('Writing numerical output.')
    if opt.npz:
        prody.saveModel(anm)
github victor-gil-sepulveda / pyProCT / pyproct / data / handler / protein / ensembleLoader.py View on Github external
structure_info["source"] = path
            name, ext = os.path.splitext(path)
            self.check_extension(ext)

            if ext == ".dcd":
                structure_info["source of atoms"] = file_info["atoms_file"]

                structure = prody.parsePDB(file_info["atoms_file"])
                removeAllCoordsetsFromStructureLeavingFirst(structure)
                dcd_data = prody.DCDFile(path)
                coordsets = dcd_data.getCoordsets()

                for coordset in coordsets:
                    structure.addCoordset(coordset)
            else:
                structure = prody.parsePDB(path)

            if "base_selection" in file_info and file_info["base_selection"] !=  "":
                structure = structure.select(file_info["base_selection"])
                structure_info["base selection"]=file_info["base_selection"]

            structure_info["number of conformations"] = structure.numCoordsets()
            structure_info["number of atoms"] = structure.numAtoms()
            return  structure, structure_info
github victor-gil-sepulveda / pyProCT / pyproct / clustering / evaluation / metrics / benchmark / benchmarkPCAMetric.py View on Github external
from pyproct.clustering.metrics.pcaMetrics import PCAMetric
if __name__ == '__main__':
    """
    Compares Prody and pyProClust implementation.
    """
    
    ######################
    # BENCHMARKING
    ######################
    prody.confProDy(verbosity='none')#setVerbosity('none')
    print "Loading file..."
    t1 = time.time()
    print "\tUncompressing..."
    open("tmp_amber_long.pdb","w").write(bz2.BZ2File("data/amber_long.pdb.tar.bz2").read())
    print "\tLoading..."
    pdb = prody.parsePDB("tmp_amber_long.pdb", subset='calpha')
    not_iterposed_coordsets = numpy.array(pdb.getCoordsets())
    number_of_conformations = not_iterposed_coordsets.shape[0]
    atoms_per_conformation = not_iterposed_coordsets.shape[1]
    os.system("rm tmp_amber_long.pdb")
    print "\tDeleting temporary file"
    t2 = time.time()
    print 'Loading took %0.3f s' % (t2-t1)
    
    ######################
    # PRODY
    ######################
    print "Performing calculations with prody..."
    t1 = time.time()
    ensemble = prody.Ensemble('pca_test_ensemble')
    ensemble.setCoords( pdb.getCoords())
    ensemble.addCoordset(pdb.getCoordsets())
github makson96 / Dynamics / pymol_plugin_dynamics.py View on Github external
def prody(self):
		#Silence ProDy and create logs
		prody.confProDy(verbosity='none')
		prody.startLogfile("log_prody.log")
		#Prepare ensemble
		model = prody.parsePDB(project_name+"_multimodel.pdb", subset='calpha')
		model
		ensemble = prody.Ensemble(project_name+' ensemble')
		ensemble.setCoords(model.getCoords())
		ensemble.addCoordset(model.getCoordsets())
		ensemble.iterpose()
		#ANM calculations
		if self.calculation_type == 0:
			anm = prody.ANM(project_name)
			anm.buildHessian(ensemble)
			anm.calcModes()
			anm
			write_nmd = anm
			self.enm = anm
		#PCA calculations
		elif self.calculation_type == 1:
			pca = prody.PCA(project_name)