BondCount

BondCount[mol]

gives the number of bonds in the molecule mol.

BondCount[mol,patt]

gives the number of bonds in the molecule mol matching the bond pattern patt.

Details and Options

  • Possible forms for patt include:
  • "type"a bond with a specified bond type
    Bond[{a1,a2},"type"]a bond with atoms defined by ai
    MoleculePattern[]a molecule pattern with one bond
    patt1|patt2|a bond matching any of the patti
  • The ai may be an atom index or a pattern representing an atom.
  • With the default option setting IncludeHydrogensAll, all bonds will be counted by BondCount. Use the option value "ExplicitOnly" to exclude bonds to implicit hydrogen atoms.

Examples

open allclose all

Basic Examples  (2)

Count the bonds in a molecule:

Count the number of double bonds:

Count the number of double bonds involving oxygen:

Count the number of cyclic bonds involving a nitrogen atom:

Options  (1)

IncludeHydrogens  (1)

BondCount will include all atoms by default:

Use IncludeHydrogensNone to exclude the hydrogens, which make up the majority of atoms:

This is equivalent to using a pattern excluding hydrogen atoms:

Possible Issues  (2)

Aromatic bonds are displayed visually as single or double bonds:

Asking for the number of "Double" bonds does not include aromatic bonds:

Convert the aromatic bonds to single/double using MoleculeModify before taking the count:

Because Molecule will try to fill valences with hydrogen atoms, hydrogen atoms will be included in the count even if they were not in the original molecule expression:

To exclude implicit hydrogen atoms, use:

Alternatively, to stop hydrogen atoms from appearing, use the Molecule option ValenceFillingNone:

The resulting molecule contains a single atom with unpaired electrons:

Wolfram Research (2019), BondCount, Wolfram Language function, https://reference.wolfram.com/language/ref/BondCount.html (updated 2020).

Text

Wolfram Research (2019), BondCount, Wolfram Language function, https://reference.wolfram.com/language/ref/BondCount.html (updated 2020).

CMS

Wolfram Language. 2019. "BondCount." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/BondCount.html.

APA

Wolfram Language. (2019). BondCount. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/BondCount.html

BibTeX

@misc{reference.wolfram_2024_bondcount, author="Wolfram Research", title="{BondCount}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/BondCount.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_bondcount, organization={Wolfram Research}, title={BondCount}, year={2020}, url={https://reference.wolfram.com/language/ref/BondCount.html}, note=[Accessed: 21-November-2024 ]}