Detecting a gas molecule moving through a small pinhole Suppose I have the four DNA base chemicals - thymine, adenine, cytosine, and guanine. Imagine I turn each of them into a gas, make a "cartridge" of the gas for each chemical, and then have a "pinhole" that is opened or closed by a semiconductor. When the pinhole is open, the gas will, of course, expand through the pinhole and exit the cartridge. The system must emit only one molecule at a time.

If I send a command to the semiconductor to open the pinhole, what kind of sensor can I use to detect a molecule passing through? If necessary, you can modify the base chemicals as long as it would not interfere with their chemical properties in any way other than to improve detection of those molecules, if that makes sense.

The cheaper and more compact the system, the better, of course. I was thinking about the way an inkjet printer works, with a piezoelectric crystal vibrating the ink into droplets, but even the smallest droplets (a picoliter or so) are still bigger than a single molecule, so that doesn't work. Other possible methods I've thought of include a MALDI like system, a system where a weak laser is set up with a light detector; when a molecule passes through, the beam is interrupted, using a scanning tunneling microscope (STM; no idea how that would work), or a system using fluorophores.
The best way to do this is to detect the molecules you want in the presence of others that carry it along. You should not expect to detect every molecule of the type you want but just one of them at a time. 

The most sensitive detection technique is mass spectrometry, more sensitive than fluorescence because if a molecule fluoresces in a direction away from your detector its photon is lost. All ions can in principle be collected in a mass spectrometer.

To get the molecules into the spectrometer mix them with a solvent, (if necessary) and heat this with a pulsed IR laser. This has to be sufficient to vaporise the mixture/substrate  and it has to be positioned close to the input of the spectrometer since this is done outside the spectrometer. The vapour is at atmospheric pressure and mixed with air but because of the pressure differential efficiently enters the spectrometer (it is easy to see this). Here by differential pumping and using skimmers before the entrance to the mass spectrometer part some of the target molecules will be present in the beam produced. The mass spectrometer should probably be of the time of flight/reflectron type to increase throughput and mass resolution. By pulsing the laser it is then possible to gate the detector to observe the molecules at just the right time and so reduce noise. Of course once you have detected the molecule it is destroyed on the detector. 

If you do not want to destroy the molecules then fluorescence detection is the only possibility provided the molecule does fluoresce as not all do with a reasonable yield. A second laser is thus needed after the mass selection and then a photomultiplier is used to count single photons of fluorescence as they arrive (v. common technique now for 50 years or more). I'm not sure what you could do after that but again there is time as photons travel effectively instantaneously compared to the sped the molecule will be travelling at. As I said in a comment not cheap, not trivial.