コード例 #1
0
def test_gilda_disambiguation():
    gm.gilda_mode = 'web'
    er1 = Agent('NDR1', db_refs={'TEXT': 'NDR1'})
    pmid1 = '18362890'
    stmt1 = Phosphorylation(None, er1,
                            evidence=[Evidence(pmid=pmid1,
                                               text_refs={'PMID': pmid1})])

    er2 = Agent('NDR1', db_refs={'TEXT': 'NDR1'})
    pmid2 = '16832411'
    stmt2 = Inhibition(None, er2,
                       evidence=[Evidence(pmid=pmid2,
                                          text_refs={'PMID': pmid2})])
    mapped_stmts1 = gm.map_stmts([stmt1])
    assert mapped_stmts1[0].sub.name == 'STK38', mapped_stmts1[0].sub.name
    assert mapped_stmts1[0].sub.db_refs['HGNC'] == '17847', \
        mapped_stmts1[0].sub.db_refs
    assert mapped_stmts1[0].sub.db_refs['UP'] == 'Q15208', \
        mapped_stmts1[0].sub.db_refs

    mapped_stmts2 = gm.map_stmts([stmt2])
    assert mapped_stmts2[0].obj.name == 'NDRG1', \
        mapped_stmts2[0].obj.name
    assert mapped_stmts2[0].obj.db_refs['HGNC'] == '7679', \
        mapped_stmts2[0].obj.db_refs
    assert mapped_stmts2[0].obj.db_refs['UP'] == 'Q92597', \
        mapped_stmts2[0].obj.db_refs

    annotations = mapped_stmts2[0].evidence[0].annotations
    assert len(annotations['agents']['gilda'][1]) == 2, \
        annotations
    assert annotations['agents']['gilda'][0] is None
    assert annotations['agents']['gilda'][1] is not None
コード例 #2
0
ファイル: chembl_client.py プロジェクト: reynoldsm88/indra
def get_inhibition(drug, target):
    chebi_id = drug.db_refs.get('CHEBI')
    mesh_id = drug.db_refs.get('MESH')
    if chebi_id:
        drug_chembl_id = chebi_client.get_chembl_id(chebi_id)
    elif mesh_id:
        drug_chembl_id = get_chembl_id(mesh_id)
    else:
        logger.error('Drug missing ChEBI or MESH grounding.')
        return None

    target_upid = target.db_refs.get('UP')
    if not target_upid:
        logger.error('Target missing UniProt grounding.')
        return None
    target_chembl_id = get_target_chemblid(target_upid)

    logger.info('Drug: %s, Target: %s' % (drug_chembl_id, target_chembl_id))
    query_dict = {
        'query': 'activity',
        'params': {
            'molecule_chembl_id': drug_chembl_id,
            'target_chembl_id': target_chembl_id,
            'limit': 10000
        }
    }
    res = send_query(query_dict)
    evidence = []
    for assay in res['activities']:
        ev = get_evidence(assay)
        if not ev:
            continue
        evidence.append(ev)
    st = Inhibition(drug, target, evidence=evidence)
    return st
コード例 #3
0
ファイル: processor.py プロジェクト: maparent/indra
 def _process_line(self, line):
     drug = self._extract_drug(line)
     prot = self._extract_protein(line)
     if prot is None:
         return
     evidence = self._make_evidence(line)
     self.statements.append(Inhibition(drug, prot, evidence=evidence))
コード例 #4
0
def get_with_drug_statement(rel, evidences):
    drug = get_drug_agent(rel['result'], rel['resultID1'])
    virus = get_virus_agent(rel['virus'])
    stmt = Inhibition(drug,
                      virus,
                      evidence=[get_evidence(ev) for ev in evidences])
    return stmt
