<?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=CreateAtom</id>
	<title>CreateAtom - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/index.php?action=history&amp;feed=atom&amp;title=CreateAtom"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=CreateAtom&amp;action=history"/>
	<updated>2026-06-21T08:16:03Z</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=CreateAtom&amp;diff=3517&amp;oldid=prev</id>
		<title>Pyadmin: 5 revisions</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3517&amp;oldid=prev"/>
		<updated>2014-03-28T01:21:16Z</updated>

		<summary type="html">&lt;p&gt;5 revisions&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A script to create an atom C at a point some distance d from a pair of atoms (A, B), along the line of the bond A-B. The main function takes a modelName (usually, the name of the file loaded, like &amp;quot;1pqr&amp;quot; or &amp;quot;peptide&amp;quot;), a distance, and some parameters to identify the atoms A, B.&lt;br /&gt;
&lt;br /&gt;
Use like: &amp;lt;pre&amp;gt;createAtomAlongBond(&amp;quot;gly&amp;quot;, 3, 23, &amp;quot;H&amp;quot;, 23, &amp;quot;N&amp;quot;, &amp;quot;O&amp;quot;)&amp;lt;/pre&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import cmd&lt;br /&gt;
from chempy import models, cpv&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Create an atom at a distance 'distance' along the bond between atomA and atomB&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
def createAtomAlongBond(modelName, distance, resiA, atomNameA, resiB, atomNameB, atomNameC):&lt;br /&gt;
    model = cmd.get_model(modelName)&lt;br /&gt;
    p1 = getAtomCoords(model, str(resiA), atomNameA)&lt;br /&gt;
    p2 = getAtomCoords(model, str(resiB), atomNameB)&lt;br /&gt;
    if p1 is None:&lt;br /&gt;
        print &amp;quot;atom not found!&amp;quot;, modelName, resiA, atomNameA&lt;br /&gt;
    elif p2 is None:&lt;br /&gt;
        print &amp;quot;atom not found!&amp;quot;, modelName, resiB, atomNameB&lt;br /&gt;
    else:&lt;br /&gt;
        p3 = calculateNewPoint(p1, p2, distance)&lt;br /&gt;
&lt;br /&gt;
        # the details of the new atom&lt;br /&gt;
        atomDetails = {}&lt;br /&gt;
        atomDetails['residueName'] = &amp;quot;HOH&amp;quot;&lt;br /&gt;
        atomDetails['residueNumber'] = &amp;quot;1&amp;quot;&lt;br /&gt;
        atomDetails['symbol'] = &amp;quot;O&amp;quot;&lt;br /&gt;
        atomDetails['name'] = atomNameC&lt;br /&gt;
        atomDetails['coords'] = p3&lt;br /&gt;
        &lt;br /&gt;
        # make an atom with index n+1 and chain &amp;quot;X&amp;quot;&lt;br /&gt;
        newAtom = makeAtom(model.nAtom + 1, atomDetails, &amp;quot;X&amp;quot;)&lt;br /&gt;
        model.add_atom(newAtom)&lt;br /&gt;
        model.update_index()&lt;br /&gt;
        cmd.load_model(model, &amp;quot;newpeptide&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
def getAtomCoords(model, resi, atomName):&lt;br /&gt;
    for a in model.atom:&lt;br /&gt;
        if a.resi == resi and a.name == atomName:&lt;br /&gt;
            return a.coord&lt;br /&gt;
    return None&lt;br /&gt;
&lt;br /&gt;
def calculateNewPoint(p1, p2, distance):&lt;br /&gt;
    v1 = cpv.normalize(cpv.sub(p1, p2))&lt;br /&gt;
    return cpv.add(p1, cpv.scale(v1, distance))&lt;br /&gt;
&lt;br /&gt;
def makeAtom(index, atomDetails, chain):&lt;br /&gt;
    atom = chempy.Atom()&lt;br /&gt;
    atom.index = index&lt;br /&gt;
    atom.name = atomDetails['name']&lt;br /&gt;
    atom.symbol = atomDetails['symbol']&lt;br /&gt;
    atom.resn = atomDetails['residueName']&lt;br /&gt;
    atom.chain = chain&lt;br /&gt;
    atom.resi = atomDetails['residueNumber']&lt;br /&gt;
    atom.resi_number = int(atomDetails['residueNumber'])&lt;br /&gt;
    atom.coord = atomDetails['coords']&lt;br /&gt;
    atom.hetatm = False&lt;br /&gt;
    return atom&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;createAtomAlongBond&amp;quot;, createAtomAlongBond)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
