Skip to content

Commit

Permalink
more comments in bitstring-hex-encode.py
Browse files Browse the repository at this point in the history
  • Loading branch information
vancemiller committed May 1, 2015
1 parent 723deb1 commit 87f13b0
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions demo/bitstring-hex-encode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,45 @@

# reading data
store = pd.HDFStore('/data/bigchem/data/example50K-hex.h5', )

workingSet = store.select('data', start=0, stop=1000)
print workingSet.head(5)


example = workingSet.iloc[0].RDK5FPhex
print(example)



# length 256 i.e 4bit x 256 = 1024
print(len(example))



#recover original bitstring
exampleBit = bitstring.BitArray(hex=example).bin

print(exampleBit)



# calculate fingerprint
mol = Chem.MolFromSmiles("CC1C(C)C(C(CC#N)C=C)C1C")
originalBit = Chem.RDKFingerprint(mol, maxPath=5, fpSize=1024, nBitsPerHash=2).ToBitString()



# verify that they are equal
print(exampleBit == originalBit)



#example of encoding to hex
def Hexifier(smi):
return bitstring.BitArray(bin=Chem.RDKFingerprint(mol, maxPath=5, fpSize=1024).ToBitString()).hex


#run hex encoding function
print(Hexifier(mol))



#verify that hex is identical
originalhex = Hexifier(mol)
print(example == originalhex)
Expand Down

0 comments on commit 87f13b0

Please sign in to comment.