0%

Iterating over entities: genes, models, and other fields

The batch_solr_request function allows you to search for multiple items that belong to the same field. Pass the list of entities to the field_list parameter and specify the field to iterate over in the field_type.

You can iterate over genes, models or any other fields in the core. In the example below, we iterate over genes.

# Write genes to the Python list.
genes = ['Prkdc', 'Xrcc5', 'Xrcc4', 'Wrn']

# Iterate over list of genes.
df = batch_solr_request(
    core='genotype-phenotype',
    params={
        'q':'*:*',
        'fl': 'marker_symbol,mp_term_name,p_value',
        'field_list': genes,
        'field_type': 'marker_symbol'
    },
    download = False
)

Note: Square brackets should be used because this is a special Python object called a list. It is stored in the genes variable, which will then become the value of the field_list parameter.