Skip to content

Instantly share code, notes, and snippets.

@felipealbrecht
Last active July 22, 2017 03:43
Show Gist options
  • Save felipealbrecht/3f3b7439cc270949dcfb to your computer and use it in GitHub Desktop.
Save felipealbrecht/3f3b7439cc270949dcfb to your computer and use it in GitHub Desktop.
Obtaining flanking regions based on already existing regions
import xmlrpclib
import time
url = "http://deepblue.mpi-inf.mpg.de/xmlrpc"
user_key = "anonymous_key"
server = xmlrpclib.Server(url, allow_none=True)
gene_names = ["RNU6-1100P", "CICP7", "MRPL20", "ANKRD65", "HES2", "ACOT7", "HES3", "ICMT"]
# Select the RP11-34P13 gene locations from gencode v23
(status, q_genes) = server.select_genes(gene_names, None, "gencode v19", None, None, None, user_key)
# Obtain the regions that starts 2500 bases pair before the regions start and have 2000 base pairs.
# The 4th argument inform that DeepBlue must consider the region strand (column STRAND) to calculate the new region
(s, before_flank_id) = server.flank(q_genes, -2500, 2000, True, user_key)
# Obtain the regions that starts 1500 bases pair after the regions end and have 500 base pairs.
# The 4th argument inform that DeepBlue must consider the region strand (column STRAND) to calculate the new region
(s, after_flank_id) = server.flank(q_genes, 1500, 500, True, user_key)
# Merge both flanking regions set and genes set
(s, flank_merge_id) = server.merge_queries(before_flank_id, after_flank_id, user_key)
(s, all_merge_id) = server.merge_queries(q_genes, flank_merge_id, user_key)
# Request the regions
(status, request_id) = server.get_regions(all_merge_id, "CHROMOSOME,START,END,STRAND,@LENGTH", user_key)
# Wait for the server processing
(status, info) = server.info(request_id, user_key)
request_status = info[0]["state"]
while request_status != "done" and request_status != "failed":
time.sleep(1)
(status, info) = server.info(request_id, user_key)
request_status = info[0]["state"]
(status, regions) = server.get_request_data(request_id, user_key)
print regions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment