Using colorimetric sensor arrays scientists have successfully developed a method of "analytical cupping."
They note that in addition to being able to accurately differentiate between beans or blends they can even detect differences in roasting parameters (time and temperature). They used coffee because it is readily available in different types and qualities, but the method can be used for numerous complex substances.
As a note of clarification: This method does not allow detection of the individual compounds that make up a substance, but rather creates a fingerprint that allows the substance (in this case individual bean variety or blend) to be positively identified and distinguished from other varieties or blends.
(Abstract of the work available here).
BTW, as an aside, I might note that the work was done at the University of Illinois where I (albeit unsuccessfully) began my academic adventure hundreds of years ago.
)