本文整理汇总了Python中intermine.webservice.Service.query方法的典型用法代码示例。如果您正苦于以下问题:Python Service.query方法的具体用法?Python Service.query怎么用?Python Service.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intermine.webservice.Service
的用法示例。
在下文中一共展示了Service.query方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: humanmine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
def humanmine():
for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["humanmine primary id", "humanmine primary identifier", "humanmine primary gene id", "humanmine primary gene identifier"]):
s = Service("www.humanmine.org/humanmine")
Gene = s.model.Gene
q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
gene_object = {}
for row in q.rows():
process = row.__str__()
for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
temp_str = x[1]
if temp_str[0] == "'" and temp_str[-1] == "'":
temp_str = temp_str[1:-1]
if x[0] == "description":
gene_object["description"] = temp_str.strip()
elif x[0] == "cytoLocation":
gene_object["cytogenetic_location"] = temp_str.strip()
elif x[0] == "id":
gene_object["id"] = temp_str.strip()
elif x[0] == "length":
gene_object["length"] = temp_str.strip()
elif x[0] == "primaryIdentifier":
gene_object["primary_id"] = temp_str.strip()
elif x[0] == "score":
gene_object["score"] = temp_str.strip()
elif x[0] == "scoreType":
gene_object["score_type"] = temp_str.strip()
elif x[0] == "secondaryIdentifier":
gene_object["secondary_id"] = temp_str.strip()
elif x[0] == "symbol":
gene_object["symbol"] = temp_str.strip()
return gene_object
示例2: attack
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
def attack(self):
username = "user-weapon-{0}@noreply.intermine.org".format(self.ident)
password = "yolo"
try:
s = Service(self.service.root, username, password)
s.deregister(s.get_deregistration_token())
self.counter.add(3)
except:
pass
s = self.service.register(username, password)
self.LOG.debug("Registered user " + username)
self.counter.add(1)
c = 0
classes = s.model.classes.values()
self.counter.add(1)
classkeys = s._get_json('/classkeys')['classes']
self.counter.add(1)
while c == 0:
table = random.choice(classes)
if not (table.has_id and table.name in classkeys):
continue
query = s.query(table.name).select(classkeys[table.name][0])
c = query.count()
self.counter.add(1)
n = random.randint(1, min(100, c))
members = random.sample(map(lambda r: r[0], query.rows()), n)
self.counter.add(1)
self.LOG.debug("Will construct list of %s with: %r", table.name, members)
with s.list_manager() as lm:
l = lm.create_list(members, table.name)
self.LOG.debug('Created list %s, size: %d', l.name, l.size)
self.counter.add(1)
try:
s.deregister(s.get_deregistration_token())
self.counter.add(2)
except:
pass
示例3: ratmine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
def ratmine(gene):
for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["ratmine primary id", "ratmine primary identifier", "ratmine primary gene id", "ratmine primary gene identifier"]):
s = Service("http://ratmine.mcw.edu/ratmine")
Gene = s.model.Gene
q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
gene_object = {}
for row in q.rows():
process = row.__str__()
for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
temp_str = x[1]
if temp_str[0] == "'" and temp_str[-1] == "'":
temp_str = temp_str[1:-1]
if x[0] == "briefDescription":
if temp_str.strip() == "None":
gene_object["brief_description"] = None
else:
gene_object["brief_description"] = temp_str.strip()
elif x[0] == "description":
gene_object["description"] = temp_str.strip()
elif x[0] == "geneType":
gene_object["gene_type"] = temp_str.strip()
elif x[0] == "id":
gene_object["id"] = temp_str.strip()
elif x[0] == "length":
gene_object["length"] = temp_str.strip()
elif x[0] == "name":
gene_object["name"] = temp_str.strip()
elif x[0] == "ncbi_gene_number":
gene_object["ncbiGeneNumber"] = temp_str.strip()
elif x[0] == "pharmGKBidentifier":
gene_object["pharmGKB_id"] = temp_str.strip()
elif x[0] == "primaryIdentifier":
gene_object["primary_id"] = temp_str.strip()
elif x[0] == "score":
gene_object["score"] = temp_str.strip()
elif x[0] == "scoreType":
gene_object["score_type"] = temp_str.strip()
elif x[0] == "secondaryIdentifier":
gene_object["secondary_id"] = temp_str.strip()
elif x[0] == "symbol":
gene_object["symbol"] = temp_str.strip()
return gene_object
示例4: flymine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
def flymine(gene):
obj_array = []
for ident in gene.identifiers:
if ident["identifier_type"].lower() in ["ensembl", "ensembl id", "ensembl identifier", "ensembl gene id"]:
s = Service("www.flymine.org/query")
Gene = s.model.Gene
q = s.query(Gene).select("*").where("Gene", "LOOKUP", ident["identifier"])
try:
for row in q.rows():
primary_identifier = row["primaryIdentifier"]
brief_description = row["briefDescription"]
cyto_location = row["cytoLocation"]
description = row["description"]
identifier = row["id"]
length_of_gene = row["length"]
name_of_gene = row["name"]
score = row["score"]
score_type = row["scoreType"]
secondary_identifier = row["secondaryIdentifier"]
gene_symbol = row["symbol"]
gene_object = {
'id': identifier,
'primary_id': primary_identifier,
'secondary_id': secondary_identifier,
'symbol': gene_symbol,
'name': name_of_gene,
'cyto_location': cyto_location,
'brief_description': brief_description,
'description': description,
'length': length_of_gene,
'score': score,
'score_type': score_type
}
obj_array.append(gene_object)
except intermine.errors.WebserviceError:
print("A webservice error occurred. Please contact Intermine support.")
else:
print("Something else went wrong.")
return obj_array
示例5: wormmine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
def wormmine(gene):
for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["wormmine primary id", "wormmine primary identifier", "wormmine primary gene id", "wormmine primary gene identifier"]):
s = Service("http://intermine.wormbase.org/tools/wormmine")
Gene = s.model.Gene
q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
gene_object = {}
for row in q.rows():
process = row.__str__()
for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
temp_str = x[1]
if temp_str[0] == "'" and temp_str[-1] == "'":
temp_str = temp_str[1:-1]
if x[0] == "id":
gene_object["id"] = temp_str.strip()
elif x[0] == "lastUpdated":
gene_object["last_updated"] = temp_str.strip()
elif x[0] == "length":
gene_object["length"] = temp_str.strip()
elif x[0] == "name":
gene_object["name"] = temp_str.strip()
elif x[0] == "operon":
gene_object["operon"] = temp_str.strip()
elif x[0] == "primary_id":
gene_object["primary_id"] = temp_str.strip()
elif x[0] == "score":
gene_object["score"] = temp_str.strip()
elif x[0] == "score_type":
gene_object["score_type"] = temp_str.strip()
elif x[0] == "secondary_id":
gene_object["secondary_id"] = temp_str.strip()
elif x[0] == "symbol":
gene_object["symbol"] = temp_str.strip()
return gene_object
示例6: len
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
col_width = 15
cols = 8
sep = '| '
ellipsis = '...'
line_width = col_width * cols + (cols - 1) * len(sep)
fit_to_cell = lambda a: a.ljust(col_width) if len(a) <= col_width else a[:col_width - len(ellipsis)] + ellipsis
hrule = "-" * line_width
summary = "\n%s: %d Alleles"
s = Service("www.flymine.org/query")
Gene = s.model.Gene
q = s.query(Gene).\
add_columns("name", "symbol", "alleles.*").\
filter(Gene.symbol == ["zen", "eve", "bib", "h"]).\
filter(Gene.alleles.symbol == "*hs*").\
outerjoin(Gene.alleles).\
order_by("symbol")
for row in q.rows():
print row
for gene in s.query(s.model.Gene).filter(s.model.Gene.symbol == ["zen", "eve", "bib", "h"]).add_columns(s.model.Gene.alleles):
print summary % (gene.symbol, len(gene.alleles))
print hrule
for k, line_of_alleles in itertools.groupby(sorted(map(lambda a: a.symbol, gene.alleles)), lines_of(cols)):
print sep.join(map(fit_to_cell, line_of_alleles))
print "\nAllele Classes:"
示例7: yeastmine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
def yeastmine():
s = Service("https://yeastmine.yeastgenome.org:443/yeastmine/service")
Gene = s.model.Gene
q = s.query(Gene).select("*").where("Gene", "LOOKUP", "Rad51")
gene_object = {}
for row in q.rows():
process = row.__str__()
for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
print(x)
for iden in gnomics.objects.auxiliary_files.identifier.filter_identifiers(gene.identifiers, ["yeastmine primary id", "yeastmine primary identifier", "yeastmine primary gene id", "yeastmine primary gene identifier"]):
s = Service("https://yeastmine.yeastgenome.org:443/yeastmine/service")
Gene = s.model.Gene
q = s.query(Gene).select("*").where("Gene", "LOOKUP", iden["identifier"])
gene_object = {}
for row in q.rows():
process = row.__str__()
for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
temp_str = x[1]
if temp_str[0] == "'" and temp_str[-1] == "'":
temp_str = temp_str[1:-1]
if x[0] == "cytoLocation":
gene_object["cytogenetic_location"] = temp_str.strip()
elif x[0] == "description":
gene_object["description"] = temp_str.strip()
elif x[0] == "featAttribute":
gene_object["feature_attribute"] = temp_str.strip()
elif x[0] == "featureType":
gene_object["feature_type"] = temp_str.strip()
elif x[0] == "functionSummary":
gene_object["function_summary"] = temp_str.strip()
elif x[0] == "id":
gene_object["id"] = temp_str.strip()
elif x[0] == "jasparAccession":
gene_object["jaspar_accession"] = temp_str.strip()
elif x[0] == "jasparClass":
gene_object["jaspar_class"] = temp_str.strip()
elif x[0] == "jasparFamily":
gene_object["jaspar_family"] = temp_str.strip()
elif x[0] == "length":
gene_object["length"] = temp_str.strip()
elif x[0] == "phenotypeSummary":
gene_object["phenotype_summary"] = temp_str.strip()
elif x[0] == "primaryIdentifier":
gene_object["primary_id"] = temp_str.strip()
elif x[0] == "qualifier":
gene_object["qualifier"] = temp_str.strip()
elif x[0] == "score":
gene_object["score"] = temp_str.strip()
elif x[0] == "scoreType":
gene_object["score_type"] = temp_str.strip()
elif x[0] == "secondaryIdentifier":
gene_object["secondary_id"] = temp_str.strip()
elif x[0] == "status":
gene_object["status"] = temp_str.strip()
elif x[0] == "symbol":
gene_object["symbol"] = temp_str.strip()
elif x[0] == "name":
gene_object["name"] = temp_str.strip()
elif x[0] == "sgdAlias":
gene_object["sgd_alias"] = temp_str.strip()
return gene_object
示例8: mousemine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import query [as 别名]
def mousemine(gene):
for ident in gene.identifiers:
if ident["identifier_type"].lower() in ["ncbi", "ncbi id", "ncbi gene identifier", "ncbi gene id", "entrez gene id", "entrez id"]:
s = Service("www.mousemine.org/mousemine")
Gene = s.model.Gene
q = s.query(Gene).select("*").where("Gene", "LOOKUP", ident["identifier"])
gene_object = {}
for row in q.rows():
process = row.__str__()
for x in re.findall(r"(\w+)=('[0-9A-Za-z:()\- \[\]<>\.,]{1,}'|None|[0-9]{1,})", process):
temp_str = x[1]
if temp_str[0] == "'" and temp_str[-1] == "'":
temp_str = temp_str[1:-1]
if x[0] == "briefDescription":
if temp_str.strip() == "None":
gene_object["brief_description"] = None
else:
gene_object["brief_description"] = temp_str.strip()
elif x[0] == "description":
gene_object["description"] = temp_str.strip()
for y in re.findall(r"(FUNCTION:[0-9A-Za-z\-\(\) ,.\[]+]|PHENOTYPE:[0-9A-Za-z\-\(\) ,.\[]+])", temp_str):
y_split = y.split(":")
if y_split[0].strip() == "FUNCTION":
gene_object["function"] = y_split[1].strip()
elif y_split[0].strip() == "PHENOTYPE":
gene_object["phenotype"] = y_split[1].strip()
elif x[0] == "id":
gene_object["id"] = temp_str.strip()
elif x[0] == "length":
gene_object["length"] = temp_str.strip()
elif x[0] == "mgiType":
gene_object["mgi_type"] = temp_str.strip()
elif x[0] == "name":
gene_object["name"] = temp_str.strip()
elif x[0] == "ncbiGeneNumber":
gene_object["ncbi_gene_id"] = temp_str.strip()
elif x[0] == "primaryIdentifier":
gene_object["primary_id"] = temp_str.strip()
elif x[0] == "score":
if temp_str.strip() == "None":
gene_object["score"] = None
else:
gene_object["score"] = temp_str.strip()
elif x[0] == "scoreType":
if temp_str.strip() == "None":
gene_object["score_type"] = None
else:
gene_object["score_type"] = temp_str.strip()
elif x[0] == "secondaryIdentifier":
if temp_str.strip() == "None":
gene_object["secondary_id"] = None
else:
gene_object["secondary_id"] = temp_str.strip()
elif x[0] == "specificity":
if temp_str.strip() == "None":
gene_object["specificity"] = None
else:
gene_object["specificity"] = temp_str.strip()
elif x[0] == "symbol":
gene_object["symbol"] = temp_str.strip()
return gene_object