def get_bond_graph_distance_one_hot( bond: RDKitBond, graph_dist_matrix: np.ndarray, allowable_set: List[int] = DEFAULT_GRAPH_DISTANCE_SET, include_unknown_set: bool = True) -> List[float]: """Get an one-hot feature of graph distance. Parameters --------- bond: rdkit.Chem.rdchem.Bond RDKit bond object graph_dist_matrix: np.ndarray The return value of `Chem.GetDistanceMatrix(mol)`. The shape is `(num_atoms, num_atoms)`. allowable_set: List[int] The graph distance types to consider. The default set is `[1, 2, ..., 7]`. include_unknown_set: bool, default False If true, the index of all types not in `allowable_set` is `len(allowable_set)`. Returns ------- List[float] A one-hot vector of the graph distance. If `include_unknown_set` is False, the length is `len(allowable_set)`. If `include_unknown_set` is True, the length is `len(allowable_set) + 1`. """ graph_dist = graph_dist_matrix[bond.GetBeginAtomIdx(), bond.GetEndAtomIdx()] return one_hot_encode(graph_dist, allowable_set, include_unknown_set)
def get_bond_is_in_same_ring_one_hot(bond: RDKitBond) -> List[float]: """Get an one-hot feature about whether atoms of a bond is in the same ring or not. Parameters --------- bond: rdkit.Chem.rdchem.Bond RDKit bond object Returns ------- List[float] A one-hot vector of whether a bond is in the same ring or not. """ return [int(bond.IsInRing())]
def get_bond_is_conjugated_one_hot(bond: RDKitBond) -> List[float]: """Get an one-hot feature about whether a bond is conjugated or not. Parameters --------- bond: rdkit.Chem.rdchem.Bond RDKit bond object Returns ------- List[float] A one-hot vector of whether a bond is conjugated or not. """ return [int(bond.GetIsConjugated())]
def get_bond_type_one_hot(bond: RDKitBond, allowable_set: List[str] = DEFAULT_BOND_TYPE_SET, include_unknown_set: bool = False) -> List[float]: """Get an one-hot feature of bond type. Parameters --------- bond: rdkit.Chem.rdchem.Bond RDKit bond object allowable_set: List[str] The bond types to consider. The default set is `["SINGLE", "DOUBLE", "TRIPLE", "AROMATIC"]`. include_unknown_set: bool, default False If true, the index of all types not in `allowable_set` is `len(allowable_set)`. Returns ------- List[float] A one-hot vector of the bond type. If `include_unknown_set` is False, the length is `len(allowable_set)`. If `include_unknown_set` is True, the length is `len(allowable_set) + 1`. """ return one_hot_encode( str(bond.GetBondType()), allowable_set, include_unknown_set)
def get_bond_stereo_one_hot(bond: RDKitBond, allowable_set: List[str] = DEFAULT_BOND_STEREO_SET, include_unknown_set: bool = True) -> List[float]: """Get an one-hot feature of the stereo configuration of a bond. Parameters --------- bond: rdkit.Chem.rdchem.Bond RDKit bond object allowable_set: List[str] The stereo configuration types to consider. The default set is `["STEREONONE", "STEREOANY", "STEREOZ", "STEREOE"]`. include_unknown_set: bool, default True If true, the index of all types not in `allowable_set` is `len(allowable_set)`. Returns ------- List[float] A one-hot vector of the stereo configuration of a bond. If `include_unknown_set` is False, the length is `len(allowable_set)`. If `include_unknown_set` is True, the length is `len(allowable_set) + 1`. """ return one_hot_encode( str(bond.GetStereo()), allowable_set, include_unknown_set)