コード例 #5
0
ファイル: test_groundingmapper.py プロジェクト: Gab0/indra
def test_adeft_mapping():
    er1 = Agent('ER', db_refs={'TEXT': 'ER'})
    pmid1 = '30775882'
    stmt1 = Phosphorylation(None, er1, evidence=[Evidence(pmid=pmid1,
                                                          text_refs={'PMID':
                                                                     pmid1})])

    er2 = Agent('ER', db_refs={'TEXT': 'ER'})
    pmid2 = '28369137'
    stmt2 = Inhibition(None, er2, evidence=[Evidence(pmid=pmid2,
                                                     text_refs={'PMID':
                                                                pmid2})])

    gm = GroundingMapper(default_grounding_map, default_agent_map)
    mapped_stmts1 = gm.map_agents([stmt1])
    assert mapped_stmts1[0].sub.name == 'ESR1'
    assert mapped_stmts1[0].sub.db_refs['HGNC'] == '3467'
    assert mapped_stmts1[0].sub.db_refs['UP'] == 'P03372'

    mapped_stmts2 = gm.map_agents([stmt2])
    assert mapped_stmts2[0].obj.name == 'Endoplasmic Reticulum'
    assert mapped_stmts2[0].obj.db_refs['GO'] == 'GO:0005783'

    annotations = mapped_stmts2[0].evidence[0].annotations
    assert 'GO:GO:0005783' in annotations['agents']['adeft'][1]
コード例 #6
0
def test_assemble_model_chemical_agents():
    stmts = [
        Activation(Agent('BRAF'), Agent('KRAS')),
        Inhibition(Agent('DRUG', db_refs={'CHEBI': '123'}), Agent('BRAF'))
    ]
    model = tra_module.assemble_model(stmts)
    assert model.parameters['DRUG_0'].value == 10000.0
コード例 #7
0
def test_get_chemical_agents():
    stmts = [
        Activation(Agent('BRAF'), Agent('KRAS')),
        Inhibition(Agent('DRUG', db_refs={'CHEBI': '123'}), Agent('BRAF'))
    ]
    chemical_agents = tra_module.get_chemical_agents(stmts)
    assert chemical_agents == ['DRUG']
コード例 #8
0
def test_msa_custom_corpus_stmt_type():
    # Create a pickle with a test statement
    test_corpus = 'test_corpus2.pkl'
    kras = Agent('KRAS', db_refs={'HGNC': '6407'})
    st1 = Phosphorylation(Agent('x'), kras)
    st2 = Inhibition(Agent('y'), kras)
    st3 = Activation(Agent('z'), kras)
    with open(test_corpus, 'wb') as fh:
        pickle.dump([st1, st2, st3], fh)
    # Instantiate MSA with that pickle as the corpus
    msa = MSA(corpus_config='pickle:%s' % test_corpus)

    # Query the MSA
    finder = msa.find_mechanisms('to_target',
                                 target=kras,
                                 verb='activate')
    # Make sure we got the original statement back
    res_stmts = finder.get_statements()
    assert res_stmts[0].__class__.__name__ == 'Activation'
    assert res_stmts[0].subj.name == 'z'

    finder = msa.find_mechanisms('to_target',
                                 target=kras,
                                 verb='phosphorylate')
    # Make sure we got the original statement back
    res_stmts = finder.get_statements()
    assert res_stmts[0].__class__.__name__ == "Phosphorylation"
    assert res_stmts[0].enz.name == 'x'
コード例 #9
0
def test_adeft_mapping():
    er1 = Agent('ER', db_refs={'TEXT': 'ER'})
    pmid1 = '30775882'
    stmt1 = Phosphorylation(None, er1, evidence=[Evidence(pmid=pmid1,
                                                          text_refs={'PMID':
                                                                     pmid1})])

    er2 = Agent('ER', db_refs={'TEXT': 'ER'})
    pmid2 = '28369137'
    stmt2 = Inhibition(None, er2, evidence=[Evidence(pmid=pmid2,
                                                     text_refs={'PMID':
                                                                pmid2})])

    mapped_stmts1 = gm.map_stmts([stmt1])
    assert mapped_stmts1[0].sub.name == 'ESR', \
        mapped_stmts1[0].sub.name
    assert mapped_stmts1[0].sub.db_refs['FPLX'] == 'ESR', \
        mapped_stmts1[0].sub.db_refs

    mapped_stmts2 = gm.map_stmts([stmt2])
    assert mapped_stmts2[0].obj.name == 'endoplasmic reticulum', \
        mapped_stmts2[0].obj.name
    assert mapped_stmts2[0].obj.db_refs['GO'] == 'GO:0005783', \
        mapped_stmts2[0].obj.db_refs

    annotations = mapped_stmts2[0].evidence[0].annotations
    assert 'GO:GO:0005783' in annotations['agents']['adeft'][1]
コード例 #10
0
def test_assemble_model_targeted_agents():
    stmts = [
        Activation(Agent('BRAF'), Agent('KRAS')),
        Inhibition(Agent('DRUG'), Agent('BRAF'))
    ]
    model = tra_module.assemble_model(stmts)
    assert model.parameters['BRAF_0'].value == 50.0
    assert model.parameters['BRAF_0_mod'].value == 50.0
