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]) # 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) # something is wrong if there are fewer than 10 drugs assert len(drug_terms) > 10 # test that some example drugs are included drug_names = set(term.name for term in drug_terms) example_drugs = set(['Dasatinib', 'Tozasertib', 'Ponatinib']) assert example_drugs <= drug_names
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'])
# If all the agents are gene names, this is an internal statement. # We classify any statements with drugs in them as external. return all([a.name in gene_names for a in stmt.real_agent_list()]) estmts = [ EmmaaStatement(stmt, datetime.datetime.now(), [], {'internal': is_internal(stmt)}) for stmt in stmts ] return estmts if __name__ == '__main__': cancer_types = ( 'aml', 'brca', 'luad', 'paad', 'prad', 'skcm', ) for ctype in cancer_types: top_genes = get_top_genes(ctype, 5) cancer_terms = make_prior_from_genes(top_genes) drug_terms = find_drugs_for_genes(cancer_terms) gene_names = [g.name for g in cancer_terms] drug_names = [d.name for d in drug_terms] terms = cancer_terms + drug_terms save_config(ctype, terms) prior_stmts = get_stmts_for_gene_list(gene_names, drug_names) save_prior(ctype, prior_stmts)