Pass outside variable in HQL expression

I am having trouble to pass a python variable inside the HQL expression? Here’s an example:
The following query that works:
vds.query_samples(‘ => sa.pheno.008 ).counter()’)

But I want to pass the code in as a variable in a loop, I couldn’t get it to work. I tried:
vds.query_samples(‘ => code ).counter()’)

I also tried adding quotes, using the “let” syntax, etc. None of them works. I couldn’t find an example in the tutorial, either. Could you point me to the the correct way to do that?


If the Python variable is a string or int or float, you can pass it directly into the string.

for example:

x = 5
vds.query_samples(' => sa.pheno == {}).collect()'.format(x))

I think in this case, your Python variable is the name of the annotation. If your variable is "sa.pheno.`008`" then you can insert this with the same format syntax:

x = "sa.pheno.`008`"
vds.query_samples(' => {}).counter()'.format(x))

That works the magic, thanks a lot!