コード例 #11
0
def _get_db_no_pa_stmts():
    db = get_temp_db(clear=True)

    db_builder = DbBuilder(db)
    db_builder.add_text_refs([('12345', 'PMC54321'), ('24680', 'PMC08642'),
                              ('97531', )])
    db_builder.add_text_content([['pubmed-ttl', 'pubmed-abs', 'pmc_oa'],
                                 ['pubmed-abs', 'manuscripts'],
                                 ['pubmed-ttl', 'pubmed-abs']])
    db_builder.add_readings([['REACH', 'TRIPS'], ['REACH', 'SPARSER'],
                             ['REACH', 'ISI'],
                             ['SPARSER'], ['REACH', 'SPARSER'],
                             ['SPARSER', 'TRIPS', 'REACH'], ['REACH',
                                                             'EIDOS']])
    db_builder.add_raw_reading_statements([
        [Phosphorylation(mek, erk)],  # reach pubmed title
        [Phosphorylation(mek, erk, 'T', '124')],  # trips pubmed title
        [
            Phosphorylation(mek, erk),
            Inhibition(erk, ras), (Phosphorylation(mek, erk), 'in the body')
        ],  # reach pubmed-abs
        [
            Complex([mek, erk]),
            Complex([erk, ras]), (Phosphorylation(None, erk), 'In the body')
        ],  # sparser pubmed-abs
        [],  # reach pmc_oa
        [],  # ISI pmc_oa
        [Phosphorylation(map2k1, mapk1)],  # sparser pubmed-abs
        [],  # reach manuscripts
        [],  # sparser manuscripts
        [Inhibition(simvastatin_ng, raf),
         Activation(map2k1_mg, erk)],  # sparser pubmed title
        [],  # TRIPS pubmed title
        [],  # reach pubmed title
        [],  # reach pubmed abs
        [],  # eidos pubmed abs
    ])
    db_builder.add_databases(['biopax', 'tas', 'bel'])
    db_builder.add_raw_database_statements([[
        Activation(mek, raf),
        Inhibition(erk, ras),
        Phosphorylation(mek, erk)
    ], [Inhibition(simvastatin, raf)], [Phosphorylation(mek, erk, 'T',
                                                        '124')]])
    return db
コード例 #12
0
def test_find_contradicts():
    st1 = Inhibition(Agent('a'), Agent('b'))
    st2 = Activation(Agent('a'), Agent('b'))
    st3 = IncreaseAmount(Agent('a'), Agent('b'))
    st4 = DecreaseAmount(Agent('a'), Agent('b'))
    pa = Preassembler(hierarchies, [st1, st2, st3, st4])
    contradicts = pa.find_contradicts()
    assert len(contradicts) == 2
    for s1, s2 in contradicts:
        assert {s1.uuid, s2.uuid} in ({st1.uuid,
                                       st2.uuid}, {st3.uuid, st4.uuid})
コード例 #13
0
ファイル: test_reactome_prior.py プロジェクト: pagreene/emmaa
def test_find_drugs_for_genes():
    # SearchTerm for SRC
    SRC = SearchTerm(type='gene',
                     name='SRC',
                     search_term='"SRC"',
                     db_refs={'HGNC': '11283'})
    # drugs targeting KRAS
    drug_terms = find_drugs_for_genes([SRC], [
        Inhibition(Agent('Dasatinib', db_refs={'CHEBI': 'CHEBI:49375'}),
                   Agent('SRC', db_refs={'HGNC': '11283'})),
        Inhibition(Agent('Ponatinib', db_refs={'CHEBI': 'CHEBI:78543'}),
                   Agent('SRC', db_refs={'HGNC': '11283'}))
    ])

    # make sure there are results
    assert drug_terms

    # make sure the result is a list of search terms
    assert all(isinstance(term, SearchTerm) for term in drug_terms)

    # test that some example drugs are included
    drug_names = set(term.name for term in drug_terms)
    assert drug_names == set(['Dasatinib', 'Ponatinib'])
コード例 #14
0
 def _process_row(self, row):
     drugs = self._extract_drugs(row['compound_ids'], row['lspci_id'])
     prot = self._extract_protein(row['entrez_gene_symbol'],
                                  row['entrez_gene_id'])
     evidences = self._make_evidences(row['tas'], row['references'])
     # NOTE: there are several entries in this data set that refer to
     # non-human Entrez genes, e.g.
     # https://www.ncbi.nlm.nih.gov/gene/3283880
     # We skip these for now because resources for Entrez-based
     # mappings for non-human genes are not integrated, and would cause
     # pre-assembly issues.
     if 'HGNC' not in prot.db_refs:
         return
     for drug in drugs:
         self.statements.append(Inhibition(drug, prot, evidence=evidences))
コード例 #15
0
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
コード例 #16
0
def test_get_search_terms():
    gp = GeneListPrior(['BRAF'], 'braf', 'BRAF model')
    assert gp.name == 'braf'
    assert gp.human_readable_name == 'BRAF model'
    st = gp.make_search_terms([
        Inhibition(Agent('vemurafenib', db_refs={'CHEBI': 'CHEBI:63637'}),
                   Agent('BRAF', db_refs={
                       'HGNC': '1097',
                       'UP': 'P15056'
                   }))
    ])
    assert st
    assert all([isinstance(s, SearchTerm) for s in st])
    assert st[0].type == 'gene'
    assert st[0].search_term == '"BRAF"'
    assert st[1].type == 'drug'
    assert st[1].search_term == '"vemurafenib"', st[1].search_term
コード例 #17
0
def test_find_contradicts():
    st1 = Inhibition(Agent('a'), Agent('b'))
    st2 = Activation(Agent('a'), Agent('b'))
    st3 = IncreaseAmount(Agent('a'), Agent('b'))
    st4 = DecreaseAmount(Agent('a'), Agent('b'))
    st5 = ActiveForm(
        Agent('a', mods=[ModCondition('phosphorylation', None, None, True)]),
        'kinase', True)
    st6 = ActiveForm(
        Agent('a', mods=[ModCondition('phosphorylation', None, None, True)]),
        'kinase', False)
    pa = Preassembler(hierarchies, [st1, st2, st3, st4, st5, st6])
    contradicts = pa.find_contradicts()
    assert len(contradicts) == 3
    for s1, s2 in contradicts:
        assert {s1.uuid,
                s2.uuid} in ({st1.uuid,
                              st2.uuid}, {st3.uuid,
                                          st4.uuid}, {st5.uuid, st6.uuid})
コード例 #18
0
def test_targeted_agents():
    stmts = [
        Activation(Agent('BRAF'), Agent('KRAS')),
        Inhibition(Agent('DRUG'), Agent('BRAF'))
    ]
    assert tra_module.get_targeted_agents(stmts) == ['BRAF']
コード例 #19
0
def _get_db_with_pa_stmts():
    db = get_temp_db(clear=True)

    db_builder = DbBuilder(db)
    db_builder.add_text_refs([('12345', 'PMC54321'), ('24680', 'PMC08642'),
                              ('97531', ), ('87687', )])
    db_builder.add_text_content([['pubmed-ttl', 'pubmed-abs', 'pmc_oa'],
                                 ['pubmed-ttl', 'pubmed-abs', 'manuscripts'],
                                 ['pubmed-ttl', 'pubmed-abs', 'pmc_oa'],
                                 ['pubmed-ttl', 'pubmed-abs']])
    db_builder.add_readings([
        # Ref 1
        ['REACH', 'TRIPS'],  # pubmed ttl
        ['REACH', 'SPARSER'],  # pubmed abs
        ['REACH', 'ISI'],  # pmc_oa
        # Ref 2
        ['REACH', 'TRIPS'],  # pubmed ttl (new)
        ['SPARSER'],  # pubmed abs
        ['REACH', 'SPARSER'],  # manuscripts
        # Ref 3
        ['SPARSER', 'TRIPS', 'REACH'],  # pubmed ttl
        ['REACH', 'EIDOS', 'SPARSER'],  # pubmed abs
        ['SPARSER'],  # pmc oa (new)
        # Ref 4
        ['TRIPS', 'REACH', 'SPARSER'],  # pubmed ttl (new)
        ['REACH', 'SPARSER'],  # pubmed abs (new)
    ])

    db_builder.add_raw_reading_statements([
        # Ref 1
        # pubmed ttl
        [Phosphorylation(mek, erk)],  # reach
        [Phosphorylation(mek, erk, 'T', '124')],  # trips
        # pubmed abs
        [
            Phosphorylation(mek, erk),
            Inhibition(erk, ras), (Phosphorylation(mek, erk), 'in the body')
        ],  # reach
        [
            Complex([mek, erk]),
            Complex([erk, ras]), (Phosphorylation(None, erk), 'In the body')
        ],  # sparser
        # pmc OA
        [],  # reach
        [],  # ISI

        # Ref 2
        # pubmed ttl
        [Phosphorylation(map2k1, mapk1)],  # reach (new)
        [Phosphorylation(map2k1, mapk1, 'T', '124')],  # trips (new)
        # pubmed abs
        [Phosphorylation(map2k1, mapk1)],  # sparser
        # manuscript
        [],  # reach
        [],  # sparser

        # Ref 3
        # pubmed ttl
        [],  # sparser
        [Inhibition(simvastatin, raf)],  # TRIPS
        [],  # reach
        # pubmed abs
        [],  # reach
        [],  # eidos
        [Activation(map2k1_mg, erk),
         Inhibition(simvastatin_ng, raf)],  # sparser (new)
        # pmc oa
        [
            Inhibition(simvastatin_ng, raf),
            Inhibition(erk, ras),
            Activation(ras, raf)
        ],  # sparser (new)

        # Ref 4
        # pubmed ttl
        [],  # trips (new)
        [],  # reach (new)
        [],  # sparser (new)
        # pubmed abstract
        [
            Activation(kras, braf),
            Complex([map2k1, mapk1]),
            Complex([kras, braf])
        ],  # reach (new)
        [
            Complex([kras, braf]),
            Complex([mek, erk]),
            IncreaseAmount(kras, braf)
        ],  # sparser (new)
    ])
    db_builder.add_databases(['biopax', 'tas', 'bel'])
    db_builder.add_raw_database_statements([[
        Activation(mek, raf),
        Inhibition(erk, ras),
        Phosphorylation(mek, erk),
        Activation(ras, raf)
    ], [Inhibition(simvastatin, raf)], [Phosphorylation(mek, erk, 'T',
                                                        '124')]])
    db_builder.add_pa_statements([(Phosphorylation(mek, erk), [0, 2, 4,
                                                               25], [1, 8]),
                                  (Phosphorylation(mek, erk, 'T',
                                                   '124'), [1, 28]),
                                  (Phosphorylation(None, erk), [7], [0, 1, 8]),
                                  (Activation(mek, raf), [23]),
                                  (Inhibition(simvastatin, raf), [11, 27]),
                                  (Complex([mek, erk]), [5]),
                                  (Complex([erk, ras]), [6]),
                                  (Inhibition(erk, ras), [3, 24]),
                                  (Phosphorylation(map2k1, mapk1), [10])])

    # Add the preassembly update.
    pu = db.PreassemblyUpdates(corpus_init=True)
    db.session.add(pu)
    db.session.commit()

    return db
コード例 #20
0
ファイル: chembl_client.py プロジェクト: reynoldsm88/indra
def get_drug_inhibition_stmts(drug):
    """Query ChEMBL for kinetics data given drug as Agent get back statements

    Parameters
    ----------
    drug : Agent
        Agent representing drug with MESH or CHEBI grounding

    Returns
    -------
    stmts : list of INDRA statements
        INDRA statements generated by querying ChEMBL for all kinetics data of
        a drug interacting with protein targets
    """
    chebi_id = drug.db_refs.get('CHEBI')
    mesh_id = drug.db_refs.get('MESH')
    if chebi_id:
        drug_chembl_id = chebi_client.get_chembl_id(chebi_id)
    elif mesh_id:
        drug_chembl_id = get_chembl_id(mesh_id)
    else:
        logger.error('Drug missing ChEBI or MESH grounding.')
        return None
    logger.info('Drug: %s' % (drug_chembl_id))
    query_dict = {
        'query': 'activity',
        'params': {
            'molecule_chembl_id': drug_chembl_id,
            'limit': 10000
        }
    }
    res = send_query(query_dict)
    activities = res['activities']
    targ_act_dict = activities_by_target(activities)
    target_chembl_ids = [x for x in targ_act_dict]
    protein_targets = get_protein_targets_only(target_chembl_ids)
    filtered_targ_act_dict = {
        t: targ_act_dict[t]
        for t in [x for x in protein_targets]
    }
    stmts = []
    for target_chembl_id in filtered_targ_act_dict:
        target_activity_ids = filtered_targ_act_dict[target_chembl_id]
        target_activites = [
            x for x in activities if x['activity_id'] in target_activity_ids
        ]
        target_upids = []
        targ_comp = protein_targets[target_chembl_id]['target_components']
        for t_c in targ_comp:
            target_upids.append(t_c['accession'])
        evidence = []
        for assay in target_activites:
            ev = get_evidence(assay)
            if not ev:
                continue
            evidence.append(ev)
        if len(evidence) > 0:
            for target_upid in target_upids:
                agent_name = uniprot_client.get_gene_name(target_upid)
                target_agent = Agent(agent_name, db_refs={'UP': target_upid})
                st = Inhibition(drug, target_agent, evidence=evidence)
                stmts.append(st)
    return stmts
