clustering.py
def computeLigandSimilarity(target_names, fname):
    '''Read target (first col) and ligand (third col) from fname. 
    Return ligand similarity matrix indexed according to target_names'''
    fingerprints = dict()
    for line in open(fname):
        vals = line.split()
        targ = vals[0]
        ligfile = vals[2]
        smi = open(ligfile).readline().split()[0]
        mol = AllChem.MolFromSmiles(smi)
        if mol == None:
            mol = AllChem.MolFromSmiles(smi,sanitize=False)
        fp = FingerprintMols.FingerprintMol(mol)
        fingerprints[targ] = fp
    n = len(target_names)
    sims = np.zeros((n,n))
    for i in range(n):
        for j in range(i+1):
            fpi = fingerprints[target_names[i]]
            fpj = fingerprints[target_names[j]]
            sim = fs(fpi,fpj)
            sims[i,j] = sims[j,i] = sim
    return sims
Read target (first col) and ligand (third col) from fname. 
    Return ligand similarity matrix indexed according to target_names
Read target (first col) and ligand (third col) from fname.
Return ligand similarity matrix indexed according to target_names
Read target ( first col ) and ligand ( third col ) from fname . Return ligand similarity matrix indexed according to target_names
def computeLigandSimilarity(target_names, fname):
    fingerprints = dict()
    for line in open(fname):
        vals = line.split()
        targ = vals[0]
        ligfile = vals[2]
        smi = open(ligfile).readline().split()[0]
        mol = AllChem.MolFromSmiles(smi)
        if mol == None:
            mol = AllChem.MolFromSmiles(smi,sanitize=False)
        fp = FingerprintMols.FingerprintMol(mol)
        fingerprints[targ] = fp
    n = len(target_names)
    sims = np.zeros((n,n))
    for i in range(n):
        for j in range(i+1):
            fpi = fingerprints[target_names[i]]
            fpj = fingerprints[target_names[j]]
            sim = fs(fpi,fpj)
            sims[i,j] = sims[j,i] = sim
    return sims
def computeLigandSimilarity ( target_names , fname ) : fingerprints = dict ( ) for line in open ( fname ) : vals = line . split ( ) targ = vals [ 0 ] ligfile = vals [ 2 ] smi = open ( ligfile ) . readline ( ) . split ( ) [ 0 ] mol = AllChem . MolFromSmiles ( smi ) if mol == None : mol = AllChem . MolFromSmiles ( smi , sanitize = False ) fp = FingerprintMols . FingerprintMol ( mol ) fingerprints [ targ ] = fp n = len ( target_names ) sims = np . zeros ( ( n , n ) ) for i in range ( n ) : for j in range ( i + 1 ) : fpi = fingerprints [ target_names [ i ] ] fpj = fingerprints [ target_names [ j ] ] sim = fs ( fpi , fpj ) sims [ i , j ] = sims [ j , i ] = sim return sims
Read target (first col) and ligand (third col) from fname.
Read target ( first col ) and ligand ( third col ) from fname .
'''Read target (first col) and ligand (third col) from fname. 
    Return ligand similarity matrix indexed according to target_names'''
target_names
fname