writing rmsf or bfactors into PDB's bfactor field

952 views
Skip to first unread message

Dmitry Osolodkin

unread,
Aug 16, 2016, 1:23:23 PM8/16/16
to MDnalysis discussion
Hello all,

I would like to colour my protein by RMSF or B-factors of individual residues from my trajectory using VMD with Beta colouring. To do this, I intend to put the RMSF/B-factor values (calculated separately or inside MDAnalysis) into corresponding fields of a PDB file.

Is such a PDB writing possible with the help of MDAnalysis? Maybe there are other convenient recipes?

Thank you in advance for your help,
Dmitry

Oliver Beckstein

unread,
Aug 16, 2016, 1:27:14 PM8/16/16
to mdnalysis-...@googlegroups.com
Hi Dmitry,

> On 16 Aug, 2016, at 05:43, Dmitry Osolodkin <diva...@gmail.com> wrote:
>
> I would like to colour my protein by RMSF or B-factors of individual residues from my trajectory using VMD with Beta colouring. To do this, I intend to put the RMSF/B-factor values (calculated separately or inside MDAnalysis) into corresponding fields of a PDB file.
>
> Is such a PDB writing possible with the help of MDAnalysis? Maybe there are other convenient recipes?

You're in luck: The tutorial covers exactly this case: http://www.mdanalysis.org/MDAnalysisTutorial/writing.html#example-saving-dynamic-per-atom-properties-in-b-factor

Ask if you have questions!

Oliver

--
Oliver Beckstein * orbe...@gmx.net
skype: orbeckst * orbe...@gmail.com

Oliver Beckstein

unread,
Aug 16, 2016, 3:22:37 PM8/16/16
to mdnalysis-...@googlegroups.com
Actually, if you only want a static snapshot then you don't even have to go through what the tutorial says. You can just set the bfactors of an AtomGroup and write out the atom group.

ag,bfactors = rmsf
ag.write("atoms_with_bfactors.pdb")

I wrote up a short tutorial, which you can view at

http://nbviewer.jupyter.org/gist/orbeckst/6bea4a4be3ad0eb541e105edd58e93bf

Hope that helps,
Oliver

Dmitry Osolodkin

unread,
Aug 17, 2016, 4:07:23 AM8/17/16
to MDnalysis discussion
Hi Oliver,

thank you for your help. Looks like I was stuck with the documentation and totally overlook the tutorial section. I will try these protocols and report in case of any problems.

Best,
Dmitry

Oliver Beckstein

unread,
Aug 17, 2016, 6:56:54 AM8/17/16
to mdnalysis-...@googlegroups.com

> On 17 Aug, 2016, at 01:07, Dmitry Osolodkin <diva...@gmail.com> wrote:
>
> thank you for your help. Looks like I was stuck with the documentation and totally overlook the tutorial section. I will try these protocols and report in case of any problems.

Well, you didn't overlook this tutorial because I wrote in response to your email :-)

Mohamed shehata

unread,
Feb 4, 2019, 3:37:52 AM2/4/19
to MDnalysis discussion
The code went well till 

protein.bfactors = R.rmsf

I got this error , any suggestions?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-29-918005ee106d> in <module>()
----> 1 protein.bfactors = R.rmsf

D:\mo\Python\New folder\lib\site-packages\MDAnalysis\core\groups.py in __setattr__(self, attr, value)
    276             raise AttributeError(
    277                 "Cannot set arbitrary attributes to a {}".format(
--> 278                     'Group' if self._is_group else 'Component'))
    279         # if it is, we allow the setattr to proceed by deferring to the super
    280         # behaviour (ie do it)

AttributeError: Cannot set arbitrary attributes to a Group

On Tuesday, 16 August 2016 22:22:37 UTC+3, Oliver Beckstein wrote:
Reply all
Reply to author
Forward
0 new messages