Commit da477548 by peastman

Merge pull request #63 from peastman/pdbfile

Renamed one argument
parents 5ec1679e bcd2e153
...@@ -131,9 +131,9 @@ This is the most powerful way to use PDBFixer. It allows you to script the proc ...@@ -131,9 +131,9 @@ This is the most powerful way to use PDBFixer. It allows you to script the proc
<p> <p>
PDBFixer is based on OpenMM, and to use its Python API you should first be familiar with the OpenMM API. Consult the OpenMM documentation for details. In everything that follows, I will assume you are already familiar with OpenMM. PDBFixer is based on OpenMM, and to use its Python API you should first be familiar with the OpenMM API. Consult the OpenMM documentation for details. In everything that follows, I will assume you are already familiar with OpenMM.
<p> <p>
To use PDBFixer create a <tt>PDBFixer</tt> object, passing to its constructor a <tt>PdbStructure</tt> object containing the structure to process. You then call a series of methods on it to perform various transformations. When all the transformations are done, you can get the new structure from its <tt>topology</tt> and <tt>positions</tt> fields. The overall outline of your code will look something like this: To use PDBFixer create a <tt>PDBFixer</tt> object, passing to its constructor the file to process. You then call a series of methods on it to perform various transformations. When all the transformations are done, you can get the new structure from its <tt>topology</tt> and <tt>positions</tt> fields. The overall outline of your code will look something like this:
<tt><pre> <tt><pre>
fixer = PDBFixer(file=open('myfile.pdb')) fixer = PDBFixer(filename='myfile.pdb')
# ... # ...
# Call various methods on the PDBFixer # Call various methods on the PDBFixer
# ... # ...
...@@ -213,7 +213,7 @@ Here is a complete example that ties this together. It adds all missing atoms i ...@@ -213,7 +213,7 @@ Here is a complete example that ties this together. It adds all missing atoms i
<tt><pre> <tt><pre>
from pdbfixer import PDBFixer from pdbfixer import PDBFixer
from simtk.openmm.app import PDBFile from simtk.openmm.app import PDBFile
fixer = PDBFixer(file=open('myfile.pdb')) fixer = PDBFixer(filename='myfile.pdb')
fixer.findMissingResidues() fixer.findMissingResidues()
fixer.findNonstandardResidues() fixer.findNonstandardResidues()
fixer.replaceNonstandardResidues() fixer.replaceNonstandardResidues()
...@@ -227,7 +227,7 @@ PDBFile.writeFile(fixer.topology, fixer.positions, open('output.pdb', 'w')) ...@@ -227,7 +227,7 @@ PDBFile.writeFile(fixer.topology, fixer.positions, open('output.pdb', 'w'))
Suppose you want to keep only the first chain in the file and remove all the others. To do this, call <tt>removeChains()</tt>: Suppose you want to keep only the first chain in the file and remove all the others. To do this, call <tt>removeChains()</tt>:
<tt><pre> <tt><pre>
<span style="color:grey">fixer = PDBFixer(file=open('myfile.pdb'))</span> <span style="color:grey">fixer = PDBFixer(filename='myfile.pdb')</span>
numChains = len(list(fixer.topology.chains())) numChains = len(list(fixer.topology.chains()))
fixer.removeChains(range(1, numChains)) fixer.removeChains(range(1, numChains))
<span style="color:grey">fixer.findMissingResidues()</span> <span style="color:grey">fixer.findMissingResidues()</span>
......
...@@ -133,14 +133,14 @@ class PDBFixer(object): ...@@ -133,14 +133,14 @@ class PDBFixer(object):
"""PDBFixer implements many tools for fixing problems in PDB files. """PDBFixer implements many tools for fixing problems in PDB files.
""" """
def __init__(self, filename=None, file=None, url=None, pdbid=None): def __init__(self, filename=None, pdbfile=None, url=None, pdbid=None):
"""Create a new PDBFixer instance to fix problems in a PDB file. """Create a new PDBFixer instance to fix problems in a PDB file.
Parameters Parameters
---------- ----------
filename : str, optional, default=None filename : str, optional, default=None
A filename specifying the file from which the PDB file is to be read. A filename specifying the file from which the PDB file is to be read.
file : file, optional, default=None pdbfile : file, optional, default=None
A file-like object from which the PDB file is to be read. A file-like object from which the PDB file is to be read.
The file is not closed after reading. The file is not closed after reading.
url : str, optional, default=None url : str, optional, default=None
...@@ -150,7 +150,7 @@ class PDBFixer(object): ...@@ -150,7 +150,7 @@ class PDBFixer(object):
Notes Notes
----- -----
Only one of structure, filename, file, url, or pdbid may be specified or an exception will be thrown. Only one of structure, filename, pdbfile, url, or pdbid may be specified or an exception will be thrown.
Examples Examples
-------- --------
...@@ -160,7 +160,7 @@ class PDBFixer(object): ...@@ -160,7 +160,7 @@ class PDBFixer(object):
>>> pdbid = '1VII' >>> pdbid = '1VII'
>>> url = 'http://www.rcsb.org/pdb/files/%s.pdb' % pdbid >>> url = 'http://www.rcsb.org/pdb/files/%s.pdb' % pdbid
>>> file = urlopen(url) >>> file = urlopen(url)
>>> fixer = PDBFixer(file=file) >>> fixer = PDBFixer(pdbfile=file)
Start from a filename. Start from a filename.
...@@ -182,8 +182,8 @@ class PDBFixer(object): ...@@ -182,8 +182,8 @@ class PDBFixer(object):
""" """
# Check to make sure only one option has been specified. # Check to make sure only one option has been specified.
if bool(filename) + bool(file) + bool(url) + bool(pdbid) != 1: if bool(filename) + bool(pdbfile) + bool(url) + bool(pdbid) != 1:
raise Exception("Exactly one option [filename, file, url, pdbid] must be specified.") raise Exception("Exactly one option [filename, pdbfile, url, pdbid] must be specified.")
self.source = None self.source = None
if filename: if filename:
...@@ -192,9 +192,9 @@ class PDBFixer(object): ...@@ -192,9 +192,9 @@ class PDBFixer(object):
file = open(filename, 'r') file = open(filename, 'r')
structure = PdbStructure(file) structure = PdbStructure(file)
file.close() file.close()
elif file: elif pdbfile:
# A file-like object has been specified. # A file-like object has been specified.
structure = PdbStructure(file) structure = PdbStructure(pdbfile)
elif url: elif url:
self.source = url self.source = url
# A URL has been specified. # A URL has been specified.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment