Comments (2)
Hi, thanks for your interest! As you mentioned, we don't support other formats yet. But, we plan to add them in the close future.
Yes, you can override the rdkit molecule. Here is the workaround:
- Let's say you can create a rdkit molecule with associated conformation. I am making one here:
>>> from chemml.chem import Molecule
>>> m1 = Molecule('O', 'smiles') # water molecule
>>> m1.to_xyz(optimizer='UFF') # embed and optimize the 3D geometry
This molecule gives you an rdkit molecule:
>>> m1.rdkit_molecule
<rdkit.Chem.rdchem.Mol at 0x13b4b7d00>
>>> m1.xyz.geometry
array([[-6.62167743e-04, 4.04121065e-01, 0.00000000e+00], [-7.82704434e-01, -2.03343606e-01, 0.00000000e+00], [ 7.83366601e-01, -2.00777459e-01, 0.00000000e+00]])
- Based on what you described, you only have rdkit objects. Now, I want to create a new chemml molecule using that rdkit molecule only. You first need to instantiate the Molecule class using dummy info:
>>> m2 = Molecule('C', 'smiles')
Please note that if you try to create the xyz geometry with no optimization, the following error raises:
>>> m2.to_xyz(optimizer=None)
ValueError: The conformation has not been built yet (maybe due to the 2D representation of the creator). You should set the optimizer value if you wish to embed and optimize the 3D geometry.
Now, we replace its rdkit_molecule with the water molecule from the first step:
>>> m2.rdkit_molecule = m1.rdkit_molecule # any rdkit.Chem.rdchem.Mol object
when you try to build the geometry with no optimizer, it gets the available conformation from your rdkit molecule:
>>> m2.to_xyz(optimizer=None)
>>> m2.xyz.geometry
array([[-6.62167743e-04, 4.04121065e-01, 0.00000000e+00], [-7.82704434e-01, -2.03343606e-01, 0.00000000e+00], [ 7.83366601e-01, -2.00777459e-01, 0.00000000e+00]])
>>> m2
<chemml.chem.Molecule(
rdkit_molecule : <rdkit.Chem.rdchem.Mol object at 0x13b5cdda0>,
pybel_molecule : None,
creator : ('SMILES', 'C'),
smiles : 'C',
smarts : None,
inchi : None,
xyz : <XYZ(geometry: (3, 3), atomic_numbers: (3, 1), atomic_symbols: (3, 1))>)>
You can also get the correct SMILES if you need:
>>> m2.to_smiles()
>>> m2
<chemml.chem.Molecule(
rdkit_molecule : <rdkit.Chem.rdchem.Mol object at 0x13b5cdda0>,
pybel_molecule : None,
creator : ('SMILES', 'C'),
smiles : '[H]O[H]',
smarts : None,
inchi : None,
xyz : <XYZ(geometry: (3, 3), atomic_numbers: (3, 1), atomic_symbols: (3, 1))>)>
No worries about the creator, this is just the initial creator and as far as I remember doesn't make any issue.
Please let me know if you have any other questions. Thanks!
from chemml.
Thanks, it worked like a charm!
from chemml.
Related Issues (11)
- Wrong import of pybel HOT 1
- select the test set for the Active Learning manually HOT 2
- can we save a trained active learning model? HOT 1
- GeneticAlgorithm function fitness argument does not check number of inputs
- TypeError when loading dataset
- Z-Score
- Dependency Issue in Installation
- from chemml import wrapperRUN HOT 1
- Can't find pybel despyte it being installed and working HOT 2
- chemML cant read XYZ format as string HOT 1
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 chemml.