Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
dipanghosh committed Aug 2, 2017
1 parent 7c82262 commit 6d895f8
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 9 deletions.
58 changes: 58 additions & 0 deletions Aggregation/simi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/env python

# usage: simi.py (similar|exact) inputfile
# input file format:
# smiles identifier
#
# Contributing authors:
# Teague Sterling, Pascal Wassam, Gurgen Turmanian and John Irwin, 2010-2013
#

import xmlrpclib, sys, pprint


def checkAggregators(smi):
result = server.similarity.getSimilars(smi)
try:
similarCount = len(result['aggregators'])

for r in result['aggregators']:
if r['similarity'] == 1.0:
exactMatch = True
exactmatchref = r['reference']
return (similarCount, exactMatch, exactmatchref)

except:
pass


lines = file(sys.argv[1]).readlines()
lookups = {}
myfile = sys.argv[2]
for l in lines:
t = l.split(',')
smi = t[1]
id = t[0]
activity = t[2]
if len(id) == 0: id = None
lookups[id] = smi


server_url = "http://advisor.bkslab.org:8080/aggregate_lookup/xml-rpc/"
server = xmlrpclib.ServerProxy(server_url);
similarCount = 0
exactMatch = False
outfile = open(myfile, 'w')
outfile.write('ID, Activity, No. of matches,Exact match, Ref for exact match')
for (id, smi) in lookups.iteritems():
try:
checkResult = checkAggregators(smi)
try:
outfile.write(id+","+activity+","+",".join(str(x) for x in checkResult)+"\n")
print id, checkResult
except:
outfile.write(id+ ","+ activity +","+ "None"+"\n")
print id, checkResult
except:
pass
outfile.close()
27 changes: 27 additions & 0 deletions accuAnalysis/combine.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from dipan_utilities import utilities
import getUnique as gt
import exportOverlaps as ex

overlaps13 = ex.exportOverlaps(0, 2)
overlaps23 = ex.exportOverlaps(1, 2)
overlaps12 = ex.exportOverlaps(0, 1)
desktopDir = '/Users/dghosh/Desktop/'

#Accounting for all the molecules showing class changing
switchersForset1 = utilities.extractList(overlaps13[0], gt.set3dict)
switchersForset2 = utilities.extractList(overlaps23[0], gt.set3dict)
switchersForset2and1 = utilities.extractList(overlaps12[0], gt.set2dict)
switchersForset2and1From1 = utilities.extractList(overlaps12[0], gt.set1dict)

print len(switchersForset2and1From1)

set3list = utilities.extractList(gt.set3idSet, gt.set3dict)
uniqFromSet1 = utilities.extractList(gt.uniq1to3, gt.set1dict)
uniqFromSet2 = utilities.extractList(gt.uniq2to3, gt.set2dict)

combined = set.union(set(set3list), set(uniqFromSet1), set(uniqFromSet2))


combinedExcludeSwitching =(set(switchersForset1)|set(switchersForset2)|set(switchersForset2and1)|set(switchersForset2and1From1))
print len(combinedExcludeSwitching)
utilities.listToFile(desktopDir+'toExclude.txt', combinedExcludeSwitching)
6 changes: 4 additions & 2 deletions accuAnalysis/determine_expt_inacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ def calculateBalAccforSets(i, j):
activeinCommon = float(intersectionByIndex(i, j, givefullset=False))
totalinCommon = float(intersectionByIndex(i, j, givefullset=True))
inactiveinCommon = totalinCommon - activeinCommon
balAcc = 0.5 * ((switched[0] / activeinCommon) + switched[1] / inactiveinCommon)
return balAcc
TP = activeinCommon - switched[0]
TN = inactiveinCommon - switched[1]
balAcc = 0.5 * ((TP / (TP + switched[0])) + (TN/ (TN + switched[1])))
print balAcc


