text_plain_output_1.png
from mol2vec.features import mol2alt_sentence

from rdkit import Chem

import os

import pandas as pd

import pybel

file_dir = '../input/champs-scalar-coupling/structures/'
mols_files = os.listdir(file_dir)
mols_index = dict(map(reversed, enumerate(mols_files)))
mol_name = list(mols_index.keys())

def xyz_to_smiles(fname: str) -> str:
    mol = next(pybel.readfile('xyz', fname))
    smi = mol.write(format='smi')
    return smi.split()[0].strip()

smiles = [xyz_to_smiles(file_dir + i) for i in tqdm(mol_name)]

df_smiles = pd.DataFrame({'molecule_name': mol_name, 'smiles': smiles})

sentence = mol2alt_sentence(Chem.MolFromSmiles(df_smiles.smiles[33]), 1)
print('SMILE:', df_smiles.smiles[33])
print(sentence)