def test():
	parser = argparse.ArgumentParser(description='test similarity service')
	parser.add_argument('-username', required=True, help='username')
	parser.add_argument('-password', required=True, help='password')
	args = parser.parse_args()

	api = KnowledgeHubAPI()
	api.set_service('DEV')
	status = api.login(args.username, args.password)
	print(status)
	terms = api.SemanticService().lookup('Terbinafine', 'RxNorm')
	print(json.dumps(terms, indent=4, sort_keys=True))
	#if len(terms['terms']) > 0:
		#concepts = api.SemanticService().normalize(terms['terms'][0], 'RxNorm')
		#print(json.dumps(concepts, indent=4, sort_keys=True))

		#if len(concepts['concepts']) == 1:
	compounds = [
							  "Minoxidil","Estradiol","Anastrozole","Felodipine","Amphetamine",",Adenosine","Azathioprine","Levamisole",
							  #"Zolmitriptan","Lidocaine","Alprazolam","Ropivacaine","Foscarnet","Rimonabant","Remoxipride","Cyclophosphamide",
							  #"Aripiprazole","Bambuterol","Sulfamethoxazole","Rosiglitazone","Clozapine","Budesonide","Omeprazole","Raltitrexed",
							  #"Clonidine","Gefitinib","Ximelagatran","Diazepam","Olanzapine","Zafirlukast","Nifedipine","Indomethacin","Erlotinib",
							  #"Formoterol","Diclofenac","Metoprolol","Enprofylline","Bicalutamide","Chlordiazepoxide","Simvastatin","Ranitidine",
							  #"Ticagrelor","Sulfinpyrazone","Phenylbutazone","Benazepril","Isosorbide Mononitrate","Deferoxamine","Guanfacine",
							  #"Naftifine","Chlorthalidone","Guanethidine","Valproic Acid","Clozapine","Baclofen","Maprotiline","Thioridazine",
							  #"Aminoglutethimide","Bromocriptine","Phentolamine","Amantadine","Thiethylperazine","Pindolol","Lidocaine",
							  #"Linezolid","Prednisolone","Candoxatril","Diazepam","Orlistat","Carprofen","Cilazapril"
							  ]
Exemple #2
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'Process parameters for collecting findings from primitive adapter')
    parser.add_argument('-username', required=True, help='username')
    parser.add_argument('-password', required=True, help='password')
    args = parser.parse_args()

    api = KnowledgeHubAPI(server='TEST',
                          client_secret='39c644b3-1f23-4d94-a71f-e0fb43ebd760')
    api.login(args.username, args.password)

    compoundSmile = api.ChemistryService().getSMILESByName('omeprazole')
    similar_compounds = api.SimilarityService().get(compoundSmile[0])

    names = []
    smiles = []
    similarities = []

    if similar_compounds is not None:
        for similar_compound in similar_compounds:
            names.append(similar_compound['name'])
            smiles.append(similar_compound['smiles'])
            similarities.append(similar_compound['distance'])

    studies = filterStudies(api.eToxSys().getStudiesByCompoundNames(names))
    print(f'Found {len(studies)} studies.')
    for study in studies:
        print(study)

    api.SemanticService().getSocs(studies)
    otherStudies = [
        study for study in studies if study['FINDING']['__soc'] == 'Other'
    ]
    print(f'#others:{len(otherStudies)}')
Exemple #3
0
def main():
    parser = argparse.ArgumentParser(
        description=
        'Process parameters for collecting findings from primitive adapter')
    parser.add_argument('-username', required=True, help='username')
    parser.add_argument('-password', required=True, help='password')
    args = parser.parse_args()

    api = KnowledgeHubAPI(server='DEV',
                          client_secret='3db5a6d7-4694-48a4-8a2e-e9c30d78f9ab')
    api.login(args.username, args.password)

    socs = {}

    studies = api.eToxSys().getStudiesByCompoundNames(['omeprazole'])
    #studies = api.eToxSys().getStudiesBySMILES(['COc1ccc2[nH]c([S+]([O-])Cc3ncc(C)c(OC)c3C)nc2c1'])
    print(f'#studies:{len(studies)}')
    #print(studies[0])

    findings_per_specimen_organ = {}

    for study in studies:
        if study['FINDING']['finding'] != None and study['FINDING'][
                'finding'] != 'No abnormalities detected' and len(
                    study['FINDING']['finding']) > 0:
            specimenOrgans = api.SemanticService().getSocs(
                study['FINDING']['specimenOrgan'])
            for specimenOrgan in specimenOrgans:
                if len(specimenOrgan) > 0:
                    finding = study['FINDING']['specimenOrgan']

                    if specimenOrgan not in findings_per_specimen_organ:
                        findings_per_specimen_organ[specimenOrgan] = []
                    if finding not in findings_per_specimen_organ[
                            specimenOrgan]:
                        findings_per_specimen_organ[specimenOrgan].append(
                            finding)

    for specimen_organ in findings_per_specimen_organ:
        print(
            f'{specimen_organ}: {len(findings_per_specimen_organ[specimen_organ])}'
        )
        for finding in findings_per_specimen_organ[specimen_organ]:
            print('     ' + finding)
def main():
    api = KnowledgeHubAPI()
    terms = api.SemanticService().lookup('inflamm', 'HPATH')
    print(terms)
session_state = SessionState.get(compoundName="Omeprazole",
                                 compoundSmile="",
                                 similar_compounds="",
                                 compoundIds=[],
                                 compoundNames=[],
                                 studies={},
                                 df_sim=[])

api = KnowledgeHubAPI()
compoundSmile = ''
############1. Translate compound to SMILES using semantic services
compoundName = st.text_input("compound name: (e.g. Omeprazole)",
                             value=session_state.compoundName)
session_state.compoundName = compoundName
if st.button('Retrieve') and len(compoundName) > 0:
    compound = api.SemanticService().normalize(compoundName,
                                               ['RxNorm', 'smiles'])
    if 'concepts' in compound:
        for concept in compound['concepts']:
            if 'vocabularyId' in concept:
                if concept['vocabularyId'] == 'smiles':
                    # global compoundSmile
                    compoundSmile = concept['conceptCode']
                    st.text(f'Found SMILES {compoundSmile} for {compoundName}')
                    session_state.compoundSmile = compoundSmile
                    session_state.similar_compounds = []
                    session_state.compoundIds = []
                    session_state.compoundNames = []
                    session_state.studies = {}
                    session_state.df_sim = []

########2. Retrieve similar compounds
from knowledgehub.api import KnowledgeHubAPI

api = KnowledgeHubAPI(server='DEV',
                      client_secret='3db5a6d7-4694-48a4-8a2e-e9c30d78f9ab')
api.login('tester', 'tester')
socs = api.SemanticService().getSocByCode('10000060')
print(socs)