(node_list, adjacency_matrix, remap=None)
return smiles, mol
Converts molecular graph to SMILES string
    :param node_list:
    :param adjacency_matrix:
    :param remap: edge inverse relabel map
    :return:
Converts molecular graph to SMILES string
    :param node_list:
    :param adjacency_matrix:
    :param remap: edge inverse relabel map
    :return:
Converts molecular graph to SMILES string : param node_list : : param adjacency_matrix : : param remap : edge inverse relabel map : return :
def SmilesFromGraphs(node_list, adjacency_matrix, remap=None):
    """
    Converts molecular graph to SMILES string
    :param node_list:
    :param adjacency_matrix:
    :param remap: edge inverse relabel map
    :return:
    """
    # create empty editable mol object
    mol = Chem.RWMol()

    # add atoms to mol and keep track of index
    node_to_idx = {}
    for i in range(len(node_list)):
        a = Chem.Atom(node_list[i])
        molIdx = mol.AddAtom(a)
        node_to_idx[i] = molIdx

    # add bonds between adjacent atoms
    xx, yy = np.where(np.triu(adjacency_matrix, k=1))
    vv = adjacency_matrix[xx, yy]
    for ix, iy, bond in zip(xx, yy, vv):
        # add relevant bond type (there are many more of these)
        if remap is not None:
            bond = remap[bond]
        if bond == 1.:
            bond_type = Chem.rdchem.BondType.SINGLE
            mol.AddBond(node_to_idx[ix], node_to_idx[iy], bond_type)
        elif bond == 1.5:
            bond_type = Chem.rdchem.BondType.AROMATIC
            mol.AddBond(node_to_idx[ix], node_to_idx[iy], bond_type)
        elif bond == 2.:
            bond_type = Chem.rdchem.BondType.DOUBLE
            mol.AddBond(node_to_idx[ix], node_to_idx[iy], bond_type)
        elif bond == 3.:
            bond_type = Chem.rdchem.BondType.TRIPLE
            mol.AddBond(node_to_idx[ix], node_to_idx[iy], bond_type)
        else:
            raise ValueError("Invalid bond type in matrix")

    # Convert RWMol to Mol object
    mol = mol.GetMol()
    #Chem.Kekulize(mol)

    # Convert RWMol to SMILES
    smiles = Chem.MolToSmiles(mol, kekuleSmiles=True)

    return smiles, mol
def SmilesFromGraphs ( node_list , adjacency_matrix , remap = None ) : # create empty editable mol object mol = Chem . RWMol ( ) # add atoms to mol and keep track of index node_to_idx = { } for i in range ( len ( node_list ) ) : a = Chem . Atom ( node_list [ i ] ) molIdx = mol . AddAtom ( a ) node_to_idx [ i ] = molIdx # add bonds between adjacent atoms xx , yy = np . where ( np . triu ( adjacency_matrix , k = 1 ) ) vv = adjacency_matrix [ xx , yy ] for ix , iy , bond in zip ( xx , yy , vv ) : # add relevant bond type (there are many more of these) if remap is not None : bond = remap [ bond ] if bond == 1. : bond_type = Chem . rdchem . BondType . SINGLE mol . AddBond ( node_to_idx [ ix ] , node_to_idx [ iy ] , bond_type ) elif bond == 1.5 : bond_type = Chem . rdchem . BondType . AROMATIC mol . AddBond ( node_to_idx [ ix ] , node_to_idx [ iy ] , bond_type ) elif bond == 2. : bond_type = Chem . rdchem . BondType . DOUBLE mol . AddBond ( node_to_idx [ ix ] , node_to_idx [ iy ] , bond_type ) elif bond == 3. : bond_type = Chem . rdchem . BondType . TRIPLE mol . AddBond ( node_to_idx [ ix ] , node_to_idx [ iy ] , bond_type ) else : raise ValueError ( "Invalid bond type in matrix" ) # Convert RWMol to Mol object mol = mol . GetMol ( ) #Chem.Kekulize(mol) # Convert RWMol to SMILES smiles = Chem . MolToSmiles ( mol , kekuleSmiles = True ) return smiles , mol