コード例 #21
0
def test_dump_build():
    """Test the dump pipeline.

    Method
    ------
    CREATE CONTEXT:
    - Create a local principal database with a small amount of content.
      Aim for representation of stmt motifs and sources.
    - Create a local readonly database.
    - Create a fake bucket (moto)

    RUN THE DUMP

    CHECK THE RESULTS
    """
    assert config.is_db_testing()

    # Create the dump locale.
    s3 = boto3.client('s3')
    dump_head = config.get_s3_dump()
    s3.create_bucket(Bucket=dump_head.bucket)
    assert dump_head.bucket == S3_DATA_LOC['bucket']

    # Create the principal database.
    db = get_temp_db(clear=True)

    db.copy('text_ref', [        # trid
        ('1', 1, 'PMC1', 1),     # 1
        ('2', 2, 'PMC2', 2),     # 2
        ('3', 3, None, None),    # 3
        (None, None, 'PMC4', 4)  # 4
    ], ('pmid', 'pmid_num', 'pmcid', 'pmcid_num'))

    db.copy('mesh_ref_annotations', [
        (1, 11, False),
        (1, 13, False),
        (1, 12, True),
        (2, 12, True),
        (3, 13, False),
        (3, 33, True)
    ], ('pmid_num', 'mesh_num', 'is_concept'))

    db.copy('text_content', [              # tcid
        (1, 'pubmed', 'txt', 'abstract'),  # 1
        (1, 'pmc', 'xml', 'fulltext'),     # 2
        (2, 'pubmed', 'txt', 'title'),     # 3
        (3, 'pubmed', 'txt', 'abstract'),  # 4
        (3, 'pmc', 'xml', 'fulltext'),     # 5
        (4, 'pmc', 'xml', 'fulltext')      # 6
    ], ('text_ref_id', 'source', 'format', 'text_type'))

    db.copy('reading', [(tcid, rdr, 1, reader_versions[rdr][-1], 'emtpy')
                        for tcid, rdr in [
        # 1             2             3
        (1, 'reach'), (1, 'eidos'), (1, 'isi'),

        # 4
        (2, 'reach'),

        # 5             6            7
        (3, 'reach'), (3, 'eidos'), (3, 'trips'),

        # 8
        (4, 'reach'),

        # 9
        (5, 'reach'),

        # 10
        (6, 'reach')
    ]], ('text_content_id', 'reader', 'batch_id', 'reader_version', 'format'))

    db.copy('db_info', [
        ('signor', 'signor', 'Signor'),       # 1
        ('pc', 'biopax', 'Pathway Commons'),  # 2
        ('medscan', 'medscan', 'MedScan')     # 3
    ], ('db_name', 'source_api', 'db_full_name'))

    raw_stmts = {
        'reading': {
            2: [
                Inhibition(
                    Agent('Fever', db_refs={'TEXT': 'fever', 'MESH': 'D005334'}),
                    Agent('Cough', db_refs={'TEXT': 'cough', 'MESH': 'D003371'}),
                    evidence=Evidence(text="We found fever inhibits cough.")
                )
            ],
            4: [
                Phosphorylation(
                    Agent('MEK', db_refs={'FPLX': 'MEK', 'TEXT': 'mek'}),
                    Agent('ERK', db_refs={'FPLX': 'MEK', 'TEXT': 'erk'}),
                    evidence=Evidence(text="mek phosphorylates erk, so say I.")
                ),
                Activation(
                    Agent('MAP2K1', db_refs={'HGNC': '6840', 'TEXT': 'MEK1'}),
                    Agent('MAPK1', db_refs={'HGNC': '6871', 'TEXT': 'ERK1'}),
                    evidence=Evidence(text="MEK1 activates ERK1, or os I'm told.")
                ),
                Activation(
                    Agent('ERK', db_refs={'FPLX': 'ERK', 'TEXT': 'ERK'}),
                    Agent('JNK', db_refs={'FPLX': 'JNK', 'TEXT': 'JNK'}),
                    evidence=Evidence(text="ERK activates JNK, maybe.")
                ),
                Complex([
                    Agent('MEK', db_refs={'FPLX': 'MEK', 'TEXT': 'MAP2K'}),
                    Agent('ERK', db_refs={'FPLX': 'ERK', 'TEXT': 'MAPK'}),
                    Agent('RAF', db_refs={'FPLX': 'RAF', 'TEXT': 'RAF'})
                ], evidence=Evidence(text="MAP2K, MAPK, and RAF form a complex."))
            ],
            7: [
                Activation(
                    Agent('ERK', db_refs={'FPLX': 'ERK', 'TEXT': 'ERK'}),
                    Agent('JNK', db_refs={'FPLX': 'JNK', 'TEXT': 'JNK'}),
                    evidence=Evidence(text='ERK activates JNK, maybe.')
                )
            ],
            8: [
                Complex([
                    Agent('MEK', db_refs={'FPLX': 'MEK', 'TEXT': 'mek'}),
                    Agent('ERK', db_refs={'FPLX': 'ERK', 'TEXT': 'erk'})
                ], evidence=Evidence(text="...in the mek-erk complex."))
            ],
        },
        'databases': {
            2: [
                Conversion(
                    Agent('FRK', db_refs={'HGNC': '3955'}),
                    [Agent('ATP', db_refs={'MESH': 'D000255'})],
                    [Agent('hydron', db_refs={'CHEBI': 'CHEBI:15378'})]
                )
            ],
            3: [
                Phosphorylation(
                    Agent('MEK', db_refs={'FPLX': 'MEK', 'TEXT': 'MEK'}),
                    Agent('ERK', db_refs={'FPLX': 'ERK', 'TEXT': 'ERK'}),
                    evidence=Evidence(text="...MEK phosphorylates ERK medscan.")
                )
            ]
        }
    }
    simple_insert_stmts(db, raw_stmts)

    # Run preassembly.
    prass.create_corpus(db)

    # Do the dump proceedure.
    ro = get_temp_ro(clear=True)
    dump(db, ro)

    # Check that the s3 dump exists.
    all_dumps = dm.list_dumps()
    assert len(all_dumps) == 1

    # Check to make sure all the dump files are present.
    dump_path = all_dumps[0]
    file_list = dump_path.list_objects(s3)
    assert dm.Start.from_list(file_list)
    assert dm.Readonly.from_list(file_list)
    assert dm.Belief.from_list(file_list)
    assert dm.Sif.from_list(file_list)
    assert dm.StatementHashMeshId.from_list(file_list)
    assert dm.FullPaStmts.from_list(file_list)
    assert dm.End.from_list(file_list)

    # Check what tables are active in the readonly database.
    active_tables = ro.get_active_tables()
    for tbl in ro.get_tables():
        if ro.tables[tbl]._temp:
            # If it was temp, it should be gone.
            assert tbl not in active_tables
        else:
            # Otherwise, it should be there.
            assert tbl in active_tables

    # Check that the principal db has no more ro schema.
    assert 'readonly' not in db.get_schemas()

    # Check contents of the readonly database.
    assert len(ro.select_all(ro.FastRawPaLink)) \
           == len(db.select_all(db.RawUniqueLinks))

    # Check that a query basically works.
    from indra_db.client.readonly import HasAgent
    res = HasAgent('MEK').get_statements(ro)
    assert len(res.statements()) == 2, len(res.statements())

    # Check that belief is represented in the table.
    bdict = {h: b for h, b in ro.select_all([ro.SourceMeta.mk_hash,
                                             ro.SourceMeta.belief])}
    assert all(1 >= b > 0 for b in bdict.values())

    # Check to make sure lambda was diverted correctly.
    call_records = config.get_test_call_records()
    assert len(call_records) == 2
    assert all(rec.func_name == '_set_lambda_env' for rec in call_records)
    assert all(isinstance(rec.args[1], dict) for rec in call_records)
    assert 'INDRAROOVERRIDE' in call_records[0].args[1]
    assert call_records[0].args[1]['INDRAROOVERRIDE'] == str(db.url)
    assert not call_records[1].args[1]