Demo entry 6353107

1

   

Submitted by anonymous on Mar 29, 2017 at 11:18
Language: Python. Code size: 703 Bytes.

import pybel
def cal2d_and_write(sdfpath,databasepath,fp1,simtype,threshold=1000):
        a=[]
        resultpath = os.path.split(sdfpath)[0]+'/result.txt'
        with open(databasepath) as f:
                for i,j in parse_lines(f):
                        mol = pybel.readstring('sdf',i)
                        fp2=mol.calcfp(fptype = simtype)
                        sim2d = round(fp2|fp1,3)
                        name = mol.title
                        a.append({'name':name,'sim2d':sim2d})
                amax = sorted(a,key=lambda s:s['sim2d'],reverse=True)
                threshold = min(len(amax),threshold)
                write_data('sim2d',amax[0:threshold],resultpath)

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).