예제 #1
0
def getBondFeatures(b: Chem.rdchem.Bond):
    return [
        b.GetBeginAtomIdx(),
        b.GetEndAtomIdx(),
        b.GetBondTypeAsDouble(),
        int(b.GetIsAromatic()),
        int(b.GetIsConjugated())
    ]
예제 #2
0
def bond_features(bond: Chem.rdchem.Bond) -> List[Union[bool, int, float]]:
    """
    Builds a feature vector for a bond.

    :param bond: A RDKit bond.
    :return: A list containing the bond features.
    """
    if bond is None:
        fbond = [1] + [0] * (BOND_FDIM - 1)
    else:
        bt = bond.GetBondType()
        fbond = [
            0,  # bond is not None
            # bt == Chem.rdchem.BondType.SINGLE,
            # bt == Chem.rdchem.BondType.DOUBLE,
            # bt == Chem.rdchem.BondType.TRIPLE,
            # bt == Chem.rdchem.BondType.AROMATIC,
            (bond.GetIsConjugated() if bt is not None else 0),
            (bond.IsInRing() if bt is not None else 0)
        ]
        fbond += [1 if bond.GetIsAromatic() else 0]
        fbond += onek_encoding_unk(int(bond.GetStereo()), list(range(6)))
        # fbond += bond_in_member_rings(bond)
    return fbond