An adaptive method for statistical detection with applications to drug discovery