Comments (2)
If you want similarities between compounds in an SDF file, I would recommend generating fingerprints and calculating similarities locally using RDKit (or OpenBabel, CDK, etc.). Something like:
mols = Chem.SDMolSupplier('myfile.sdf')
fp1 = AllChem.GetMorganFingerprint(mols[0], 2)
fp2 = AllChem.GetMorganFingerprint(mols[1], 2)
DataStructs.TanimotoSimilarity(fp1, fp2)
But if you specifically want to use PubChem fingerprints you can do something like this with PubChemPy:
def tanimoto(compound1, compound2):
fp1 = int(compound1.fingerprint, 16)
fp2 = int(compound2.fingerprint, 16)
fp1_count = bin(fp1).count('1')
fp2_count = bin(fp2).count('1')
both_count = bin(fp1 & fp2).count('1')
return float(both_count) / (fp1_count + fp2_count - both_count)
I added a more complete example here: https://github.com/mcs07/PubChemPy/blob/master/examples/Chemical%20fingerprints%20and%20similarity.ipynb
from pubchempy.
Great !
Yes, I also use RDKit. In this part, I only want to get the PubChem similarities.
Now I see, by compound.fingerprint in your package, I can not only get the similarities, but also the PubChem fingerprints ~
Thanks a lot !
Songpeng
from pubchempy.
Related Issues (20)
- pubchempy missing results available on the pubchem web page HOT 2
- Using the search bar
- Errors in the encoding of some bits HOT 1
- Is it possible to calculate the PMI of the compounds?
- Is it possible to get 3D coordinates of ligand using CID or SID? HOT 1
- Is it possible to list the position of each functional group (atom number of key atom) in iupac name?
- obtaining compounds by property
- Timeout
- obtaining CCS values
- Assay.from_aid().to_dict() fails for multiple AIDs
- Minor python syntax problem
- Obtaining hazard classes and categories
- Certain compounds cannot be retrieved by name anymore
- Can not generate SMILES of compounds from known CAS numbers HOT 4
- Neither NAMES nor CAS hyphened numbers, verified on PubChem, seem to retrieve many compounds' SMILES
- Get compounds function is too slow HOT 9
- Ask for help about how to find Pubchem CID of many compounds by CAS numbers HOT 3
- Inconsistencies in Isomeric SMILES Data Retrieval Using PubChemPy Compared to Previous Data
- Questions about "Chemical and Physical Properties"
- SSLCertVerificationError while running the simplest of PubChemPy examples
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pubchempy.