def GOQLtoFindDrugs(TargetIds: list, TargetType='Protein', drugEffect=['negative']): if TargetType == 'Protein': return OQL.get_drugs(for_targets_with_ids=TargetIds) elif TargetType == 'Small Molecule': REL_TYPES = ['Regulation', 'MolSynthesis'] OQLquery = OQL.expand_entity(PropertyValues=TargetIds, SearchByProperties=['id'], expand_by_rel_types=REL_TYPES, expand2neighbors=['Small Molecule'], direction='upstream') OQLquery += ' AND Effect = (' + ','.join(drugEffect) + ')' return OQLquery else: REL_TYPES = ['Regulation'] OQLquery = OQL.expand_entity(PropertyValues=TargetIds, SearchByProperties=['id'], expand_by_rel_types=REL_TYPES, expand2neighbors=['Small Molecule'], direction='upstream') OQLquery += ' AND Effect = (' + ','.join(drugEffect) + ')' return OQLquery
IdToNames = ps_api.Graph.get_properties(PPIids, 'Name') sorted_centrality_byName = list() for t in sorted_centrality: idx = t[0] # if idx in IdToNames.keys(): name = IdToNames[idx][0] sorted_centrality_byName.append((name, t[1])) print(sorted_centrality_byName) DiseaseProteins = set(ps_api.Graph.get_entity_ids(['Protein'])) print("Finding Drugs for Proteins containing GeneticVariants linked to %s" % InputDiseaseNames) ps_api.add_dump_file(foutDrugsForDiseaseProteins, replace_main_dump=True) start_time = time.time() ps_api.process_oql(GOQL.get_drugs(for_targets_with_ids=list(DiseaseProteins)), flush_dump=True) DrugCount = set([ x for x, y in ps_api.Graph.nodes(data=True) if ((ps_api.Graph.out_degree(x) > 0) & (y['ObjTypeName'][0] in ['Small Molecule', 'SmallMol'])) ]) FoundTargets = set([ x for x, y in ps_api.Graph.nodes(data=True) if ((ps_api.Graph.in_degree(x) > 1) & (y['ObjTypeName'][0] in ['Protein'])) ]) execution_time = ps_api.execution_time(start_time) print("%d drugs for %d proteins linked to %s were retrieved in %s ---" % (len(DrugCount), len(FoundTargets), InputDiseaseNames, execution_time)) # find RMC compounds for non-druggable targets