Skip to main content

Package to interrogate motif-broker JS microservice with python

Project description

motif-broker-request

Example in test/test.py

Configure motif-broker-request

import motif_broker_request.request as mb_request

mb_request.configure("http://localhost:5984") #Default is localhost:3282

You can also change bulk length

mb_request.set_bulk_length(10000) #Default is 50000

Request motif-broker

sgrnas = ["AAAAAAAAAAAAAAAAAAATGGG", "TCCAAAAAAAAACAGTGGATTGG", "CACTAAAAAAGAAGACCAAGCGG"] # sgRNAs you want to search
res = mb_request.get(sgrnas)

print(res)
>

Request motif-broker with some filter

You can write filter functions. This functions have to take motif_broker results as arguments and return the filtered version with same format

Example of function that just keep given genomes in results :

def filter_genomes(mb_res, **kwargs):
    if not "genomes" in kwargs:
        raise Exception("you must provide 'genomes' argument to get function for filter_genomes function")
    genomes = kwargs["genomes"]

    filtered_results = {}
    for sgrna in mb_res: 
        added = False 
        for org in mb_res[sgrna]:
            if org in genomes:
                if added:
                    filtered_results[sgrna][org] = mb_res[sgrna][org]
                else:
                    filtered_results[sgrna] = {org : mb_res[sgrna][org]}

    return filtered_results

Applied this way to get results :

res = mb_request.get(sgrnas, filter_predicate=filter_genomes, genomes=["dd6cfb980c8a3659acffa4f002ea7404", "dd6cfb980c8a3659acffa4f0029ff84a"])
print(res)
> 

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

motif-broker-request-1.0.0.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

motif_broker_request-1.0.0-py3-none-any.whl (2.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page