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

		<summary type="html">&lt;p&gt;7 revisions&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Overview =&lt;br /&gt;
[[ConnectedCloud]] grows a cloud of objects that are &amp;quot;connected&amp;quot; through single-linkage clustering.  Two objects are &amp;quot;connected&amp;quot; if they are within the user-defined cutoff, radius.  It starts with a selection, and grows until no more objects are withing ''radius'' Angstroms of the cloud.&lt;br /&gt;
&lt;br /&gt;
Let's say we want to find the cloud of docking guesses (blue lines) that are connected to the lowest energy docking pose (red sticks).  I call,&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
connectedCloud lig1, lig*, radius=1, doPrint=True&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
and get&lt;br /&gt;
&amp;lt;gallery heights=250px widths=250px&amp;gt;&lt;br /&gt;
Image:ConnectedCloud.png|Find the cloud growing from the red sticks.  Consider all blue lines for inclusion.&lt;br /&gt;
Image:ConnectedCloud2.png|Those in the cloud are shown in red.  Notice the small blue cloud above the red was not selected.  At no point were those atoms close enough to the currently growing cloud, to be considered.&lt;br /&gt;
&amp;lt;/gallery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Syntax =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
connectedCloud origSel, subSel, [radius=1, [doPrint=True]]&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
* origSel -- the original selection to grow from&lt;br /&gt;
* subSel -- only consider these objects when growing&lt;br /&gt;
* radius -- defines &amp;quot;connectedness&amp;quot;.  Anything &amp;lt;= radius Angstroms from the growing cloud and in subSel is considered&lt;br /&gt;
* doPrint -- print some misc. info&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# Find all objects in the set &amp;quot;lig*&amp;quot; (all ligands from a docking run, for example) that are&lt;br /&gt;
# in the connected cloud of &amp;quot;connectedness&amp;quot; set to 1 Ang.  Print the number of atoms in the&lt;br /&gt;
# selection and the surface area of the selection (if it were an object).&lt;br /&gt;
connectedCloud lig427, lig*, radius=1, doPrint=True&lt;br /&gt;
&lt;br /&gt;
# select everything within 0.85 of lig2467 and don't print anything&lt;br /&gt;
connectedCloud lig2467, *, radius=0.85, doPrint=False&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= The Code =&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot; enclose=&amp;quot;pre&amp;quot;&amp;gt;&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
def connectedCloud( origSel, subSel, radius=1, doPrint=True ):&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	connectedCloud -- find all atoms, by object in subSel connected to&lt;br /&gt;
		origSel by radius Ang.  In other words, start from origSel&lt;br /&gt;
		and find all objects &amp;lt;=radius Ang. from it &amp;amp; add that to the&lt;br /&gt;
		result.  Once nothing more is added, you have your cloud of&lt;br /&gt;
		points.&lt;br /&gt;
&lt;br /&gt;
	origSel,&lt;br /&gt;
		the selection around which we start expanding.&lt;br /&gt;
&lt;br /&gt;
	subSel,&lt;br /&gt;
		the subset of objects to consider&lt;br /&gt;
&lt;br /&gt;
	radius,&lt;br /&gt;
		the maximum radius in which to consider; anything &amp;gt;radius&lt;br /&gt;
		Ang. from any objet in the current selection is ignored (unless&lt;br /&gt;
		it is added later by some other path).&lt;br /&gt;
&lt;br /&gt;
	doPrint&lt;br /&gt;
		print some values before returning the selection name&lt;br /&gt;
&lt;br /&gt;
	Author:&lt;br /&gt;
		Jason Vertrees, 2009.&lt;br /&gt;
	&lt;br /&gt;
	&amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
	cName = &amp;quot;__tempCloud__&amp;quot;&lt;br /&gt;
	cmd.select(cName, origSel)&lt;br /&gt;
&lt;br /&gt;
	# we keep track of cloud size based on the number of atoms in the selection; oldCount&lt;br /&gt;
	# is the previous iteration and curCount is after we add everything for this iteration.&lt;br /&gt;
	oldCount=0&lt;br /&gt;
	curCount=cmd.count_atoms( cName )&lt;br /&gt;
&lt;br /&gt;
	# flag to stop at 1000 iterations. if something goes wrong we don't want to hijack the computer.&lt;br /&gt;
	flag=0&lt;br /&gt;
&lt;br /&gt;
	# while something was added in this iteration&lt;br /&gt;
	while oldCount != curCount:&lt;br /&gt;
		flag += 1&lt;br /&gt;
		# grow current cloud&lt;br /&gt;
		cmd.select( cName, &amp;quot;bo. &amp;quot; + subSel + &amp;quot; within &amp;quot; + radius + &amp;quot; of &amp;quot; + cName )&lt;br /&gt;
		# update atom counts in the cloud&lt;br /&gt;
		oldCount=curCount&lt;br /&gt;
		curCount=cmd.count_atoms(cName)&lt;br /&gt;
		&lt;br /&gt;
		if ( flag &amp;gt; 1000 ):&lt;br /&gt;
			print &amp;quot;Warning: I gave up.  I grew the cloud 1000 times and it kept growing.&amp;quot;&lt;br /&gt;
			print &amp;quot;Warning: If this is valid (weird), then increases the 'flag' in the source&amp;quot;&lt;br /&gt;
			print &amp;quot;Warning: code to something &amp;gt;1000.&amp;quot;&lt;br /&gt;
			break&lt;br /&gt;
&lt;br /&gt;
	# create the object for getting its surface area&lt;br /&gt;
	cmd.create(&amp;quot;connectedCloud&amp;quot;, cName)&lt;br /&gt;
&lt;br /&gt;
	# print cloud info&lt;br /&gt;
	if doPrint:&lt;br /&gt;
		print &amp;quot;Number of atoms in cloud:&amp;quot;, str(cmd.count_atoms(cName))&lt;br /&gt;
		print &amp;quot;Surface area of cloud:&amp;quot;, str(cmd.get_area(&amp;quot;connectedCloud&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
	# delete our work &lt;br /&gt;
	cmd.delete(&amp;quot;connectedCloud&amp;quot;)&lt;br /&gt;
	# rename and return&lt;br /&gt;
	cmd.set_name(cName, &amp;quot;connectedCloud&amp;quot;)&lt;br /&gt;
	return &amp;quot;connectedCloud&amp;quot;&lt;br /&gt;
&lt;br /&gt;
cmd.extend(&amp;quot;connectedCloud&amp;quot;, connectedCloud)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Script_Library|ConnectedCloud]]&lt;br /&gt;
[[Category:ObjSel_Scripts]]&lt;/div&gt;</summary>
		<author><name>Pyadmin</name></author>
	</entry>
</feed>