def test_nl_modeling(): # 1 code chunk from indra.sources import trips model_text = 'MAP2K1 phosphorylates MAPK1 and DUSP6 dephosphorylates MAPK1.' tp = trips.process_text(model_text) # 2nd code chunk for st in tp.statements: assert st.evidence[0].text # Replaces a print statement in the doc # 3rd code chunk from indra.assemblers.pysb import PysbAssembler pa = PysbAssembler() pa.add_statements(tp.statements) pa.make_model(policies='two_step') # 4th code chunk for monomer in pa.model.monomers: assert monomer # This replaces a print statements in the doc # 5th code chunk for rule in pa.model.rules: assert rule # This replaces a print statements in the doc # 6th code chunk for parameter in pa.model.parameters: assert parameter # This replaces a print statements in the doc # 7th code chunk for annotation in pa.model.annotations: assert annotation # This replaces a print statements in the doc # 8th code chunk (this code is currently in a commented out section) pa.set_context('A375_SKIN') for monomer_pattern, parameter in pa.model.initial_conditions: assert monomer_pattern assert parameter.value # 9th code chunk _ = pa.export_model('sbml') assert _ _ = pa.export_model('bngl') assert _
def contextualize_model(model, cell_line, genes): """Contextualize model at the level of a PySB model.""" # Here we just make a PysbAssembler to be able # to apply set_context on the model being passed in model.name = cell_line cell_line_ccle = cell_line + '_SKIN' pa = PysbAssembler() pa.model = model pa.set_context(cell_line_ccle) # Set initial conditions for missense mutations variants = read_ccle_variants(genes) mutations = variants['missense'][cell_line_ccle] for gene, mut_list in mutations.items(): for fres, loc, tres in mut_list: site_name = fres + loc for ic in model.initial_conditions: if ic[0].monomer_patterns[0].monomer.name == gene: sc = ic[0].monomer_patterns[0].site_conditions if site_name in sc: sc[site_name] = tres return pa.model