Пример #1
0
def add_observables(model):
    data = process_data.read_data()
    ab_map = process_data.get_antibody_map(data)
    for ab_name, agents in ab_map.items():
        patterns = []
        for agent in agents:
            try:
                monomer = model.monomers[agent.name]
            except KeyError:
                continue
            if agent.mods:
                mc = agent.mods[0]
                site_names = ['phospho', mc.residue]
                if mc.position is not None:
                    site_names.append(mc.residue + mc.position)
                for site_name in site_names:
                    try:
                        pattern = monomer(**{site_name: 'p'})
                        patterns.append(ComplexPattern([pattern], None))
                    except Exception:
                        pass
            else:
                patterns.append(ComplexPattern([monomer()], None))
        if patterns:
            if model.monomers.get(ab_name) is not None:
                obs_name = ab_name + '_obs'
            else:
                obs_name = ab_name
            if not re.match(r'[_a-z][_a-z0-9]*\Z', obs_name, re.IGNORECASE):
                obs_name = obs_name.replace('-', '_')
            if not re.match(r'[_a-z][_a-z0-9]*\Z', obs_name, re.IGNORECASE):
                obs_name = 'p' + obs_name
            o = Observable(obs_name, ReactionPattern(patterns))
            model.add_component(o)
    '''
Пример #2
0
def run(dec_thresh=-1, inc_thresh=1):
    data = pd.read_data(pd.data_file)
    ab_agents = pd.get_antibody_map(data)

    # If filtering is to be done based on thresholds only,
    # set this to None
    drug_ab_combs = get_eval_drug_ab_combs(data)
    #drug_ab_combs = None

    stmts, values = make_stmts(data,
                               ab_agents,
                               drug_ab_combs=drug_ab_combs,
                               thresh=[dec_thresh, inc_thresh])

    # Now, preassemble the statements to remove duplicates
    pa_dict = preassemble_stmts(stmts)

    with open('data_stmts.pkl', 'wb') as f:
        pickle.dump((pa_dict, values), f, protocol=2)

    return (stmts, values)
Пример #3
0
        if json_dict[drug].get(ab) is None:
            json_dict[drug][ab] = {}
        for idx, path in enumerate(paths):
            path_stmts = []
            for rule_name, sign in path[:-1]:
                stmt = _stmt_from_rule(model, rule_name, stmts)
                path_stmts.append(stmt.uuid)
            json_dict[drug][ab][idx] = path_stmts
    return json_dict

if __name__ == '__main__':
    print("Processing data")

    data = process_data.read_data(process_data.data_file)
    data_genes = process_data.get_all_gene_names(data)
    ab_map = process_data.get_antibody_map(data)

    print('Loading data statements.')
    data_stmts, data_values = make_stmts.run(dec_thresh=0.5, inc_thresh=1.5)
    all_data_stmts = [values.values() for values in data_stmts.values()]
    all_data_stmts = itertools.chain.from_iterable(all_data_stmts)
    all_data_stmts = list(itertools.chain.from_iterable(all_data_stmts))

    print('We will check the following drug-ab combinations:\n============')
    for drug, stmtd in data_stmts.items():
        print(drug)
        for ab in stmtd.keys():
            print('-'+ ab)

    agent_obs = list(itertools.chain.from_iterable(ab_map.values()))
    # Here we need to cross-reference the antbody map with the data values