本文整理汇总了Python中intermine.webservice.Service.new_query方法的典型用法代码示例。如果您正苦于以下问题:Python Service.new_query方法的具体用法?Python Service.new_query怎么用?Python Service.new_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intermine.webservice.Service
的用法示例。
在下文中一共展示了Service.new_query方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getInteractions
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def getInteractions():
service = Service("http://yeastmine.yeastgenome.org/yeastmine/service")
# Get a new query on the class (table) you will be querying:
query = service.new_query("Gene")
# Type constraints should come early - before all mentions of the paths they constrain
query.add_constraint("goAnnotation.ontologyTerm", "GOTerm")
# The view specifies the output columns
query.add_view(
"symbol", "interactions.details.experimentType",
"interactions.gene2.symbol", "interactions.gene2.briefDescription"
)
# You can edit the constraint values below
query.add_constraint("goAnnotation.qualifier", "IS NULL", code = "C")
query.add_constraint("goAnnotation.qualifier", "!=", "NOT", code = "B")
query.add_constraint("goAnnotation.ontologyTerm.name", "=", "cytoplasmic translation", code = "A")
query.add_constraint("name", "ONE OF", ["Ribosomal Protein of the Large subunit", "Ribosomal Protein of the Small subunit"], code = "D")
query.add_constraint("interactions.details.annotationType", "=", "manually curated", code = "E")
# Your custom constraint logic is specified with the code below:
query.set_logic("A and (B or C) and E and D")
interactions = {}
for row in query.rows():
if row["symbol"] not in interactions.keys():
interactions[row["symbol"]] = [{ "expt" : row["interactions.details.experimentType"], "gene2": row["interactions.gene2.symbol"],"desc":row["interactions.gene2.briefDescription"]}]
else:
interactions[row["symbol"]].append({ "expt": row["interactions.details.experimentType"], "gene2": row["interactions.gene2.symbol"],"desc":row["interactions.gene2.briefDescription"]})
return interactions
示例2: search_SGD
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def search_SGD(self, gene_code=None):
service = Service("http://yeastmine.yeastgenome.org/yeastmine/service")
query = service.new_query("Gene")
query.add_view(
"chromosome.primaryIdentifier",
"chromosomeLocation.end",
"chromosomeLocation.start",
"chromosomeLocation.strand",
"secondaryIdentifier",
)
query.add_constraint("symbol", "=", gene_code, code="A")
for row in query.rows():
print(
[
row["secondaryIdentifier"],
row["chromosome.primaryIdentifier"],
row["chromosomeLocation.start"],
row["chromosomeLocation.end"],
"+" if row["chromosomeLocation.strand"] else "-",
]
)
return [
row["secondaryIdentifier"],
row["chromosome.primaryIdentifier"][3:],
row["chromosomeLocation.start"],
row["chromosomeLocation.end"],
"+" if row["chromosomeLocation.strand"] else "-",
]
示例3: get_gene_id
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def get_gene_id(gene_name):
"""Retrieve systematic yeast gene name from the common name.
:param gene_name: Common name for yeast gene (e.g. ADE2).
:type gene_name: str
:returns: Systematic name for yeast gene (e.g. YOR128C).
:rtype: str
"""
service = Service("http://yeastmine.yeastgenome.org/yeastmine/service")
# Get a new query on the class (table) you will be querying:
query = service.new_query("Gene")
# The view specifies the output columns
query.add_view("primaryIdentifier", "secondaryIdentifier", "symbol",
"name", "sgdAlias", "crossReferences.identifier",
"crossReferences.source.name")
# Uncomment and edit the line below (the default) to select a custom sort
# order:
# query.add_sort_order("Gene.primaryIdentifier", "ASC")
# You can edit the constraint values below
query.add_constraint("organism.shortName", "=", "S. cerevisiae", code="B")
query.add_constraint("Gene", "LOOKUP", gene_name, code="A")
# Uncomment and edit the code below to specify your own custom logic:
# query.set_logic("A and B")
for row in query.rows():
gid = row["secondaryIdentifier"]
return gid
示例4: get_gene_id
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def get_gene_id(gene_name):
'''Retrieve systematic yeast gene name from the common name.
:param gene_name: Common name for yeast gene (e.g. ADE2).
:type gene_name: str
:returns: Systematic name for yeast gene (e.g. YOR128C).
:rtype: str
'''
from intermine.webservice import Service
service = Service('http://yeastmine.yeastgenome.org/yeastmine/service')
# Get a new query on the class (table) you will be querying:
query = service.new_query('Gene')
# The view specifies the output columns
query.add_view('primaryIdentifier', 'secondaryIdentifier', 'symbol',
'name', 'sgdAlias', 'crossReferences.identifier',
'crossReferences.source.name')
# Uncomment and edit the line below (the default) to select a custom sort
# order:
# query.add_sort_order('Gene.primaryIdentifier', 'ASC')
# You can edit the constraint values below
query.add_constraint('organism.shortName', '=', 'S. cerevisiae', code='B')
query.add_constraint('Gene', 'LOOKUP', gene_name, code='A')
# Uncomment and edit the code below to specify your own custom logic:
# query.set_logic('A and B')
for row in query.rows():
gid = row['secondaryIdentifier']
return gid
示例5: main
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def main():
"""Connects to yeastmine and creates a dictionary of annotation data.
Data is saved into shelve as well as returned."""
#print("annotations.SGD.yeastmine.main:")
service = Service("http://yeastmine.yeastgenome.org/yeastmine")
query = service.new_query()
query.add_view(
"SequenceFeature.primaryIdentifier", "SequenceFeature.featureType",
"SequenceFeature.secondaryIdentifier", "SequenceFeature.description",
"SequenceFeature.sgdAlias", "SequenceFeature.name", "SequenceFeature.symbol",
"SequenceFeature.chromosome.name", "SequenceFeature.chromosome.featAttribute",
"SequenceFeature.locations.start", "SequenceFeature.locations.end", "SequenceFeature.locations.strand"
)
query.add_constraint("SequenceFeature.organism.name", "=", "Saccharomyces cerevisiae", "A")
query.add_constraint("SequenceFeature.featureType", "=", "ORF", "B")
query.set_logic("(A and B)")
annotation = {}
#print("settins.PROJECT_ROOT: %s" % settings.PROJECT_ROOT)
#print("os.path.join: %s" % os.path.join(os.path.join(settings.PROJECT_ROOT, 'apps', 'annotations', 'SGD', 'yeastmine')))
db = shelve.open(os.path.join(settings.PROJECT_ROOT, 'apps', 'annotations', 'SGD', 'yeastmine'), 'c')
for row in query.rows():
data = {}
for x in xrange(0, len(row.views)):
attribute = row.views[x].split('.')[-1]
value = row.data[x]['value']
if attribute == 'name' and not value: continue
data[attribute] = value
if 'name' not in data: data['name'] = None
annotation[data['secondaryIdentifier']] = data
db[str(data['secondaryIdentifier'])] = data
db.close()
return annotation
示例6: query_fishmine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def query_fishmine(intermine_url: str, protein_id: str, query: str="Gene") -> IntermineResult:
service = Service(intermine_url)
query = service.new_query(query)
query.add_view("primaryIdentifier")
query.add_constraint("primaryIdentifier", "CONTAINS", "ZDB*", code="A")
query.add_constraint("crossReferences.identifier", "=", "{}".format(protein_id), code="B")
result_list = ["ZFIN:{}".format(val['primaryIdentifier']) for val in query.rows()]
return intermine_response_factory(result_list, protein_id)
示例7: get_yeast_gene_location
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def get_yeast_gene_location(gene_name):
'''Acquire the location of a gene from SGD http://www.yeastgenome.org
:param gene_name: Name of the gene.
:type gene_name: string
:returns location: [int: chromosome, int:biostart, int:bioend, int:strand]
:rtype location: list
'''
from intermine.webservice import Service
service = Service('http://yeastmine.yeastgenome.org/yeastmine/service')
# Get a new query on the class (table) you will be querying:
query = service.new_query('Gene')
# The view specifies the output columns
query.add_view('primaryIdentifier', 'secondaryIdentifier', 'symbol',
'name', 'organism.shortName',
'chromosome.primaryIdentifier',
'chromosomeLocation.start', 'chromosomeLocation.end',
'chromosomeLocation.strand')
# Uncomment and edit the line below (the default) to select a custom sort
# order:
# query.add_sort_order('Gene.primaryIdentifier', 'ASC')
# You can edit the constraint values below
query.add_constraint('organism.shortName', '=', 'S. cerevisiae',
code='B')
query.add_constraint('Gene', 'LOOKUP', gene_name, code='A')
# Uncomment and edit the code below to specify your own custom logic:
# query.set_logic('A and B')
chromosomes = {'chrI': 1,
'chrII': 2,
'chrIII': 3,
'chrIV': 4,
'chrV': 5,
'chrVI': 6,
'chrVII': 7,
'chrVIII': 8,
'chrIX': 9,
'chrX': 10,
'chrXI': 11,
'chrXII': 12,
'chrXIII': 13,
'chrXIV': 14,
'chrXV': 15,
'chrXVI': 16}
first_result = query.rows().next()
return [chromosomes[first_result['chromosome.primaryIdentifier']],
first_result['chromosomeLocation.start'],
first_result['chromosomeLocation.end'],
int(first_result['chromosomeLocation.strand'])]
示例8: query
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def query(ids):
service = Service("http://targetmine.nibio.go.jp/targetmine")
query = service.new_query("Protein")
query.add_view(
"primaryIdentifier", "primaryAccession", "name", "length",
"compounds.compound.casRegistryNumber", "compounds.compound.name",
"compounds.compound.compoundGroup.name"
)
test_id = ids[0]
query.add_constraint("Protein", "IN", ",".join(ids))
return query.rows()
示例9: get_yeast_gene_location
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def get_yeast_gene_location(gene_name):
"""Acquire the location of a gene from SGD http://www.yeastgenome.org
:param gene_name: Name of the gene.
:type gene_name: string
:returns location: [int: chromosome, int:biostart, int:bioend, int:strand]
:rtype location: list
"""
service = Service("http://yeastmine.yeastgenome.org/yeastmine/service")
# Get a new query on the class (table) you will be querying:
query = service.new_query("Gene")
# The view specifies the output columns
query.add_view("primaryIdentifier", "secondaryIdentifier", "symbol",
"name", "organism.shortName",
"chromosome.primaryIdentifier",
"chromosomeLocation.start", "chromosomeLocation.end",
"chromosomeLocation.strand")
# Uncomment and edit the line below (the default) to select a custom sort
# order:
# query.add_sort_order("Gene.primaryIdentifier", "ASC")
# You can edit the constraint values below
query.add_constraint("organism.shortName", "=", "S. cerevisiae",
code="B")
query.add_constraint("Gene", "LOOKUP", gene_name, code="A")
# Uncomment and edit the code below to specify your own custom logic:
# query.set_logic("A and B")
chromosomes = {"chrI": 1,
"chrII": 2,
"chrIII": 3,
"chrIV": 4,
"chrV": 5,
"chrVI": 6,
"chrVII": 7,
"chrVIII": 8,
"chrIX": 9,
"chrX": 10,
"chrXI": 11,
"chrXII": 12,
"chrXIII": 13,
"chrXIV": 14,
"chrXV": 15,
"chrXVI": 16}
first_result = query.rows().next()
return [chromosomes[first_result["chromosome.primaryIdentifier"]],
first_result["chromosomeLocation.start"],
first_result["chromosomeLocation.end"],
int(first_result["chromosomeLocation.strand"])]
示例10: download
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def download(self, genes, fields, scope=None, species=None):
'''
Retrives the data depending on self.constraints and self.view
'''
constraints = self.constraints
views = self.views
glist = np.array(genes)
if len(glist) > 1000:
a = len(glist) / 1000
segs = np.array_split(glist, a)
else:
segs = [glist]
# store the data in here
z = []
# API uses letters to distinguish between constraints
alpha = list(string.ascii_uppercase)
for seg in segs:
# Connect to the API
service = SS(self.datasource)
query = service.new_query("Gene")
query.add_view(",".join(views))
# Some databases require a host name
if self.hostid != "":
query.add_constraint("Gene", "LOOKUP", ",".join(seg),
self.hostid, code="A")
else:
query.add_constraint("Gene", "LOOKUP", ",".join(seg), code="A")
# Apply the constraints
if len(constraints) != 0:
i = 1
for constraint in constraints:
letter = alpha[i]
if len(constraint.split("=")) == 2:
L = constraint.split("=")
query.add_constraint(L[0], "=", L[1], code=letter)
elif re.search("IS NOT NULL", constraint):
p1 = constraint.replace(" IS NOT NULL", "")
query.add_constraint(p1, "IS NOT NULL", code=letter)
i = i + 1
# Parse the output into a list of tuples
j = 0
for row in query.rows():
t = [row['symbol']]
for v in views:
t.append(row[v])
z.append(tuple(t))
j += 1
self.dataset = z
示例11: parse
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def parse(self, limit=None):
count = 0
for num in range(10, 100):
fuzzy_gene = "MGI:{0}*".format(num)
gene = "MGI:{0}".format(num)
service = Service("http://www.mousemine.org/mousemine/service")
logging.getLogger('Model').setLevel(logging.ERROR)
logging.getLogger('JSONIterator').setLevel(logging.ERROR)
query = service.new_query("OntologyAnnotation")
query.add_constraint("subject", "SequenceFeature")
query.add_constraint("ontologyTerm", "MPTerm")
query.add_view(
"subject.primaryIdentifier", "subject.symbol",
"subject.sequenceOntologyTerm.name", "ontologyTerm.identifier",
"ontologyTerm.name", "evidence.publications.pubMedId",
"evidence.comments.type", "evidence.comments.description"
)
query.add_sort_order("OntologyAnnotation.ontologyTerm.name", "ASC")
query.add_constraint("subject.organism.taxonId", "=", self.txid, code="A")
query.add_constraint("subject", "LOOKUP", fuzzy_gene, code="B")
query.add_constraint(
"subject.primaryIdentifier", "CONTAINS", gene, code="C")
query.outerjoin("evidence.comments")
for row in query.rows():
mgi_curie = row["subject.primaryIdentifier"]
mp_curie = row["ontologyTerm.identifier"]
pub_curie = "PMID:{0}".format(row["evidence.publications.pubMedId"])
assoc = G2PAssoc(self.graph, self.name, mgi_curie, mp_curie)
if row["evidence.publications.pubMedId"]:
reference = Reference(
self.graph, pub_curie, self.globaltt['journal article'])
reference.addRefToGraph()
assoc.add_source(pub_curie)
assoc.add_evidence(self.globaltt['experimental phenotypic evidence'])
assoc.add_association_to_graph()
if not count % 10 and count != 0:
count_from = count - 10
LOG.info(
"%s processed ids from MGI:%i* to MGI:%i*",
datetime.datetime.now(), count_from, count)
count += 1
if limit and count >= limit:
break
return
示例12: query_mousemine
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def query_mousemine(intermine_url: str, gene_id: str) -> IntermineResult:
"""
:param intermine_url: intermine server, eg
http://www.mousemine.org/mousemine/service
:param gene_id: gene ID, eg ENSMUSG00000063180
:return: Intermine_Result object
"""
service = Service(intermine_url)
query = service.new_query("SequenceFeature")
query.add_view("primaryIdentifier")
query.add_constraint("SequenceFeature", "LOOKUP", "{}".format(gene_id), code="A")
query.add_constraint("organism.shortName", "=", "M. musculus", code="B")
result_list = ["{}".format(val['primaryIdentifier']) for val in query.rows()]
return intermine_response_factory(result_list, gene_id)
示例13: intermine_query
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def intermine_query(type):
from intermine.webservice import Service
service = Service("http://yeastmine.yeastgenome.org/yeastmine/service")
# Get a new query on the class (table) you will be querying:
query = service.new_query(type)
# The view specifies the output columns
query.add_view("primaryIdentifier", "sequence.residues")
# Uncomment and edit the line below (the default) to select a custom sort order:
# query.add_sort_order("Chromosome.primaryIdentifier", "ASC")
return query
示例14: test
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def test(self):
'''
Tests the HumanMine API
Look up symbol for APOBEC3G, should return APOBEC3G.
'''
service = SS('http://www.humanmine.org/humanmine/service')
query = service.new_query("Gene")
query.add_view("symbol")
query.add_constraint("Gene", "LOOKUP", "APOBEC3G", code="A")
for row in query.rows():
symbol = row['symbol']
if symbol == "APOBEC3G":
return 1
else:
return 0
示例15: getData
# 需要导入模块: from intermine.webservice import Service [as 别名]
# 或者: from intermine.webservice.Service import new_query [as 别名]
def getData(mine):
"""
A function to get datasets corresponding to a mine
================================================
example:
>>> from intermine import registry
>>> registry.getData('flymine')
Name: Affymetrix array: Drosophila1
Name: Affymetrix array: Drosophila2
Name: Affymetrix array: GeneChip Drosophila Genome 2.0 Array
Name: Affymetrix array: GeneChip Drosophila Genome Array
Name: Anoph-Expr data set
Name: BDGP cDNA clone data set.....
"""
x = "http://registry.intermine.org/service/instances/" + mine
try:
r = requests.get(x)
dict = json.loads(r.text)
link = dict["instance"]["url"]
service = Service(link)
query = service.new_query("DataSet")
query.add_view("name", "url")
list = []
for row in query.rows():
try:
list.append(row["name"])
except KeyError:
print("No info available")
list.sort()
for i in range(len(list)):
print("Name: " + list[i])
return None
except KeyError:
return "No such mine available"