if __name__ == '__main__':
Expand Down
11 changes: 6 additions & 5 deletions accuAnalysis/exportoverlap_implement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import loadfiles as ld
from dipan_utilities import utilities

overlaps = ex.exportOverlaps(1, 2)
switchFile = open(ld.desktopDir + 'set2to3SwitchedMID.csv', 'w')
notSwitchFile = open(ld.desktopDir + 'set2to3NotSwitchedMID.csv', 'w')
utilities.pullFromDictAndWriteToFIle(ld.set2dict, overlaps[0], switchFile)
utilities.pullFromDictAndWriteToFIle(ld.set2dict, overlaps[1], notSwitchFile)
overlaps12 = ex.exportOverlaps(0, 1)
switchFile = open(ld.desktopDir + 'set1to2Switched.csv', 'w')
NotswitchFile = open(ld.desktopDir + 'set1to2NotSwitched.csv', 'w')
utilities.pullFromDictAndWriteToFIle(ld.set2dict, overlaps12[0], switchFile)
utilities.pullFromDictAndWriteToFIle(ld.set2dict, overlaps12[1], NotswitchFile)

13 changes: 13 additions & 0 deletions accuAnalysis/fishOut.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import loadfiles as ld
from dipan_utilities import utilities

with open('/Users/dghosh/Desktop/set3_aggregators') as f:
set3Aggre = f.read().splitlines()
with open('/Users/dghosh/Desktop/set3-nonAggregators') as f:
set3NonAggre = f.read().splitlines()

switchFile = open(ld.desktopDir + 'set3AggreRID.csv', 'w')
notSwitchFile = open(ld.desktopDir + 'set3nonAggreRID.csv', 'w')

utilities.pullFromDictAndWriteToFIle(ld.set3dict, set3Aggre, switchFile)
utilities.pullFromDictAndWriteToFIle(ld.set3dict, set3NonAggre, notSwitchFile)
2 changes: 2 additions & 0 deletions accuAnalysis/getUnique.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
uniq1to3 = set1idSet - set3idSet
uniq2to1 = set2idSet - set1idSet
uniq3to1 = set3idSet - set1idSet
uniq2to3 = set2idSet - set3idSet
uniq3to2 = set3idSet - set2idSet

def extractList(idlist, mydict):
mylist = []
Expand Down
13 changes: 11 additions & 2 deletions dipan_utilities/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ def csvToDict(filename):
reader = csv.reader(open(filename, 'r'))
dict = {}
for row in reader:
_, v, k = row
v, _, k = row
dict[k] = v
return dict

Expand All @@ -18,4 +18,13 @@ def pullFromDictAndWriteToFIle(yourDict, yourSet, yourFile):
try:
yourFile.write(yourDict[id] + '\n')
except:
pass
pass

def extractList(idlist, mydict):
mylist = []
for id in idlist:
try:
mylist.append(mydict[id])
except KeyError:
print id + " Key does not exist here!"
return mylist
10 changes: 10 additions & 0 deletions learning/fizzbuzz.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
for i in range(100):
if i%3 == 0:
if i%5==0:
print 'fizzbuzz'
else:
print 'fizz'
elif i%5 == 0:
print 'buzz'
else:
print i
11 changes: 11 additions & 0 deletions writegridCode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'''
Created on 13 Mar 2017
@author: dghosh
'''
import os
dirName = "/Users/dghosh/Creative Cloud Files/portfolio_site/rome/Rome-web/day1"
os.chdir(dirName)
for filename in os.listdir("."):
basename = filename[:-8]
print '<a href="./'+dirName.split("/")[-1]+'/'+basename+'-web.jpg" data-toggle="lightbox" data-gallery="christmasmarket"><figure class="photothumbnail"><img src="./'+dirName.split("/")[-1]+'/thumb/'+basename+'-web-thumb.jpg" alt="'+filename+'" class="center-block"></figure></a>'

0 comments on commit 6d895f8

Please sign in to comment.