Closed cjgalvin closed 1 year ago
Hi, thanks for the clear description!
includeHeader=False
in your SmilesWriter
. An example is shown below:
from rdkit import Chem
from rdkit.Chem import SmilesWriter
mols.append(Chem.MolFromSmiles("CC")) mols.append(Chem.MolFromSmiles("NCC"))
with SmilesWriter("mols_no_header.smi", includeHeader=False) as f: for m in mols: f.write(m)
There are many ways to write a smi file due to its simple format. I usually treat it as a text file and write it with Python line by line, where each line is a SMILES + space + ID.
2. Thanks for the proposal. I could definitely improve it in the future :)
Thank you for providing the SmilesWriter solution. I will use that as it solves the exact problem I described. Thank you!
In order to create a
.smi
file, I used RDKit's PandasTools features. This was the first search result for me when searching "rdkit create smi file". The SaveSMILESfromFrame does exactly what it says, but it includes a header row with 'SMILES' and 'ID'.When I subsequently tried to run Auto3D on the .smi file, it got the following error:
Deleting the header row led to a successful run of Auto3D.
However, if I try to create a pipeline where I first load a CSV of SMILES and other data into a dataframe, then create a temporary .smi file to use with Auto3D, I'm going to run into this problem every time.
It does not appear that RDKit has an option to not include the header. Since that is also the first search result, I suspect several users may try to use the same approach I did.
So I have two questions: 1) Is there some other preferred way to generate the .smi file that avoids this issue? I suspect the developers did not have this issue, otherwise there would be a header row check. 2) As a solution, does it make sense to add a header row check from the point in the link below? https://github.com/isayevlab/Auto3D_pkg/blob/f463e4fd072d3e219b709cfb2b127146db05339c/src/Auto3D/utils.py#L93