本文整理汇总了Python中intermine.webservice.Service类的典型用法代码示例。如果您正苦于以下问题:Python Service类的具体用法?Python Service怎么用?Python Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Service类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_gene_id
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
示例2: fetchGene
def fetchGene(GeneName):
service = Service("http://yeastmine.yeastgenome.org/yeastmine/service")
template = service.get_template('Gene_GenomicDNA')
rows = template.rows(
E = {"op": "LOOKUP", "value": GeneName, "extra_value": "S. cerevisiae"}
)
# this service seems to return multiple similar genes but we want the first one only, so count
# and it returns information about the gene you want
count=0
for row in rows:
count=count+1
if count==1:
descr= row["description"]
GeneSeq=Seq(row["sequence.residues"])
GeneSysName=row["secondaryIdentifier"]
#let's create a record for the oldGene
GeneRecord = SeqRecord(GeneSeq, id=GeneSysName)
#now let's add some more information to make it useful
GeneRecord.name=GeneName
GeneRecord.features=GeneSysName
GeneRecord.description=descr
return GeneRecord
示例3: main
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
示例4: plot_go_vs_p
def plot_go_vs_p(list_name):
"""
A function to plot GO Term vs P-value with label of gene count on each bar
================================================
example:
>>>from intermine import query_manager as qm
>>>b.plot_go_vs_p("PL_obesityMonogen_ORahilly09")
"""
link = "http://registry.intermine.org/service/instances/" + mine
r = requests.get(link)
dict = json.loads(r.text)
url = dict["instance"]["url"]
service = Service(url)
lm = service.list_manager()
store = lm.get_list(name=list_name)
r = store.calculate_enrichment(widget="go_enrichment_for_gene")
gene_count = []
identifier = []
p_value = []
object_count = 0
for i in r:
if object_count < 5:
gene_count.append(i.matches)
identifier.append(i.identifier)
p_value.append(i.p_value)
object_count = object_count + 1
else:
if object_count >= 5:
break
y = pd.Series(p_value)
x = identifier
# Plot the figure.
ax = y.plot(kind='bar')
ax.set_title('GO Term vs p-value (Label: Gene count)')
ax.set_xlabel('GO Term')
ax.set_ylabel('p_value')
ax.set_xticklabels(x, rotation='horizontal')
rects = ax.patches
def autolabel(rects, ax):
i = 0
for rect in rects:
x = rect.get_x() + rect.get_width()/2.
y = rect.get_height()
ax.annotate(gene_count[i], (x, y), xytext=(0, 5),
textcoords="offset points",
ha='center', va='bottom')
i = i+1
autolabel(ax.patches, ax)
ax.margins(y=0.1)
plt.show()
示例5: getInteractions
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
示例6: get_gene_id
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
示例7: search_SGD
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 "-",
]
示例8: humanmine
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
示例9: query_fishmine
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)
示例10: get_yeast_gene_location
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'])]
示例11: query
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()
示例12: get_yeast_gene_location
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"])]
示例13: parse
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
示例14: intermine_query
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
示例15: query_mousemine
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)