Example #1
0
def print_initial_conditions(cell_lines, gene_names, fname):
    """Print a table with initial states/conditions for each cell line."""
    fh = open(fname, 'wt')
    genes_per_model = {}
    # First we collect the state and initial value of proteins
    # in each cell line into a dict
    for cell_line in cell_lines:
        genes_per_model[cell_line] = {}
        model = pklload('pysb_model_%s' % cell_line)
        inits = sorted(model.initial_conditions,
                       key=lambda x: x[0].monomer_patterns[0].monomer.name)
        # A list of "basic" states, deviation from which indicates
        # a "special" state like a mutated form
        basic_states = ['n', 'u', 'WT', 'inactive', None]
        # Iterate over all the initial conditions to collect them
        # in the genes_per_model datastructure
        for cplx, initial in inits:
            name = cplx.monomer_patterns[0].monomer.name
            extra_states = []
            for site, state in cplx.monomer_patterns[0].site_conditions.items(
            ):
                if site == 'loc':
                    continue
                if state not in basic_states:
                    extra_states.append('%s=%s' % (site, state))

            val_str = '%d' % initial.value
            if extra_states:
                val_str += ' (%s)' % ', '.join(extra_states)
            genes_per_model[cell_line][name] = val_str
    # Print the file while skipping proteins that aren't in any of
    # the cell line specific models.
    header = 'Protein\t' + '\t'.join(cell_lines) + '\n'
    fh.write(header)
    for gene in gene_names:
        line_vals = [gene]
        no_val = True
        for cell_line in cell_lines:
            val = genes_per_model[cell_line].get(gene)
            if not val:
                val = '-'
            else:
                no_val = False
            line_vals.append(val)
        line = '\t'.join(line_vals)
        if not no_val:
            fh.write(line + '\n')
    fh.close()
Example #2
0
    data = read_rppa_data()
    antibody_agents = get_antibody_agents()
    agents_to_observe = []
    for agents in antibody_agents.values():
        agents_to_observe += agents

    # Get all the data for Task 5
    stmts_to_check = get_task_5(data, INVERSE)
    dose = 1.0
    scored_paths = {}
    models = {}
    global_mc = None
    # Run model checking per cell line
    for cell_line in stmts_to_check.keys():
        print('Cell line: %s\n=============' % cell_line)
        model = pklload('pysb_model_%s' % cell_line)
        scored_paths[cell_line] = {}
        # Make a Model Checker with the
        # - model contextualized to the cell line
        # - the statements for the given condition
        # - agents for which observables need to be made
        global_mc = get_global_mc(model, stmts_to_check, agents_to_observe)
        for drug in stmts_to_check[cell_line].keys():
            print('Drug: %s\n=============' % drug)
            # Get all the statements and values for the condition
            stmts_condition, values_condition = \
                stmts_to_check[cell_line][drug][dose]
            path_results = []
            for stmt in stmts_condition:
                pr = global_mc.check_statement(stmt, 100, 7)
                path_results.append(pr)
Example #3
0
import pickle
from indra.sources import trips
from indra.explanation.model_checker import PysbModelChecker
from util import pklload

pysb_model = pklload('pysb_model')
pysb_stmts = pklload('pysb_stmts')

#stmts_to_check = trips.process_text('BRAF phosphorylates MAPK1.').statements
stmts_to_check = trips.process_text('HRAS phosphorylates MAPK1.').statements

mc = PysbModelChecker(pysb_model, stmts_to_check)
#paths = mc.check_model(max_paths=100, max_path_length=6)
Example #4
0
from util import pklload
from collections import defaultdict
import indra.tools.assemble_corpus as ac

if __name__ == '__main__':
    # Load cached Statements just before going into the model
    stmts = pklload('pysb_stmts')

    # Start a dictionary for source counts
    sources_count = defaultdict(int)
    # Count statements according to sources of evidence
    for stmt in stmts:
        sources = tuple(
            sorted(list(set([ev.source_api for ev in stmt.evidence]))))
        sources_count[sources] += 1

    # Statements from databases only
    db_only = 0
    # Statements from reading only
    reading_only = 0
    # Statements from databases and reading
    mixture = 0
    # Database sources
    dbs = set(['bel', 'biopax', 'phosphosite', 'signor'])
    # Reader sources
    readers = set(['reach', 'trips', 'sparser', 'r3'])
    for k, v in sources_count.items():
        d = set(k).intersection(dbs)
        r = set(k).intersection(readers)
        if d and r:
            mixture += v