Skip to content

Commit

Permalink
addet missing method getTargets to DB_connector-class
Browse files Browse the repository at this point in the history
	modified:   tools/db_connector.py
  • Loading branch information
wolfguidobolick committed Oct 18, 2016
1 parent 0c774b9 commit f2c9730
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ocean/tools/db_connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,29 @@ def execute(self,query):
names = [x[0] for x in self.cursor.description]
return names,data

def getTargets(self):
if self.db_type == 'postgre':
query = "select target_chembl_id,pa.cs from (select target_chembl_id,count(molregno) cs from %s group by target_chembl_id) as pa where cs>%d" % (
ocean.settings.OCEAN_DB_TABLE, ocean.settings.CMPD_COUNT_CUTOFF - 1)
else:
if self.filter:
if self.filter == "parallel":
query = "select target_chembl_id,cs from (select /*+ PARALLEL({0},4) */ target_chembl_id,count(molregno) cs from {0} group by target_chembl_id) where cs>{1}".format(
ocean.settings.OCEAN_DB_TABLE, ocean.settings.CMPD_COUNT_CUTOFF - 1)
else:
query = "select distinct target_chembl_id from %s where %s" % (
ocean.settings.OCEAN_DB_TABLE, self.filter)

else:
query = "select min(target_chembl_id) from %s group by target_chembl_id" % ocean.settings.OCEAN_DB_TABLE

final_query = query
print "query is", final_query
self.cursor.execute(final_query)

result = [t[0] for t in self.cursor.__iter__()]
return result

if os.path.exists('ocean/tools/custom_db_connector.py'):
import custom_db_connector
cdc = {k:v for k,v in custom_db_connector.__dict__.items() if not k.startswith('__')}
Expand Down

0 comments on commit f2c9730

Please sign in to comment.