Coder Social home page Coder Social logo

pypdb's Introduction

pyPDB

pyPDB is a python class that represents a strutural PDB file (not related to the python PDB debugger). It enables swift utility functions that can be used to prepare PDB files for further analysis and retrieve information from it.

Developed by Gareth Price ([email protected]). Please feel free to email or to use the issues pane at Github.

Instructions for installation

Download the latest release or the bleeding edge version and extract the files. pyPDB.py contains all necessary code.

Examples

from pyPDB import *

# load pdb
p = pyPDB('pdbs/gly.pdb')

# select one atom
p.selectAtom(4)

# select multiple atoms individually (this continues after the previous one)
p.selectAtom(5).selectAtom(6)

# or select multiple atoms all in one go
p.selectAtoms([4, 5, 6])

# the 'p' pyPDB instance now has a selectedAtoms attribute that is iterable:
for atom in p.selectedAtoms:
    print '{}{}'.format(atom.name, atom.id)

# calculate a distance map
print p.distanceMap()

# and also plot it
p.plotDistanceMap(save=False, close=True)

# calculate the distance between two atoms
print p.distanceBetweenAtoms(8, 9)

# calculate atoms within a given distance of another atom
print p.atomsWithinDistanceOfAtom(10, 3)

# you can iterate over something like the above such as:
atomsWithinDistance = p.atomsWithinDistanceOfAtom(10, 3)
i = 0
for x in atomsWithinDistance[0]:
    print 'Atom {}{} is within {} of {}{}: {}'.format(x.name, x.id, 3,
        p.molecule.atoms[10].name, 10, atomsWithinDistance[1][i])
    i += 1

# or even make an amber mask:
print p.toAmberMask('atoms')

# output a description of 'p' as json
print p.toJSON()

# reduce a pdb:
p.reduce()

# ...which can be iterated over:
for atom in p.reduce():
    print '{}{}'.format(atom.name, atom.id)

# the selection (or all atoms if no selection) can be written to a pdb file
p.writePDB()

# the selection can be removed using
p.removeSelection()

# translate the coordinates (or selection)
p.translateCoordinates([1,1,1])
for atom in p.molecule.atoms:
    a = p.molecule.atoms[atom]
    print "[{0:g}, {1:g}, {2:g}]".format(a.x, a.y, a.z)

License

All necessary information can be found in LICENSE (GPL v3). In brief this means:

You may copy, distribute and modify the software as long as you track changes/dates of in source files and keep modifications under GPL. You can distribute your application using a GPL library commercially, but you must also provide the source code.

(obtained from http://www.tldrlegal.com/license/gnu-general-public-license-v3-(gpl-3))

pypdb's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.