becksteinlab / propkatraj Goto Github PK
View Code? Open in Web Editor NEWpKa estimates for proteins using an ensemble approach
Home Page: https://becksteinlab.github.io/propkatraj/
License: GNU General Public License v2.0
pKa estimates for proteins using an ensemble approach
Home Page: https://becksteinlab.github.io/propkatraj/
License: GNU General Public License v2.0
It should be possible to install this script with its dependencies in a standard Pythonic manner.
Current dependencies
@dotsdl and @azjajo – please have a look at the repo and let me know if anything needs to be changed/added. (PRs or direct commits are welcome).
I tested the installation instructions in a virtual env and everything works with MDA 0.16.0 and current MDSynthesis as well as PROPKA 3.1. master.
If you are happy I cut a 0.1.0 release (and possibly add citation information).
This is an upstream issue, but probably should be documented whilst the MDA parser has this current behaviour.
Passing a PDB to propka or propkatraj should give the same predicted pkas
When passing 4LYI (everyone's favourite BRD4 model), the results will differ significantly for GLU 151, 154, and 163.
The cause for this is that the MDA PDBWriter will output everything with ATOM records whilst the native PDB has HETATM entries for the small molecules/ions/solvent. This causes the difference in results seen here (manualy hand-editing the output of a MDA PDBWriter file for 4LYI makes things work again).
I'm not versed enough in the internal workings for propka 3.1+ to know why HETATM and ATOMS are handled differently, maybe @orbeckst has more insights here?
Docs say function returns sim but actually is a DataFrame.
I have recieved an error message when I run pkatraj.run(verbose=True, start=300, stop=500, step=20).
I have checked the trajectory and they are all fine. Not too sure what's going on..
AttributeError Traceback (most recent call last)
in
----> 1 pkatraj.run(verbose=True, start=300, stop=500, step=20)
~/.local/lib/python3.7/site-packages/MDAnalysis/analysis/base.py in run(self, start, stop, step, verbose)
198 self._pm.echo(self._frame_index)
199 logger.info("Finishing up")
--> 200 self._conclude()
201 return self
202
~/anaconda3/lib/python3.7/site-packages/propkatraj/propkatraj.py in _conclude(self)
226 logging.warning(wmsg)
227
--> 228 self.pkas = pd.DataFrame(self._pkas, index=pd.Float64Index(self.times,
229 name='time'), columns=self._columns)
Thank you so much for your help in advance.
Best wishes
Will
The new propka 3.2.0 release breaks the internal API in parts. To check
Tests fail for MDAKit registry check MDAnalysis/MDAKits#153 and MDAnalysis/MDAKits#152
(Need to check what is actually going wrong and what needs fixing.)
Our coverage is artificially low, we can fix coveragerc to exclude anything that isn't under (e.g. everything that isn't in propkatraj.py
or propkatraj/tests
.
We can also quickly add an nbval test (alongside the standard CI test action) to run the examples through - although that's not a coverage thing.
The current code should support passing an array index instead of a string selection.
However the following will cause a TypeError
.
The reason for this is here:
propkatraj/propkatraj/propkatraj.py
Line 53 in 2abd91f
The latter should be np.ndarray not np.array.
Suggestion: the fix is quite trivial so it's not an issue, but I would suggest relying on users passing atomgroups instead of universes, with the default selection string being None
(if a selection string is even needed). That way the responsibility is on users to pass the right thing?
As the the "filename" for the PDB stream relies on universe.filename
universes without filenames set, e.g. when using fetch_mmtf
will cause get_propka
to fail.
Code to reproduce behaviour:
import MDAnalysis as mda
import propkatraj
u = mda.fetch_mmtf('4LYI')
pkatraj = propkatraj.get_propka(u)
Note; this might not need fixing, in the AnalysisBase update I would like to switch to using os.path.curdir
.
See MDAnalysis/cookiecutter-mdakit#54
Solution: don't run codecov on CRON CI
For a 2.0 release, remove deprecated stuff
Bump dependencies
Now that MDA has dropped 3.8, we should also move ahead with removing 3.8 support.
Create a parallel version based on pmda.parallel.ParallelAnalysisBase.
(Thanks to @dotsdl for the suggestion.)
The package is pip
installable and is published on PyPi https://pypi.python.org/pypi/propkatraj . However, PROPKA is not pip-installable yet (see jensengroup/propka#16 ).
Once jensengroup/propka#16 is solved, add a note to INSTALL.md that one can simply
pip install propkatraj
If PROPKA fails for mysterious reasons then we want to have the option to move on and skip frames.
skip_failing = True
)try/except
to skipPut a try/except
around https://github.com/Becksteinlab/propkatraj/blob/master/propkatraj/propkatraj.py#L74 together with the logging.
skip_failing = False
then raise the exception.skip_failing = True
then log error and continueSomething like
try:
mol = pk.single(pstream, optargs=['--quiet'])
except IndexError as err:
if not skip_failing:
raise
else:
# log ...
# continue the loop at the next frame, not sure if this
# is working....
continue
finally:
pstream.close(force=True) # deallocate
(IndexError
is the PROPKA error that @rsexton2 encounters.)
I am following the Jupyter notebook tutorial (docs/propkatraj-example.ipynb) and when I type
pkas = propkatraj.get_propka(u) I get the following error. I am not sure what the problem is. Many thanks
pkas = propkatraj.get_propka(u)
1/98 t= 1.000 ps [ 1.0%]/Users/nehade/anaconda3/lib/python3.5/site-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'altLocs' Using default value of ' '
"".format(attrname, default))
/Users/nehade/anaconda3/lib/python3.5/site-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'icodes' Using default value of ' '
"".format(attrname, default))
/Users/nehade/anaconda3/lib/python3.5/site-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'occupancies' Using default value of '1.0'
"".format(attrname, default))
/Users/nehade/anaconda3/lib/python3.5/site-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'tempfactors' Using default value of '0.0'
"".format(attrname, default))
Traceback (most recent call last):
File "/Users/nehade/.local/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg/propka/lib.py", line 37, in open_file_for_reading
TypeError: invalid file: <NamedStream(<_io.StringIO object at 0x110245c18>, /Users/nehade/anaconda3/lib/python3.5/site-packages/MDAnalysisTests/data/current.pdb)>
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "", line 1, in
File "/Users/nehade/.local/lib/python3.5/site-packages/propkatraj/propkatraj.py", line 82, in get_propka
mol = pk.single(pstream, optargs=['--quiet'])
File "/Users/nehade/.local/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg/propka/run.py", line 30, in single
File "/Users/nehade/.local/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg/propka/molecular_container.py", line 41, in init
File "/Users/nehade/.local/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg/propka/pdb.py", line 40, in read_pdb
printed but the debugger's state is not changed.
File "/Users/nehade/.local/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg/propka/pdb.py", line 91, in get_atom_lines_from_pdb
def find_function(funcname, filename):
File "/Users/nehade/.local/lib/python3.5/site-packages/PROPKA-3.1-py3.5.egg/propka/lib.py", line 39, in open_file_for_reading
OSError: Cannot find file /Users/nehade/anaconda3/lib/python3.5/site-packages/MDAnalysisTests/data/current.pdb
There's not a ton of activity here so let's simplify and just do development on a main branch.
As the progressmeter has now been replaced by the progressbar, the following will fail from 2.0 onwards:
propkatraj/propkatraj/propkatraj.py
Line 61 in 2abd91f
I would be interested in attempting to refactor the code to use AnalysisBase instead if there is any interest in doing so.
propkatraj
currently pins propka
to v3.1
With #36, the get_propka
function is removed. Per the deprecation warning, this means a release of 2.0.0 is needed.
2.0.0
As per the title - mainly a reminder to add it in the next PR 🙃
propkatraj.get_propka(s, sel='protein')
fails with
Time (ps): 0.0
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-11-dc948db1b97b> in <module>()
----> 1 propkatraj.get_propka(s, sel='protein')
/nfs/homes/azjajo/Projects/Staph_Member/David/propkatraj.pyc in get_propka(sim, sel, start, stop, step)
55 # we feed the stream to propka, and it reads it as if it were a file on
56 # disk
---> 57 mol = pk.single(pstream, None, writeout=False)
58 pstream.close(force=True) # deallocate
59
TypeError: single() got an unexpected keyword argument 'writeout'
PROPKA fails with the following error:
1 rsexton@chipbacca:~/Projects/pKa_Prediction/propkatraj/propkatraj⟫ ipython wt_pkas.py %run
1/100001 t= 0.000 ps [ 0.0%]/usr/local/lib/python2.7/dist-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'altLocs'
Using default value of ' '
"".format(attrname, default))
/usr/local/lib/python2.7/dist-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'icodes' Using default value of ' '
"".format(attrname, default))
/usr/local/lib/python2.7/dist-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'occupancies' Using default value of '1.0'
"".format(attrname, default))
/usr/local/lib/python2.7/dist-packages/MDAnalysis/coordinates/PDB.py:892: UserWarning: Found no information for attr: 'tempfactors' Using default value of '0.0'
"".format(attrname, default))
1415/100001 t= 1414.000 ps [ 1.4%]WARNING:root:/nfs/homes/rsexton/Projects/pKa_Prediction/wt/md/md_centered_nowater_nopbc.xtc (failure 0): failing frame 1414
1587/100001 t= 1586.000 ps [ 1.6%]WARNING:root:/nfs/homes/rsexton/Projects/pKa_Prediction/wt/md/md_centered_nowater_nopbc.xtc (failure 1): failing frame 1586
2157/100001 t= 2156.000 ps [ 2.2%]---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
/nfs/homes/rsexton/Projects/pKa_Prediction/propkatraj/propkatraj/wt_pkas.py in <module>()
6
7
----> 8 pkas = propkatraj.get_propka(u, sel='protein', step=1, skip_failure=True)
9 pkas.to_csv('wt_pkas.csv')
10
/nfs/homes/rsexton/Projects/pKa_Prediction/propkatraj/propkatraj/propkatraj.pyc in get_propka(universe, sel, start, stop, step, skip_failure)
80 # disk
81 try:
---> 82 mol = pk.single(pstream, optargs=['--quiet'])
83 except IndexError as err:
84 if not skip_failure:
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/run.pyc in single(pdbfile, optargs)
29 [280/2594]
30 my_molecule = propka.molecular_container.Molecular_container(pdbfile, options)
---> 31 my_molecule.calculate_pka()
32 my_molecule.write_pka()
33 return my_molecule
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/molecular_container.pyc in calculate_pka(self)
122 # calculate for each conformation
123 for name in self.conformation_names:
--> 124 self.conformations[name].calculate_pka(self.version, self.options)
125
126 # find non-covalently coupled groups
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/conformation_container.pyc in calculate_pka(self, version, options)
186
187 # setting remaining non-iterative and iterative side-chain & Coulomb interaction determinants
--> 188 propka.determinants.setDeterminants(self.get_sidechain_groups(), version=version, options=options)
189
190 # calculating the total pKa values
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/determinants.pyc in setDeterminants(propka_groups, version, options)
32 propka.iterative.addtoDeterminantList(group1, group2, distance, iterative_interactions, version=version)
33 elif interaction_type == 'N':
---> 34 addDeterminants(group1, group2, distance, version)
35
36
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/determinants.pyc in addDeterminants(group1, group2, distance, version)
45
46 # side-chain determinant
---> 47 addSidechainDeterminants(group1, group2, version)
48
49 # Coulomb determinant
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/determinants.pyc in addSidechainDeterminants(group1, group2, version)
58 """
59
---> 60 hbond_interaction = version.hydrogen_bond_interaction(group1, group2)
61
62 if hbond_interaction:
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/version.pyc in hydrogen_bond_interaction(self, group1, group2)
24 # side chains [238/2594]
25 def hydrogen_bond_interaction(self, group1, group2):
---> 26 return self.hydrogen_bond_interaction_model(group1, group2, self)
27
28 def calculateSideChainEnergy(self, distance, dpka_max, cutoff, weight, f_angle):
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/calculations.pyc in hydrogen_bond_interaction(group1, group2, version)
625 weight = version.calculatePairWeight(group1.Nmass, group2.Nmass)
626
--> 627 exception, value = version.checkExceptions(group1, group2)
628 #exception = False # circumventing exception
629 if exception == True:
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/version.pyc in checkExceptions(self, group1, group2)
45 # exceptions
46 def checkExceptions(self, group1, group2):
---> 47 return self.exception_check_method(self, group1, group2)
48
49 def setup_bonding_and_protonation(self, molecular_container):
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/calculations.pyc in checkExceptions(version, group1, group2)
751
752 if (resType1 == "COO" and resType2 == "ARG"):
--> 753 exception, value = checkCooArgException(group1, group2, version)
754 elif (resType1 == "ARG" and resType2 == "COO"):
755 exception, value = checkCooArgException(group2, group1, version)
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/calculations.pyc in checkCooArgException(group_coo, group_arg, version)
798 # find the closest interaction pair
799 [closest_coo_atom, distance, closest_arg_atom] = get_smallest_distance(atoms_coo, atoms_arg)
--> 800 [dpka_max, cutoff] = version.get_hydrogen_bond_parameters(closest_coo_atom,closest_arg_atom)
801 # calculate and sum up interaction energy
802 f_angle = 1.00
/nfs/homes/rsexton/.local/lib/python2.7/site-packages/propka/version.pyc in get_hydrogen_bond_parameters(self, atom1, atom2)
88 def get_hydrogen_bond_parameters(self, atom1, atom2):
89 dpka_max = self.parameters.sidechain_interaction
---> 90 cutoff = self.parameters.sidechain_cutoffs.get_value(atom1.group_type, atom2.group_type)
91 return [dpka_max, cutoff]
92
AttributeError: 'NoneType' object has no attribute 'group_type'
The files used to produce the error are attached below.
error_traj_top.zip
The following two .pdb files were both produced by GROMACS. PROPKA works with one and not the other, where the only noticeable difference is one of the files contains Na and Cl ions.
pass_fail.zip
I've been neglecting propkatraj a little bit, I don't think it's compatible with MDAnalysis 2.0. - Needs investigating and fixing (probably post ACS)
In https://becksteinlab.github.io/propkatraj/api.html , the argument name and type are not separated.
Looks like the action was based on calling setup.py
this needs to be changed to using sphinx-build
or equivalent.
We had some spurious codecov.io upload issues. Sometimes this can be improved by using a codecov token
Last release to work with PROPKA 3.1 and Python 2.7.
Afterwards it will be >= PROPKA 3.2 and Python >= 3.6, see #20
Currently the code will throw a warning if it finds any non-protein atoms in the residue selection. However the "protein residue" definition in MDA is quite loose, my understanding is that propka only really accepts these:
What would we think about making the check more stringent so that if it finds anything not in that dictionary it throws a warning to telling users to consider renaming residues to their standard value if necessary?
Says GPLv3 in some places, says GPLv2 in others. Need to pick one and choose.
propkatraj/propkatraj/propkatraj.py
Line 74 in f9d2886
Use
from six import StringIO
(and delete the line import cStringIO
)
and then
pstream = mda.lib.util.NamedStream(StringIO(), newname)
Also add "six" to
Line 28 in f9d2886
install_requires=['numpy', 'pandas', 'six', 'MDAnalysis', 'propka']
Online docs were added #38 . We should have a standard badge on the README for people to easily find the docs.
Upgrade documentation to Sphinx, hosted on GitHub pages.
add notes on citing
Hi
I am having issues running propkatraj and I think it's related to my local propkatraj or Propka installation because the error I get is
AttributeError: module 'propkatraj' has no attribute 'get_propka'
(I get no error about the module not being found)
I have MDAnalysis 2.5 installed (on a MacOS 10.15) and that works fine. I have install propka and propkatraj using
pip install propka==3.1
pip install propkatraj
No error messages during the installation
I tried a very stripped-back test script (see attached) but I can't even call the function help(propkatraj.get_propka)
Any help would be much appreciated.
thanks from Australia
Evelyne
I came across this older issue
#18
I checked the lib.py in /Users/evelyne/opt/anaconda3/lib/python3.9/site-packages/propka/lib.py and as far as I can tell the required code for the function open_file_for_reading is there
pka_test.txt
When looking at the notebook through nbviewer https://nbviewer.jupyter.org/github/Becksteinlab/propkatraj/blob/master/docs/propkatraj-example.ipynb I get
400 : Bad Request
{'model_id': '34dd1b2989df48a98da0566d926d6a68', 'version_major': 2, 'version_minor': 0} is not valid under any of the given schemas Failed validating 'oneOf' in display_data['properties']['data']['patternProperties']['^(?!application/json$)[a-zA-Z0-9]+/[a-zA-Z0-9\\-\\+\\.]+$']: On instance['cells'][13]['outputs'][0]['data']['application/vnd.jupyter.widget-view+json']: {'model_id': '34dd1b2989df48a98da0566d926d6a68', 'version_major': 2, 'version_minor': 0}
Not sure why this is happening.
I enabled zenodo but need to make a pre-release to trigger the first DOI minting and get a URL for the badge.
The docs action fails:
$ python setup.py build_sphinx
error: invalid command 'build_sphinx'
See https://github.com/Becksteinlab/propkatraj/actions/runs/4964078889/jobs/8883897113
It would be nice to be able to install from conda-forge.
related to this: MDAnalysis/cookiecutter-mdakit#110
See MDAnalysis/PathSimAnalysis#19 for how to fix.
AUTHORS to record contributors.
The propkatraj.py
script uses MDSynthesis. Should we retain this dependency or make it more bare-bones?
@dotsdl , have you got an opinion?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.