You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Originally reported by: Giovanni Pizzi (Bitbucket: pizzi, GitHub: giovannipizzi)
Create wrapper functions (and maybe even a cmdline interface, partially already existing) to easily query attributes.
E.g., to query calculations done on a structure with a given element and at least num_elems_min, and containing a given string in the label:
#!python
def get_calcs(num_elems_min, element, label_string):
from aiida.orm import DataFactory, Calculation
from django.db.models import Count
# Find attributes referring to the given element
q1 = models.DbAttribute.objects.filter(key__startswith='sites.',key__endswith='.kind_name', tval=element)
# Find structures with those attributes
q2 = DataFactory('structure').query(dbattributes__in=q1)
# Annotate the number of attributes (of the specified type)
q3 = q2.annotate(num_elems=Count('dbattributes'))
# filter only those with at least the specified # of elements
q4 = q3.filter(num_elems__gte=num_elems_min)
# Query calculations using as input the specified structures
q5 = Calculation.query(label__contains=label_string, inputs__in=q4)
# return a Django QuerySet with the resulting calculations
return q5.distinct()
print "I found %s entries." % get_calcs(num_elems_min=2, element='Fe', label_string='MD').count()
Originally reported by: Giovanni Pizzi (Bitbucket: pizzi, GitHub: giovannipizzi)
Create wrapper functions (and maybe even a cmdline interface, partially already existing) to easily query attributes.
E.g., to query calculations done on a structure with a given element and at least num_elems_min, and containing a given string in the label:
The text was updated successfully, but these errors were encountered: