A program is described that searches three-dimensional, structural databases, given a user-defined query, in order to retrieve all structures that contain any combination of a user-specified minimum number of matching elements. Queries consist of three-dimensional coordinates of atoms and/or bonds. Numerous query constraints are described which allow the investigator to define the chemical nature of the desired structures as well as the environment within which these structures must reside. They include: (1) Bonded vs. isolated atom distinction; (2) Atom type designation; (3) Definition of subsets with occupancy specification (>, =, < X atoms); (4) RMS-fit; (5) Active site volume accessibility of atoms linking query elements; (6) Number, atom type, and cyclic structure constraints for atoms linking pharmacophoric elements; (7) Automatic error boundary adjustment--ad infinitum constraint. To illustrate the capabilities of this program, queries based on the crystal structure of a thermolysin-inhibitor complex were tested against a subset of the Cambridge Crystallographic Database. Several compounds were returned which satisfied various aspects of the query, including fitting within the active site. Combination of segments of compounds which satisfy partial queries should provide a method for generating unique compounds with affinity for sites of known three-dimensional structure.