<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Load_new_B-factors</id>
	<title>Load new B-factors - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=Load_new_B-factors"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Load_new_B-factors&amp;action=history"/>
	<updated>2026-07-04T12:59:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Load_new_B-factors&amp;diff=12171&amp;oldid=prev</id>
		<title>Bell: 2 revisions</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Load_new_B-factors&amp;diff=12171&amp;oldid=prev"/>
		<updated>2014-10-20T15:32:16Z</updated>

		<summary type="html">&lt;p&gt;2 revisions&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:32, 20 October 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Bell</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Load_new_B-factors&amp;diff=12170&amp;oldid=prev</id>
		<title>PietroGattiLafranconi: download link added</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Load_new_B-factors&amp;diff=12170&amp;oldid=prev"/>
		<updated>2014-09-22T15:43:54Z</updated>

		<summary type="html">&lt;p&gt;download link added&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 15:43, 22 September 2014&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l1&quot; &gt;Line 1:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 1:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Infobox script-repo&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{{Infobox script-repo&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|type      = script&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|type      = script&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|download  = &lt;del class=&quot;diffchange diffchange-inline&quot;&gt;TBC&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|download  = &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;[http://dx.doi.org/10.6084/m9.figshare.1176991 figshare]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|author    = [[User:PietroGattiLafranconi|Pietro Gatti-Lafranconi]]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|author    = [[User:PietroGattiLafranconi|Pietro Gatti-Lafranconi]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|license   = [http://creativecommons.org/licenses/by/4.0/ CC BY 4.0]&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;|license   = [http://creativecommons.org/licenses/by/4.0/ CC BY 4.0]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>PietroGattiLafranconi</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Load_new_B-factors&amp;diff=12169&amp;oldid=prev</id>
		<title>PietroGattiLafranconi: Page created</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Load_new_B-factors&amp;diff=12169&amp;oldid=prev"/>
		<updated>2014-09-22T15:38:19Z</updated>

		<summary type="html">&lt;p&gt;Page created&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Infobox script-repo&lt;br /&gt;
|type      = script&lt;br /&gt;
|download  = TBC&lt;br /&gt;
|author    = [[User:PietroGattiLafranconi|Pietro Gatti-Lafranconi]]&lt;br /&gt;
|license   = [http://creativecommons.org/licenses/by/4.0/ CC BY 4.0]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Introduction ==&lt;br /&gt;
Quick and simple script to replace B-factor values in a PDB structure.&lt;br /&gt;
&lt;br /&gt;
New B-factors are provided in an external .txt file, one per line.&lt;br /&gt;
&lt;br /&gt;
By default, the script will also redraw the selected molecule as cartoon putty and colour by B-factor&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
 loadBfacts mol, [startaa, [source, [visual Y/N]]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Required Arguments ==&lt;br /&gt;
* '''mol ''' = any object selection (within one single object though)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Arguments ==&lt;br /&gt;
* '''startaa''' = number of amino acid the first value in 'source' refers to (default=1)&lt;br /&gt;
* '''source''' = name of the file containing new B-factor values (default=newBfactors.txt)&lt;br /&gt;
* '''visual''' = redraws structure as cartoon_putty and displays bar with min/max values (default=Y)&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
For its very nature, this script is not suitable for complex cases in which only some B-factors are to be replaced, or on complex selections. In such cases, [http://pldserver1.biochem.queensu.ca/~rlc/work/pymol/ data2bfactor.py] is a better choice.&lt;br /&gt;
&lt;br /&gt;
B-factors have to be entered one per line, with no labels or amino acid ID. They will replace values of a continuous stretch of amino acids of equal length (or shorter) starting from the position provided with 'startaa'.&lt;br /&gt;
&lt;br /&gt;
'newBfactors.txt' looks like&lt;br /&gt;
 2&lt;br /&gt;
 0&lt;br /&gt;
 0&lt;br /&gt;
 3&lt;br /&gt;
 7&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;loadbfacts 1LVM&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
[[File:LoadBfacts1.png|450px|example #1]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
PyMOL&amp;gt;loadbfacts 1LVM and chain a, startaa=135&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
[[File:LoadBfacts02.png|450px|example #2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The Code ==&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from pymol import cmd, stored, math&lt;br /&gt;
	&lt;br /&gt;
def loadBfacts (mol,startaa=1,source=&amp;quot;newBfactors.txt&amp;quot;, visual=&amp;quot;Y&amp;quot;):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	Replaces B-factors with a list of values contained in a plain txt file&lt;br /&gt;
	&lt;br /&gt;
	usage: loadBfacts mol, [startaa, [source, [visual]]]&lt;br /&gt;
 &lt;br /&gt;
	mol = any object selection (within one single object though)&lt;br /&gt;
	startaa = number of first amino acid in 'new B-factors' file (default=1)&lt;br /&gt;
	source = name of the file containing new B-factor values (default=newBfactors.txt)&lt;br /&gt;
	visual = redraws structure as cartoon_putty and displays bar with min/max values (default=Y)&lt;br /&gt;
 &lt;br /&gt;
	example: loadBfacts 1LVM and chain A&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	obj=cmd.get_object_list(mol)[0]&lt;br /&gt;
	cmd.alter(mol,&amp;quot;b=-1.0&amp;quot;)&lt;br /&gt;
	inFile = open(source, 'r')&lt;br /&gt;
	counter=int(startaa)&lt;br /&gt;
	bfacts=[]&lt;br /&gt;
	for line in inFile.readlines():	&lt;br /&gt;
		bfact=float(line)&lt;br /&gt;
		bfacts.append(bfact)&lt;br /&gt;
		cmd.alter(&amp;quot;%s and resi %s and n. CA&amp;quot;%(mol,counter), &amp;quot;b=%s&amp;quot;%bfact)&lt;br /&gt;
		counter=counter+1&lt;br /&gt;
	if visual==&amp;quot;Y&amp;quot;:&lt;br /&gt;
		cmd.show_as(&amp;quot;cartoon&amp;quot;,mol)&lt;br /&gt;
		cmd.cartoon(&amp;quot;putty&amp;quot;, mol)&lt;br /&gt;
		cmd.set(&amp;quot;cartoon_putty_scale_min&amp;quot;, min(bfacts),obj)&lt;br /&gt;
		cmd.set(&amp;quot;cartoon_putty_scale_max&amp;quot;, max(bfacts),obj)&lt;br /&gt;
		cmd.set(&amp;quot;cartoon_putty_transform&amp;quot;, 0,obj)&lt;br /&gt;
		cmd.set(&amp;quot;cartoon_putty_radius&amp;quot;, 0.2,obj)&lt;br /&gt;
		cmd.spectrum(&amp;quot;b&amp;quot;,&amp;quot;rainbow&amp;quot;, &amp;quot;%s and n. CA &amp;quot; %mol)&lt;br /&gt;
		cmd.ramp_new(&amp;quot;count&amp;quot;, obj, [min(bfacts), max(bfacts)], &amp;quot;rainbow&amp;quot;)&lt;br /&gt;
		cmd.recolor()&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;loadBfacts&amp;quot;, loadBfacts);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]]&lt;br /&gt;
[[Category:Biochemical_Scripts]]&lt;br /&gt;
[[Category:Coloring]]&lt;br /&gt;
[[Category:Structural_Biology_Scripts]]&lt;/div&gt;</summary>
		<author><name>PietroGattiLafranconi</name></author>
	</entry>
</feed>