Functional groups are, simply put, the portions of molecules that react with other molecules. There are a number of functional groups (some common ones seen below), and a single molecule may contain any number or assortment of them. The precise configuration of these functional groups will give a compound its chemical properties.
Take, for example, the naturally-occurring neurotransmitter, tryptamine. Central to its pharmacological properties are three functional groups:
an arene group, composed of six carbon atoms arranged in a planar (flat) ring
a primary amine, a nitrogen bound to two hydrogen atoms
a secondary amine, a nitrogen bound to one hydrogen atom
These groups compose tryptamine’s pharmacophore, the part of the structure that is responsible for its pharmacological effects. The same basic pharmacophore can be seen in the hallucinogenic tryptamine analogues, dimethyltryptamine (DMT) and psilocin (4-HO-DMT).
In the case of DMT, two methyl groups are attached to the primary amine in tryptamine - methyl groups are composed of a single carbon atom saturated with hydrogen atoms. The nitrogen in this case becomes a tertiary amine, one bound to no hydrogens.
Psilocin, the psychoactive metabolite of psilocybin, is simply a DMT molecule with the addition of an oxygen and hydrogen - a hydroxy group - to the the 4th carbon of the benzene ring. Making the molecule bulkier in this way contributes to the difference in effects of psilocin versus DMT.
LSD may not at first appear similar to the tryptamines above - to be sure, it possesses a few additional features that the tryptamines lack. However, upon closer inspection, the very same tryptamine pharmacophore can be identified in LSD’s molecular structure (two amines and a benzene ring). This helps to explain why LSD’s effects are so similar to other psychedelics: the basic chemical structure is the same.
Also present on the LSD molecule are two ethyl groups (2 carbons each), a ketone, and additional tertiary amine connected to a methyl.
Tryptamines and lysergamides cover most of the serotonergic psychedelics, but there’s one more important class of compounds - the phenethylamines. Phenethylamine, like tryptamine, is a naturally occurring monoamine (one amine, or nitrogen group) with psychedelic derivatives. Amongst the phenethylamines, most well known are mescaline and MDMA.
Mescaline, the natural alkaloid found in peyote and san pedro cacti, features the phenethylamine pharmacophore (a benzene ring and a primary amine) with the addition of three methoxy groups (an oxygen and a carbon) to the benzene ring.
MDMA is a synthetic phenethylamine, featuring the addition of two methyl groups and a methylene dioxy group, composed of one carbon and two oxygens added to the benzene ring. If the methylene dioxy groups is removed, the remaining structure is methamphetamine, aka meth. This is how MDMA gets its stimulant-like features, as well as its name -
Drugs with similar structures tend to have similar functions. This is because the chemical properties of a drug, and thus its pharmacological activity, are determined by its structure. The arrangement of functional groups a molecule possesses determines which other molecules it will interact with, and which ones it might repel.
So it is the case that many tryptamines are similar in toxicity and effect, and serotonergic psychedelics generally tend to follow this pattern. However, this is not always the case. Just as minor alterations to even a single functional group can change the psychoactive effects of a drug, so can they affect toxicity. MDMA contains the structure of methamphetamine, but this does not necessarily speak to its pharmacology. Likewise, the safety of a novel substance is not guaranteed only by virtue of its pharmacological class.
One interesting member of the tryptamine family, 5,7-dihydroxytryptamine (5,7-DHT), is comparable in structure to serotonin, as well as to DMT and psilocin (4-HO-DMT). It is no drug for human consumption, though: 5,7-DHT is a potent serotonergic neurotoxin, used in laboratory research to selectively kill serotonergic neurons.
Every novel compound should thus be treated with caution, as each will have a unique pharmacological profile. At the same time, there may be no limit to the number of potential compounds out there. For every molecule that the human race has familiarized itself with, there may be thousands yet to be known.