[[Category:Biochemical_Scripts]]&lt;br /&gt;
[[Category:Script_Library]]&lt;/div&gt;</summary>
		<author><name>Pyadmin</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3515&amp;oldid=prev</id>
		<title>Gilleain at 16:05, 23 October 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3515&amp;oldid=prev"/>
		<updated>2008-10-23T16:05:03Z</updated>

		<summary type="html">&lt;p&gt;&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 16:05, 23 October 2008&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-l42&quot; &gt;Line 42:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 42:&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;/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;/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;def calculateNewPoint(p1, p2, distance):&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;def calculateNewPoint(p1, p2, distance):&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;     v1 = cpv.sub(p1, p2)&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;     v1 = &lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;cpv.normalize(&lt;/ins&gt;cpv.sub(p1, p2&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;)&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;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;     return cpv.add(&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;p2&lt;/del&gt;, cpv.scale(v1, distance))&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;     return cpv.add(&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;p1&lt;/ins&gt;, cpv.scale(v1, distance))&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;/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;/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;def makeAtom(index, atomDetails, chain):&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;def makeAtom(index, atomDetails, chain):&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gilleain</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3514&amp;oldid=prev</id>
		<title>Gilleain at 08:35, 22 October 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3514&amp;oldid=prev"/>
		<updated>2008-10-22T08:35:21Z</updated>

		<summary type="html">&lt;p&gt;&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 08:35, 22 October 2008&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-l5&quot; &gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&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;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&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;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;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;import cmd&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;import cmd&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;from chempy import models&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;, protein_residues&lt;/del&gt;, cpv&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;from chempy import models, cpv&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;/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;/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;&amp;quot;&amp;quot;&amp;quot;&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;&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gilleain</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3513&amp;oldid=prev</id>
		<title>Gilleain at 08:32, 22 October 2008</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3513&amp;oldid=prev"/>
		<updated>2008-10-22T08:32:48Z</updated>

		<summary type="html">&lt;p&gt;&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 08:32, 22 October 2008&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-l5&quot; &gt;Line 5:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 5:&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;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&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;&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;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;import cmd&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;import cmd&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;from chempy import models, protein_residues&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;from chempy import models, protein_residues&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;, cpv&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;/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;/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;&amp;quot;&amp;quot;&amp;quot;&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;&amp;quot;&amp;quot;&amp;quot;&lt;/div&gt;&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-l23&quot; &gt;Line 23:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 23:&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;         # the details of the new atom&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;         # the details of the new atom&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;         atomDetails = {}&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;         atomDetails = {}&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;         atomDetails['residueName'] = &amp;quot;&lt;del class=&quot;diffchange diffchange-inline&quot;&gt;GLY&lt;/del&gt;&amp;quot;&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;         atomDetails['residueName'] = &amp;quot;&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;HOH&lt;/ins&gt;&amp;quot;&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;         atomDetails['residueNumber'] = &amp;quot;1&amp;quot;&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;         atomDetails['residueNumber'] = &amp;quot;1&amp;quot;&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;         atomDetails['symbol'] = &amp;quot;O&amp;quot;&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;         atomDetails['symbol'] = &amp;quot;O&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Gilleain</name></author>
	</entry>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3512&amp;oldid=prev</id>
		<title>Gilleain: New page: A script to create an atom C at a point some distance d from a pair of atoms (A, B), along the line of the bond A-B. The main function takes a modelName (usually, the name of the file load...</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=CreateAtom&amp;diff=3512&amp;oldid=prev"/>
		<updated>2008-10-20T12:31:13Z</updated>

		<summary type="html">&lt;p&gt;New page: A script to create an atom C at a point some distance d from a pair of atoms (A, B), along the line of the bond A-B. The main function takes a modelName (usually, the name of the file load...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;A script to create an atom C at a point some distance d from a pair of atoms (A, B), along the line of the bond A-B. The main function takes a modelName (usually, the name of the file loaded, like &amp;quot;1pqr&amp;quot; or &amp;quot;peptide&amp;quot;), a distance, and some parameters to identify the atoms A, B.&lt;br /&gt;
&lt;br /&gt;
Use like: &amp;lt;pre&amp;gt;createAtomAlongBond(&amp;quot;gly&amp;quot;, 3, 23, &amp;quot;H&amp;quot;, 23, &amp;quot;N&amp;quot;, &amp;quot;O&amp;quot;)&amp;lt;/pre&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import cmd&lt;br /&gt;
from chempy import models, protein_residues&lt;br /&gt;
&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
Create an atom at a distance 'distance' along the bond between atomA and atomB&lt;br /&gt;
&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
def createAtomAlongBond(modelName, distance, resiA, atomNameA, resiB, atomNameB, atomNameC):&lt;br /&gt;
    model = cmd.get_model(modelName)&lt;br /&gt;
    p1 = getAtomCoords(model, str(resiA), atomNameA)&lt;br /&gt;
    p2 = getAtomCoords(model, str(resiB), atomNameB)&lt;br /&gt;
    if p1 is None:&lt;br /&gt;
        print &amp;quot;atom not found!&amp;quot;, modelName, resiA, atomNameA&lt;br /&gt;
    elif p2 is None:&lt;br /&gt;
        print &amp;quot;atom not found!&amp;quot;, modelName, resiB, atomNameB&lt;br /&gt;
    else:&lt;br /&gt;
        p3 = calculateNewPoint(p1, p2, distance)&lt;br /&gt;
&lt;br /&gt;
        # the details of the new atom&lt;br /&gt;
        atomDetails = {}&lt;br /&gt;
        atomDetails['residueName'] = &amp;quot;GLY&amp;quot;&lt;br /&gt;
        atomDetails['residueNumber'] = &amp;quot;1&amp;quot;&lt;br /&gt;
        atomDetails['symbol'] = &amp;quot;O&amp;quot;&lt;br /&gt;
        atomDetails['name'] = atomNameC&lt;br /&gt;
        atomDetails['coords'] = p3&lt;br /&gt;
        &lt;br /&gt;
        # make an atom with index n+1 and chain &amp;quot;X&amp;quot;&lt;br /&gt;
        newAtom = makeAtom(model.nAtom + 1, atomDetails, &amp;quot;X&amp;quot;)&lt;br /&gt;
        model.add_atom(newAtom)&lt;br /&gt;
        model.update_index()&lt;br /&gt;
        cmd.load_model(model, &amp;quot;newpeptide&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
def getAtomCoords(model, resi, atomName):&lt;br /&gt;
    for a in model.atom:&lt;br /&gt;
        if a.resi == resi and a.name == atomName:&lt;br /&gt;
            return a.coord&lt;br /&gt;
    return None&lt;br /&gt;
&lt;br /&gt;
def calculateNewPoint(p1, p2, distance):&lt;br /&gt;
    v1 = cpv.sub(p1, p2)&lt;br /&gt;
    return cpv.add(p2, cpv.scale(v1, distance))&lt;br /&gt;
&lt;br /&gt;
def makeAtom(index, atomDetails, chain):&lt;br /&gt;
    atom = chempy.Atom()&lt;br /&gt;
    atom.index = index&lt;br /&gt;
    atom.name = atomDetails['name']&lt;br /&gt;
    atom.symbol = atomDetails['symbol']&lt;br /&gt;
    atom.resn = atomDetails['residueName']&lt;br /&gt;
    atom.chain = chain&lt;br /&gt;
    atom.resi = atomDetails['residueNumber']&lt;br /&gt;
    atom.resi_number = int(atomDetails['residueNumber'])&lt;br /&gt;
    atom.coord = atomDetails['coords']&lt;br /&gt;
    atom.hetatm = False&lt;br /&gt;
    return atom&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;createAtomAlongBond&amp;quot;, createAtomAlongBond)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Gilleain</name></author>
	</entry>
</feed>