accessing attributes of PHIL parameters
Hi, Most likely a trivial question but if I have a PHIL object such as one based on the string arrayinfo_phil_str = """ selected_info { span = True .type = bool .short_caption = "Span" minmax_data = True .type = bool .short_caption = "min,max data" } """ I can then get the PHIL definitions span and minmax_data as python values like: from libtbx.phil import parse parse(arrayinfo_phil_str).extract().selected_info.span parse(arrayinfo_phil_str).extract().selected_info.minmax_data But how do I access the values of the short_caption attribute of these definitions? Does that make sense or have not understood correctly how PHIL works? Thanks, Rob -- This email has been checked for viruses by AVG. https://www.avg.com
Hi Rob,
Yes, you can access those attributes, but you have to work with the phil
object, not the extract. Here is some sample code. There is more code in
the libtbx/phil/interface.py that builds some dictionaries for tracking
these values.
arrayinfo_phil_str = """
selected_info {
span = True
.type = bool
.short_caption = "Span"
minmax_data = True
.type = bool
.short_caption = "min,max data"
}
"""
def recursive_show(phil_object):
for o in phil_object.objects:
if o.is_scope:
recursive_show(o)
elif o.is_definition:
# o.show()
print('My name is', o.name)
print('My value is', str(o.words[0]))
print('My type is', str(o.type))
print('My short_caption is', o.short_caption)
print('My full path is', o.full_path())
# print(dir(o))
from libtbx.phil import parse
p = parse(arrayinfo_phil_str)
recursive_show(p)
--
Billy K. Poon
Research Scientist, Molecular Biophysics and Integrated Bioimaging
Lawrence Berkeley National Laboratory
1 Cyclotron Road, M/S 33R0345
Berkeley, CA 94720
Fax: (510) 486-5909
Web: https://phenix-online.org
On Thu, Oct 14, 2021 at 4:40 PM Robert Oeffner
Hi,
Most likely a trivial question but if I have a PHIL object such as one based on the string
arrayinfo_phil_str = """ selected_info { span = True .type = bool .short_caption = "Span" minmax_data = True .type = bool .short_caption = "min,max data" } """
I can then get the PHIL definitions span and minmax_data as python values like:
from libtbx.phil import parse parse(arrayinfo_phil_str).extract().selected_info.span parse(arrayinfo_phil_str).extract().selected_info.minmax_data
But how do I access the values of the short_caption attribute of these definitions? Does that make sense or have not understood correctly how PHIL works?
Thanks,
Rob
-- This email has been checked for viruses by AVG. https://www.avg.com
_______________________________________________ cctbxbb mailing list [email protected] http://phenix-online.org/mailman/listinfo/cctbxbb
participants (2)
-
Billy Poon
-
Robert Oeffner