<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Willpitt</id>
	<title>PyMOL Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pymol.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Willpitt"/>
	<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php/Special:Contributions/Willpitt"/>
	<updated>2026-04-14T23:21:55Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.pymol.org/index.php?title=Ccp4_ncont&amp;diff=1003</id>
		<title>Ccp4 ncont</title>
		<link rel="alternate" type="text/html" href="https://wiki.pymol.org/index.php?title=Ccp4_ncont&amp;diff=1003"/>
		<updated>2010-07-06T12:38:31Z</updated>

		<summary type="html">&lt;p&gt;Willpitt: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:HhaExample.png|thumb|300px|right|Interface residues (at cutoff &amp;lt;4A) in the 2c7r.pdb were found using NCONT. Usage of ContactsNCONT script in PyMOL allows easy selection of residues and atoms listed in ncont.log file. Interacting protein and DNA residues are colored in red and slate, respectively. Atoms in contact are shown in dots.]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
The script selects residues and atoms from the list of the contacts found by NCONT from CCP4 Program Suite (NCONT analyses contacts between subsets of atoms in a PDB file).&lt;br /&gt;
First, we run NCONT on our pdb file to find interface residues. Then by using the ContactsNCONT script in PyMOL we separately select residues and atoms listed in a ncont.log file. This generates two selections (atoms and residues) for each interacting chain, allowing quick manipulation of (sometimes) extensive lists in NCONT log file.&lt;br /&gt;
&lt;br /&gt;
This script works best for intermolecular contacts (when NCONT target and source selections don't overlap). If crystal contacts (NCONT parameter cell = 1 or 2) are included then additional coding is required to distinguish inter from intramolecular contacts.&lt;br /&gt;
     &lt;br /&gt;
== Usage ==&lt;br /&gt;
&lt;br /&gt;
selectContacts( contactsfile, selName1 = &amp;quot;source&amp;quot;, selName2 = &amp;quot;target&amp;quot; )&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First use NCONT to find interface residues/atoms in the pdb file. Once you have ncont.log file proceed to PyMOL.&lt;br /&gt;
Make sure you've run the ContactsNCONT script first.&lt;br /&gt;
 &lt;br /&gt;
 fetch 2c7r&lt;br /&gt;
 selectContacts ncont.log, selName1=prot, selName2=dna&lt;br /&gt;
&lt;br /&gt;
[[File:HhaI20example.png|thumb|300px|right|Quick and easy selection of interacting residues and atoms listed in the NCONT log file. Protein and DNA residues are colored in red and slate, respectively. Atoms in contact are shown in dots.]]&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;
 import re&lt;br /&gt;
 &lt;br /&gt;
 def parseContacts( f ):&lt;br /&gt;
    # /1/B/ 282(PHE). / CE1[ C]:  /1/E/ 706(GLN). / O  [ O]:   3.32&lt;br /&gt;
    # conParser = re.compile(&amp;quot;\s*/(\d+)/([A-Z])/\s*(\d+).*?/\s*([A-Z0-9]*).*?:&amp;quot;)&lt;br /&gt;
    conParser = re.compile(&amp;quot;\s*/(\d+)/([A-Z]*)/\s*(\d+).*?/\s*([A-Z0-9]*).*?:&amp;quot;) # * is needed when chain code is blank&lt;br /&gt;
    mode = 0&lt;br /&gt;
    s1 = []&lt;br /&gt;
    s2 = []&lt;br /&gt;
    pairs = []&lt;br /&gt;
    for line in f:&lt;br /&gt;
        if mode == 0:&lt;br /&gt;
            if line.strip().startswith(&amp;quot;SOURCE ATOMS&amp;quot;):&lt;br /&gt;
                mode = 1&lt;br /&gt;
        elif mode == 1:&lt;br /&gt;
            mode = 2&lt;br /&gt;
        elif mode == 2:&lt;br /&gt;
            matches = conParser.findall(line)&lt;br /&gt;
            if len(matches) == 0:&lt;br /&gt;
                return (s1, s2, pairs)&lt;br /&gt;
            if len(matches) == 2:&lt;br /&gt;
                s1.append(matches[0])&lt;br /&gt;
                s2.append(matches[1])&lt;br /&gt;
            elif len(matches) == 1:&lt;br /&gt;
                s2.append(matches[0])&lt;br /&gt;
            pairs.append((len(s1)-1, len(s2)-1))&lt;br /&gt;
        else:&lt;br /&gt;
            print &amp;quot;Unknown mode&amp;quot;, mode&lt;br /&gt;
 &lt;br /&gt;
 def selectContacts( contactsfile, selName1 = &amp;quot;source&amp;quot;, selName2 = &amp;quot;target&amp;quot; ):&lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    selectContacts -- parses CCP4 NCONT log file and selects residues and atoms from the list of the contacts found.&lt;br /&gt;
 &lt;br /&gt;
    PARAMS&lt;br /&gt;
        contactsfile&lt;br /&gt;
            filename of the CCP4 NCONT contacts log file&lt;br /&gt;
 &lt;br /&gt;
        selName1&lt;br /&gt;
            the name prefix for the _res and _atom selections returned for the&lt;br /&gt;
            source set of chain&lt;br /&gt;
 &lt;br /&gt;
        selName2&lt;br /&gt;
            the name prefix for the _res and _atom selections returned for the &lt;br /&gt;
            target set of chain&lt;br /&gt;
 &lt;br /&gt;
    RETURNS&lt;br /&gt;
        * 2 selections of interface residues and atoms for each chain are created and named&lt;br /&gt;
            depending on what you passed into selName1 and selName2&lt;br /&gt;
 &lt;br /&gt;
    AUTHOR:&lt;br /&gt;
        Gerhard Reitmayr and Dalia Daujotyte, 2009.       &lt;br /&gt;
    &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
    # read and parse contacts file into two lists of contact atoms and contact pair list&lt;br /&gt;
    s1, s2, pairs = parseContacts(open(contactsfile))&lt;br /&gt;
    # create a selection for the first contact list&lt;br /&gt;
    resName = selName1 + &amp;quot;_res&amp;quot;&lt;br /&gt;
    atomName = selName1 + &amp;quot;_atom&amp;quot;&lt;br /&gt;
    cmd.select(resName, None)&lt;br /&gt;
    cmd.select(atomName, None)&lt;br /&gt;
    for (thing, chain, residue, atom) in s1:&lt;br /&gt;
        cmd.select( resName, resName + &amp;quot; or &amp;quot; + chain+&amp;quot;/&amp;quot;+residue+&amp;quot;/&amp;quot;)&lt;br /&gt;
        cmd.select( atomName, atomName + &amp;quot; or &amp;quot; + chain+&amp;quot;/&amp;quot;+residue+&amp;quot;/&amp;quot;+atom)&lt;br /&gt;
 &lt;br /&gt;
    # create a selection for the second contact list&lt;br /&gt;
    resName = selName2 + &amp;quot;_res&amp;quot;&lt;br /&gt;
    atomName = selName2 + &amp;quot;_atom&amp;quot;&lt;br /&gt;
    cmd.select(resName, None)&lt;br /&gt;
    cmd.select(atomName, None)&lt;br /&gt;
    for (thing, chain, residue, atom) in s2:&lt;br /&gt;
        cmd.select( resName, resName + &amp;quot; or &amp;quot; + chain+&amp;quot;/&amp;quot;+residue+&amp;quot;/&amp;quot;)&lt;br /&gt;
        cmd.select( atomName, atomName + &amp;quot; or &amp;quot; + chain+&amp;quot;/&amp;quot;+residue+&amp;quot;/&amp;quot;+atom)&lt;br /&gt;
 &lt;br /&gt;
 cmd.extend(&amp;quot;selectContacts&amp;quot;, selectContacts)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library]] [[Category:ThirdParty Scripts]] [[Category:Structural Biology Scripts]]&lt;/div&gt;</summary>
		<author><name>Willpitt</name></author>
	</entry>
</feed>