def acquire_motifdb(db_list):
    db_list_key = json.dumps(db_list)
    if (redis_connection is not None):
        if redis_connection.exists(db_list_key):
            cached_data = json.loads(redis_connection.get(db_list_key))
            return (cached_data['motifdb_spectra'], cached_data['motifdb_metadata'], set(cached_data['motifdb_features']))
    client = requests.session()
    token_output = client.get((server_url + 'initialise_api/')).json()
    token = token_output['token']
    data = {'csrfmiddlewaretoken': token}
    data['motifset_id_list'] = db_list
    data['filter'] = 'True'
    output = client.post((server_url + 'get_motifset/'), data=data).json()
    motifdb_spectra = output['motifs']
    motifdb_metadata = output['metadata']
    motifdb_features = set()
    for (m, spec) in motifdb_spectra.items():
        for f in spec:
            motifdb_features.add(f)
    if (redis_connection is not None):
        data_cache = {}
        data_cache['motifdb_spectra'] = motifdb_spectra
        data_cache['motifdb_metadata'] = motifdb_metadata
        data_cache['motifdb_features'] = list(motifdb_features)
        redis_connection.set(db_list_key, json.dumps(data_cache))
    return (motifdb_spectra, motifdb_metadata, motifdb_features)
def acquire_motifdb(db_list):
    db_list_key = json.dumps(db_list)
    if (redis_connection is not None):
        if redis_connection.exists(db_list_key):
            cached_data = json.loads(redis_connection.get(db_list_key))
            return (cached_data['motifdb_spectra'], cached_data['motifdb_metadata'], set(cached_data['motifdb_features']))
    client = requests.session()
    token_output = client.get((server_url + 'initialise_api/')).json()
    token = token_output['token']
    data = {'csrfmiddlewaretoken': token}
    data['motifset_id_list'] = db_list
    data['filter'] = 'True'
    output = client.post((server_url + 'get_motifset/'), data=data).json()
    motifdb_spectra = output['motifs']
    motifdb_metadata = output['metadata']
    motifdb_features = set()
    for (m, spec) in motifdb_spectra.items():
        for f in spec:
            motifdb_features.add(f)
    if (redis_connection is not None):
        data_cache = {}
        data_cache['motifdb_spectra'] = motifdb_spectra
        data_cache['motifdb_metadata'] = motifdb_metadata
        data_cache['motifdb_features'] = list(motifdb_features)
        redis_connection.set(db_list_key, json.dumps(data_cache))
    return (motifdb_spectra, motifdb_metadata, motifdb_features)