Example #1
0
def getAtomFeatures(a: Chem.rdchem.Atom):
    return [
        # a.GetIdx(),
        a.GetAtomicNum(),
        a.GetTotalValence(),
        a.GetFormalCharge(),
        a.GetDegree(),
        a.GetTotalDegree() - a.GetDegree(),
        a.GetNumRadicalElectrons(),
        int(a.GetIsAromatic()),
        a.GetMass(),
        Chem.GetPeriodicTable().GetRvdw(a.GetAtomicNum())
    ]
Example #2
0
def get_atom_features(atom:Chem.rdchem.Atom) -> np.ndarray:
    "Concats all atom features together and returns numpy array of bools"
    
    # elements from Duvenaud's original code. Note the absense of H(optional)
    potential_atoms_list = ['C', 'N', 'O', 'S', 'F', 'Si', 'P', 'Cl', 'Br',
                            'Mg', 'Na', 'Ca', 'Fe', 'As', 'Al', 'I', 'B', 'V',
                            'K', 'Tl', 'Yb', 'Sb', 'Sn', 'Ag', 'Pd', 'Co', 'Se',
                            'Ti', 'Zn', 'H', 'Li', 'Ge', 'Cu', 'Au', 'Ni', 'Cd',
                            'In', 'Mn', 'Zr', 'Cr', 'Pt', 'Hg', 'Pb', 'Unknown']
    
    encoded_element_list = one_of_k(atom.GetSymbol(), potential_atoms_list)
    encoded_degree_list = one_of_k(atom.GetDegree(), [0, 1, 2, 3, 4, 5]) 
    encoded_num_hs_list = one_of_k(atom.GetTotalNumHs(), [0, 1, 2, 3, 4])
    encoded_fc_list = one_of_k(atom.GetFormalCharge(), [-1,-2,1,2,0])
    encoded_implicit_valence_list = one_of_k(atom.GetImplicitValence(),
                                             [0, 1, 2, 3, 4, 5])
    
    feature_vector = np.array(encoded_element_list + encoded_degree_list + 
                      encoded_num_hs_list + encoded_implicit_valence_list +
                      encoded_fc_list + [atom.GetIsAromatic()])
    
    return feature_vector