(mol, radius)
return list(identifier_sentences), list(alternating_sentence)
Calculates ECFP (Morgan fingerprint) and returns identifiers of substructures as 'sentence' (string).
    Returns a tuple with 1) a list with sentence for each radius and 2) a sentence with identifiers from all radii
    combined.
    NOTE: Words are ALWAYS reordered according to atom order in the input mol object.
    NOTE: Due to the way how Morgan FPs are generated, number of identifiers at each radius is smaller
    
    Parameters
    ----------
    mol : rdkit.Chem.rdchem.Mol
    radius : float 
        Fingerprint radius

    Returns
    -------
    identifier sentence
        List with sentences for each radius
    alternating sentence
        Sentence (list) with identifiers from all radii combined
Calculates ECFP (Morgan fingerprint) and returns identifiers of substructures as 'sentence' (string).
    Returns a tuple with 1) a list with sentence for each radius and 2) a sentence with identifiers from all radii
    combined.
    NOTE: Words are ALWAYS reordered according to atom order in the input mol object.
    NOTE: Due to the way how Morgan FPs are generated, number of identifiers at each radius is smaller
    
    Parameters
    ----------
    mol : rdkit.Chem.rdchem.Mol
    radius : float 
        Fingerprint radius
Calculates ECFP ( Morgan fingerprint ) and returns identifiers of substructures as sentence ( string ) . Returns a tuple with 1 ) a list with sentence for each radius and 2 ) a sentence with identifiers from all radii combined . NOTE : Words are ALWAYS reordered according to atom order in the input mol object . NOTE : Due to the way how Morgan FPs are generated number of identifiers at each radius is smaller Parameters ---------- mol : rdkit . Chem . rdchem . Mol radius : float Fingerprint radius
def mol2sentence(mol, radius):

    """Calculates ECFP (Morgan fingerprint) and returns identifiers of substructures as 'sentence' (string).
    Returns a tuple with 1) a list with sentence for each radius and 2) a sentence with identifiers from all radii
    combined.
    NOTE: Words are ALWAYS reordered according to atom order in the input mol object.
    NOTE: Due to the way how Morgan FPs are generated, number of identifiers at each radius is smaller
    
    Parameters
    ----------
    mol : rdkit.Chem.rdchem.Mol
    radius : float 
        Fingerprint radius

    Returns
    -------
    identifier sentence
        List with sentences for each radius
    alternating sentence
        Sentence (list) with identifiers from all radii combined
    """
    radii = list(range(int(radius) + 1))
    info = {}
    _ = AllChem.GetMorganFingerprint(mol, radius, bitInfo=info)  # info: dictionary identifier, atom_idx, radius

    mol_atoms = [a.GetIdx() for a in mol.GetAtoms()]
    dict_atoms = {x: {r: None for r in radii} for x in mol_atoms}

    for element in info:
        for atom_idx, radius_at in info[element]:
            dict_atoms[atom_idx][radius_at] = element  # {atom number: {fp radius: identifier}}

    # iterate over all atoms and radii
    identifier_sentences = []
    
    for r in radii:  # iterate over radii to get one sentence per radius
        identifiers = []
        for atom in dict_atoms:  # iterate over atoms
            # get one sentence per radius
            identifiers.append(dict_atoms[atom][r])
        identifier_sentences.append(list(map(str, [x for x in identifiers if x])))
    
    # merge identifiers alternating radius to sentence: atom 0 radius0, atom 0 radius 1, etc.
    identifiers_alt = []
    for atom in dict_atoms:  # iterate over atoms
        for r in radii:  # iterate over radii
            identifiers_alt.append(dict_atoms[atom][r])

    alternating_sentence = map(str, [x for x in identifiers_alt if x])

    return list(identifier_sentences), list(alternating_sentence)
def mol2sentence ( mol , radius ) : radii = list ( range ( int ( radius ) + 1 ) ) info = { } _ = AllChem . GetMorganFingerprint ( mol , radius , bitInfo = info ) # info: dictionary identifier, atom_idx, radius mol_atoms = [ a . GetIdx ( ) for a in mol . GetAtoms ( ) ] dict_atoms = { x : { r : None for r in radii } for x in mol_atoms } for element in info : for atom_idx , radius_at in info [ element ] : dict_atoms [ atom_idx ] [ radius_at ] = element # {atom number: {fp radius: identifier}} # iterate over all atoms and radii identifier_sentences = [ ] for r in radii : # iterate over radii to get one sentence per radius identifiers = [ ] for atom in dict_atoms : # iterate over atoms # get one sentence per radius identifiers . append ( dict_atoms [ atom ] [ r ] ) identifier_sentences . append ( list ( map ( str , [ x for x in identifiers if x ] ) ) ) # merge identifiers alternating radius to sentence: atom 0 radius0, atom 0 radius 1, etc. identifiers_alt = [ ] for atom in dict_atoms : # iterate over atoms for r in radii : # iterate over radii identifiers_alt . append ( dict_atoms [ atom ] [ r ] ) alternating_sentence = map ( str , [ x for x in identifiers_alt if x ] ) return list ( identifier_sentences ) , list ( alternating_sentence )