<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Agreed about not constructing what's already available and costly to
construct!<br>
<br>
Speaking of consistency, 'selection' of 'atom_selection_cache' uses
'string' as the argument, not selstr as in 'model', example:<br>
<br>
mmtbx/utils/tst_switch_rotamers.py: sel =
ph.atom_selection_cache().selection(string = "not resname TYR")<br>
<br>
I see the different between these flavors of select*. Ok, I afraid
I'll have to read the code each time I use these..<br>
<br>
Pavel<br>
<br>
<div class="moz-cite-prefix">On 8/16/18 16:01, Oleg Sobolev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CADd3otGaErKAPrgxjfA3PD8vcT=sLRXUBfkiZSgieSbs1jt=BA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<div dir="ltr">Hi Pavel,<br>
<div class="gmail_extra"><br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">
<div bgcolor="#FFFFFF" text="#000000">Currently model
class has three selection methods:<br>
<br>
def selection(self, selstr, optional=True):<br>
</div>
</div>
</div>
</blockquote>
<div>Takes selection string, returns bool selection </div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">
<div bgcolor="#FFFFFF" text="#000000"> def
select(self, selection):<br>
</div>
</div>
</div>
</blockquote>
<div>Takes selection (bool or iselection), applies it to
self and returns selected part of model object. </div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">
<div bgcolor="#FFFFFF" text="#000000"> def
iselection(self, selstr):<br>
</div>
</div>
</div>
</blockquote>
<div>Same as first, but returns iselection.</div>
<div><br>
</div>
<div><br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">
<div bgcolor="#FFFFFF" text="#000000"> which is
hideously confusing with zero chance to remember,
and also inconsistent with the rest. <br>
</div>
</div>
</div>
</blockquote>
<div>Let me disagree on the point of inconsistency with the
rest. </div>
<div>selection and iselection functions are available with
exactly same meaning for atom_selection_cache.</div>
<div>select is available with exact same meaning (returning
part of an object) in hierarchy, af_shared_atom,
flex.vec3_double, xray_structure etc which you pointed
out. </div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">
<div bgcolor="#FFFFFF" text="#000000"> Can we
consolidate all three into one ".select()" that
would allow taking bool or int or str? </div>
</div>
</div>
</blockquote>
<div>
<div
style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">No,
because they are doing different things. Selection and
iselection wraps atom_selection_cache functionality and
not duplicating those of select() function. ".select()"
function already has the described functionality.</div>
</div>
<div> </div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">
<div bgcolor="#FFFFFF" text="#000000">Or you think
there are philosophical arguments against it?<br>
</div>
</div>
</div>
</blockquote>
<div>Yes, and practical ones as well. I'm caching
atom_selection_cache inside model object, so you don't
have to construct it again if you use wrappers available
in model class. hierarchy.atom_selection_cache() is not a
free function to the point I had to pass the cache around
to avoid constructing it again to achieve measurable
speedup. Especially for larger models.</div>
<div><br>
</div>
<div>At the very least, please use
model.get_atom_selection_cache() instead of constructing
it.</div>
<div><br>
</div>
<div>Best regards,</div>
<div>Oleg Sobolev.</div>
<div> <br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb">
<div class="h5">
<div bgcolor="#FFFFFF" text="#000000"> <br>
Pavel<br>
<br>
<div class="m_5786486340573780857moz-cite-prefix">On
8/16/18 15:00, CCTBX commit wrote:<br>
</div>
<blockquote type="cite"> <tt>Repository : <a
class="m_5786486340573780857moz-txt-link-freetext"
moz-do-not-send="true">ssh://g18-sc-serv-04.diamond.<wbr>ac.uk/cctbx</a><br>
On branch : master<br>
<br>
<hr><br>
<br>
commit c98b44997e8eb7bf53ee828f510b93<wbr>3cd5167758<br>
Author: Oleg Sobolev <a
class="m_5786486340573780857moz-txt-link-rfc2396E"
href="mailto:osobolev@lbl.gov" target="_blank"
moz-do-not-send="true"><osobolev@lbl.gov></a><br>
Date: Thu Aug 16 15:00:20 2018 -0700<br>
<br>
Proper use of model class<br>
<br>
<br>
<hr><br>
<br>
c98b44997e8eb7bf53ee828f510b93<wbr>3cd5167758<br>
mmtbx/model/model.py | 3 +--<br>
1 file changed, 1 insertion(+), 2 deletions(-)<br>
<br>
diff --git a/mmtbx/model/model.py
b/mmtbx/model/model.py<br>
index 6f2247452..87412f95c 100644<br>
<tt style="color:#800">---
a/mmtbx/model/model.py</tt><br>
<tt style="color:#008">+++
b/mmtbx/model/model.py</tt><br>
@@ -2312,8 +2312,7 @@ class manager(object):<br>
sizes = <a href="http://flex.int"
target="_blank" moz-do-not-send="true">flex.int</a>()<br>
h = self.get_hierarchy()<br>
if(macro_molecule_only):<br>
<tt style="color:#800">- asc =
h.atom_selection_cache()</tt><br>
<tt style="color:#800">- s =
asc.selection("protein or nucleotide")</tt><br>
<tt style="color:#008">+ s =
self.selection("protein or nucleotide")</tt><br>
h = h.select(s)<br>
for r in h.residue_groups():<br>
sizes.append(r.atoms().<wbr>size())</tt><br>
</blockquote>
<br>
</div>
</div>
</div>
<br>
______________________________<wbr>_________________<br>
cctbxbb mailing list<br>
<a href="mailto:cctbxbb@phenix-online.org"
moz-do-not-send="true">cctbxbb@phenix-online.org</a><br>
<a
href="http://phenix-online.org/mailman/listinfo/cctbxbb"
rel="noreferrer" target="_blank" moz-do-not-send="true">http://phenix-online.org/<wbr>mailman/listinfo/cctbxbb</a><br>
<br>
</blockquote>
</div>
<br>
</div>
</div>
</blockquote>
<br>
</body>
</html>