本文整理汇总了Python中indra.preassembler.Preassembler.combine_duplicates方法的典型用法代码示例。如果您正苦于以下问题:Python Preassembler.combine_duplicates方法的具体用法?Python Preassembler.combine_duplicates怎么用?Python Preassembler.combine_duplicates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类indra.preassembler.Preassembler
的用法示例。
在下文中一共展示了Preassembler.combine_duplicates方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_duplicates
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_duplicates():
src = Agent('SRC', db_refs = {'HGNC': '11283'})
ras = Agent('RAS', db_refs = {'FA': '03663'})
st1 = Phosphorylation(src, ras)
st2 = Phosphorylation(src, ras)
pa = Preassembler(hierarchies, stmts=[st1, st2])
pa.combine_duplicates()
assert len(pa.unique_stmts) == 1
示例2: test_complex_refinement_order
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_complex_refinement_order():
st1 = Complex([Agent('MED23'), Agent('ELK1')])
st2 = Complex([Agent('ELK1', mods=[ModCondition('phosphorylation')]),
Agent('MED23')])
pa = Preassembler(hierarchies, stmts=[st1, st2])
pa.combine_duplicates()
pa.combine_related()
assert len(pa.related_stmts) == 1
示例3: analyze
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def analyze(filename, plot=False):
# Load the file
results = load_file(filename)
# Put together a list of all statements
all_stmts = [stmt for paper_stmts in results.values()
for stmt in paper_stmts]
# Map grounding
logger.info('Mapping grounding...')
gmap = gm.GroundingMapper(gm.default_grounding_map)
map_stmts = gmap.map_agents(all_stmts)
map_stmts = gmap.rename_agents(map_stmts)
# Combine duplicates
logger.info('Removing duplicates...')
pa = Preassembler(hierarchies, map_stmts)
pa.combine_duplicates()
# Map GO IDs to genes and associated statements
logger.info('Building map from GO IDs to stmts')
go_gene_map = {}
go_name_map = {}
for stmt in pa.unique_stmts:
(bp_name, go, gene) = go_gene_pair(stmt)
if bp_name is None and go is None and gene is None:
continue
go_gene_list = go_gene_map.get(go, [])
go_gene_list.append((gene, stmt))
go_gene_map[go] = go_gene_list
go_name_set = go_name_map.get(go, set([]))
go_name_set.add(bp_name)
go_name_map[go] = go_name_set
# Iterate over all of the GO IDs and compare the annotated genes in GO
# to the ones from the given statements
go_stmt_map = {}
for ix, go_id in enumerate(go_gene_map.keys()):
logger.info('Getting genes for %s (%s) from GO (%d of %d)' %
(go_id, ','.join(list(go_name_map[go_id])),
ix+1, len(go_gene_map.keys())))
genes_from_go = get_genes_for_go_id(go_id)
gene_stmt_list = go_gene_map[go_id]
in_go = []
not_in_go = []
for (gene, stmt) in gene_stmt_list:
if gene in genes_from_go:
in_go.append(stmt)
else:
not_in_go.append(stmt)
go_stmt_map[go_id] = {'names': list(go_name_map[go_id]),
'in_go': in_go, 'not_in_go': not_in_go}
with open('go_stmt_map.pkl', 'wb') as f:
pickle.dump(go_stmt_map, f, protocol=2)
if plot:
plot_stmt_counts(go_stmt_map, 'go_stmts.pdf')
示例4: test_agent_text_storage
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_agent_text_storage():
A1 = Agent('A', db_refs={'TEXT': 'A'})
A2 = Agent('A', db_refs={'TEXT': 'alpha'})
B1 = Agent('B', db_refs={'TEXT': 'bag'})
B2 = Agent('B', db_refs={'TEXT': 'bug'})
C = Agent('C')
D = Agent('D')
inp = [
Complex([A1, B1], evidence=Evidence(text='A complex bag.')),
Complex([B2, A2], evidence=Evidence(text='bug complex alpha once.')),
Complex([B2, A2], evidence=Evidence(text='bug complex alpha again.')),
Complex([A1, C, B2], evidence=Evidence(text='A complex C bug.')),
Phosphorylation(A1, B1, evidence=Evidence(text='A phospo bags.')),
Phosphorylation(A2, B2, evidence=Evidence(text='alpha phospho bugs.')),
Conversion(D, [A1, B1], [C, D],
evidence=Evidence(text='D: A bag -> C D')),
Conversion(D, [B1, A2], [C, D],
evidence=Evidence(text='D: bag a -> C D')),
Conversion(D, [B2, A2], [D, C],
evidence=Evidence(text='D: bug a -> D C')),
Conversion(D, [B1, A1], [C, D],
evidence=Evidence(text='D: bag A -> C D')),
Conversion(D, [A1], [A1, C],
evidence=Evidence(text='D: A -> A C'))
]
pa = Preassembler(hierarchies, inp)
unq1 = pa.combine_duplicates()
assert len(unq1) == 5, len(unq1)
assert all([len(ev.annotations['prior_uuids']) == 1
for s in unq1 for ev in s.evidence
if len(s.evidence) > 1]),\
'There can only be one prior evidence per uuid at this stage.'
ev_uuid_dict = {ev.annotations['prior_uuids'][0]: ev.annotations['agents']
for s in unq1 for ev in s.evidence}
for s in inp:
raw_text = [ag.db_refs.get('TEXT')
for ag in s.agent_list(deep_sorted=True)]
assert raw_text == ev_uuid_dict[s.uuid]['raw_text'],\
str(raw_text) + '!=' + str(ev_uuid_dict[s.uuid]['raw_text'])
# Now run pa on the above corpus plus another statement.
inp2 = unq1 + [
Complex([A1, C, B1], evidence=Evidence(text='A complex C bag.'))
]
pa2 = Preassembler(hierarchies, inp2)
unq2 = pa2.combine_duplicates()
assert len(unq2) == 5, len(unq2)
old_ev_list = []
new_ev = None
for s in unq2:
for ev in s.evidence:
if ev.text == inp2[-1].evidence[0].text:
new_ev = ev
else:
old_ev_list.append(ev)
assert all([len(ev.annotations['prior_uuids']) == 2 for ev in old_ev_list])
assert new_ev
assert len(new_ev.annotations['prior_uuids']) == 1
示例5: test_homodimer_refinement
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_homodimer_refinement():
egfr = Agent('EGFR')
erbb = Agent('ERBB2')
st1 = Complex([erbb, erbb])
st2 = Complex([erbb, egfr])
pa = Preassembler(hierarchies, stmts=[st1, st2])
pa.combine_duplicates()
assert len(pa.unique_stmts) == 2
pa.combine_related()
assert len(pa.related_stmts) == 2
示例6: test_flatten_stmts
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_flatten_stmts():
st1 = Phosphorylation(Agent('MAP3K5'), Agent('RAF1'), 'S', '338')
st2 = Phosphorylation(None, Agent('RAF1'), 'S', '338')
st3 = Phosphorylation(None, Agent('RAF1'))
st4 = Phosphorylation(Agent('PAK1'), Agent('RAF1'), 'S', '338')
st5 = Phosphorylation(None, Agent('RAF1'), evidence=Evidence(text='foo'))
pa = Preassembler(hierarchies, stmts=[st1, st2, st3, st4, st5])
pa.combine_duplicates()
pa.combine_related()
assert len(pa.related_stmts) == 2
assert len(flatten_stmts(pa.unique_stmts)) == 4
assert len(flatten_stmts(pa.related_stmts)) == 4
示例7: test_duplicates_copy
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_duplicates_copy():
src = Agent('SRC', db_refs = {'HGNC': '11283'})
ras = Agent('RAS', db_refs = {'FA': '03663'})
st1 = Phosphorylation(src, ras, evidence=[Evidence(text='Text 1')])
st2 = Phosphorylation(src, ras, evidence=[Evidence(text='Text 2')])
stmts = [st1, st2]
pa = Preassembler(hierarchies, stmts=stmts)
pa.combine_duplicates()
assert len(pa.unique_stmts) == 1
assert len(stmts) == 2
assert len(stmts[0].evidence) == 1
assert len(stmts[1].evidence) == 1
示例8: test_activation_refinement
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_activation_refinement():
subj = Agent('alcohol', db_refs={'CHEBI': 'CHEBI:16236',
'HMDB': 'HMDB00108',
'PUBCHEM': '702',
'TEXT': 'alcohol'})
obj = Agent('endotoxin', db_refs={'TEXT': 'endotoxin'})
st1 = Inhibition(subj, obj)
st2 = Activation(subj, obj)
pa = Preassembler(hierarchies, stmts=[st1, st2])
pa.combine_duplicates()
assert len(pa.unique_stmts) == 2
pa.combine_related()
assert len(pa.related_stmts) == 2
示例9: test_association_refinement
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_association_refinement():
health = 'UN/entities/human/health'
food = 'UN/entities/human/food'
food_security = 'UN/entities/human/food/food_security'
eh = Event(Concept('health', db_refs={'UN': [(health, 1.0)]}))
ef = Event(Concept('food', db_refs={'UN': [(food, 1.0)]}))
efs = Event(Concept('food security', db_refs={'UN': [(food_security, 1.0)]}))
st1 = Association([eh, ef], evidence=[Evidence(source_api='eidos1')])
st2 = Association([ef, eh], evidence=[Evidence(source_api='eidos2')])
st3 = Association([eh, efs], evidence=[Evidence(source_api='eidos3')])
st4 = Association([ef, efs], evidence=[Evidence(source_api='eidos4')])
eidos_ont = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'../sources/eidos/eidos_ontology.rdf')
hm = HierarchyManager(eidos_ont, True, True)
hierarchies = {'entity': hm}
pa = Preassembler(hierarchies, [st1, st2, st3, st4])
unique_stmts = pa.combine_duplicates() # debugging
assert len(unique_stmts) == 3
rel_stmts = pa.combine_related()
assert len(rel_stmts) == 2
eh_efs_stmt = [st for st in rel_stmts if (st.members[0].concept.name in
{'health', 'food security'} and st.members[1].concept.name
in {'health', 'food security'})][0]
assert len(eh_efs_stmt.supported_by) == 1
assert (eh_efs_stmt.supported_by[0].members[0].concept.name
in {'food', 'health'})
assert (eh_efs_stmt.supported_by[0].members[1].concept.name
in {'food', 'health'})
示例10: test_duplicates_sorting
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_duplicates_sorting():
mc = ModCondition('phosphorylation')
map2k1_1 = Agent('MAP2K1', mods=[mc])
mc1 = ModCondition('phosphorylation', 'serine', '218')
mc2 = ModCondition('phosphorylation', 'serine', '222')
mc3 = ModCondition('phosphorylation', 'serine', '298')
map2k1_2 = Agent('MAP2K1', mods=[mc1, mc2, mc3])
mapk3 = Agent('MAPK3')
#ras = Agent('MAPK3', db_refs = {'FA': '03663'})
#nras = Agent('NRAS', db_refs = {'FA': '03663'})
st1 = Phosphorylation(map2k1_1, mapk3, position='218')
st2 = Phosphorylation(map2k1_2, mapk3)
st3 = Phosphorylation(map2k1_1, mapk3, position='218')
stmts = [st1, st2, st3]
pa = Preassembler(hierarchies, stmts=stmts)
pa.combine_duplicates()
assert len(pa.unique_stmts) == 2
示例11: test_combine_evidence_exact_duplicates
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_combine_evidence_exact_duplicates():
raf = Agent('RAF1')
mek = Agent('MEK1')
p1 = Phosphorylation(raf, mek,
evidence=Evidence(text='foo'))
p2 = Phosphorylation(raf, mek,
evidence=Evidence(text='bar'))
p3 = Phosphorylation(raf, mek,
evidence=Evidence(text='bar'))
stmts = [p1, p2, p3]
pa = Preassembler(hierarchies, stmts=stmts)
pa.combine_duplicates()
# The statements come out sorted by their matches_key
assert len(pa.unique_stmts) == 1
assert len(pa.unique_stmts[0].evidence) == 2
assert set(ev.text for ev in pa.unique_stmts[0].evidence) == \
set(['foo', 'bar'])
示例12: test_grounding_aggregation
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_grounding_aggregation():
braf1 = Agent('BRAF', db_refs={'TEXT': 'braf', 'HGNC': '1097'})
braf2 = Agent('BRAF', db_refs={'TEXT': 'BRAF'})
braf3 = Agent('BRAF', db_refs={'TEXT': 'Braf', 'UP': 'P15056'})
st1 = Phosphorylation(None, braf1)
st2 = Phosphorylation(None, braf2)
st3 = Phosphorylation(None, braf3)
pa = Preassembler(hierarchies, stmts=[st1, st2, st3])
unique_stmts = pa.combine_duplicates()
assert len(unique_stmts) == 3
示例13: test_agent_coordinates
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_agent_coordinates():
path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'reach_coordinates.json')
stmts = reach.process_json_file(path).statements
pa = Preassembler(hierarchies, stmts)
unique_stmt = pa.combine_duplicates()[0]
evidence_list = unique_stmt.evidence
agent_annots = [ev.annotations['agents'] for ev in unique_stmt.evidence]
assert all(a['raw_text'] == ['MEK1', 'ERK2'] for a in agent_annots)
assert {tuple(a['coords']) for a in agent_annots} == {((21, 25), (0, 4)),
((0, 4), (15, 19))}
示例14: test_grounding_aggregation_complex
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_grounding_aggregation_complex():
mek = Agent('MEK')
braf1 = Agent('BRAF', db_refs={'TEXT': 'braf', 'HGNC': '1097'})
braf2 = Agent('BRAF', db_refs={'TEXT': 'BRAF', 'dummy': 'dummy'})
braf3 = Agent('BRAF', db_refs={'TEXT': 'Braf', 'UP': 'P15056'})
st1 = Complex([mek, braf1])
st2 = Complex([braf2, mek])
st3 = Complex([mek, braf3])
pa = Preassembler(hierarchies, stmts=[st1, st2, st3])
unique_stmts = pa.combine_duplicates()
assert len(unique_stmts) == 3
示例15: test_preassemble_related_complex
# 需要导入模块: from indra.preassembler import Preassembler [as 别名]
# 或者: from indra.preassembler.Preassembler import combine_duplicates [as 别名]
def test_preassemble_related_complex():
ras = Agent('RAS', db_refs={'FPLX': 'RAS'})
kras = Agent('KRAS', db_refs={'HGNC': '6407'})
hras = Agent('HRAS', db_refs={'HGNC': '5173'})
st1 = Complex([kras, hras])
st2 = Complex([kras, ras])
st3 = Complex([hras, kras])
st4 = Complex([ras, kras])
pa = Preassembler(hierarchies, [st1, st2, st3, st4])
uniq = pa.combine_duplicates()
assert len(uniq) == 2
top = pa.combine_related()
assert len(top) == 1