In [1]:
import rdkit
import pandas as pd
import numpy as np
from scipy.stats.stats import pearsonr 
from sklearn import linear_model
from heapq import nlargest
from rdkit import Chem

In [2]:
fileName = "train.csv"
start = 650000
end = 700000
train = pd.read_csv(fileName,nrows=end)

In [3]:
train = train[start:]
print len(train.smiles)


50000

In [4]:
from rdkit.Chem import AllChem
m = Chem.MolFromSmiles(train.smiles[start])
x1 = AllChem.GetMorganFingerprintAsBitVect(m, 1, nBits=512, useFeatures=True)
x2= AllChem.GetMorganFingerprintAsBitVect(m, 2, nBits=512, useFeatures=True)
x3 = AllChem.GetMorganFingerprintAsBitVect(m, 3, nBits=1024, useFeatures=True)
x4 = AllChem.GetHashedAtomPairFingerprintAsBitVect(m, nBits=256)
x5 = AllChem.GetHashedTopologicalTorsionFingerprintAsBitVect(m , nBits=256)
new_row = x1 + x2 + x3 + x4 + x5
features = new_row

In [5]:
for i in range(start+1,end):
    if(i %10000 == 0):
        print i
    m = Chem.MolFromSmiles(train.smiles[i])
    x1 = AllChem.GetMorganFingerprintAsBitVect(m, 1, nBits=512, useFeatures=True)
    x2= AllChem.GetMorganFingerprintAsBitVect(m, 2, nBits=512, useFeatures=True)
    x3 = AllChem.GetMorganFingerprintAsBitVect(m, 3, nBits=1024, useFeatures=True)
    x4 = AllChem.GetHashedAtomPairFingerprintAsBitVect(m, nBits=256)
    x5 = AllChem.GetHashedTopologicalTorsionFingerprintAsBitVect(m , nBits=256)
    new_row = x1 + x2 + x3 + x4 + x5
    features = features + new_row


660000
670000
680000
690000

In [8]:
len(features)


Out[8]:
128000000

In [9]:
new_feats = np.array(features)

In [10]:
new_feats = new_feats.reshape(end-start,2560)

In [11]:
new_feats.shape


Out[11]:
(50000, 2560)

In [12]:
a = pd.DataFrame(new_feats)

In [13]:
a.to_csv("train"  + str(start))

In [ ]:
v = r_[0.:10.]

In [ ]:
v

In [ ]: