code: public static List<Group> getLigandsByProximity(Collection<Group> target, Atom[] query, double cutoff) {
  		// Geometric hashing of the reduced structure
  		Grid grid = new Grid(cutoff);
  		grid.addAtoms(query);
  
  		List<Group> ligands = new ArrayList<>();
  		for(Group g :target ) {
  			// don't worry about waters
  			if(g.isWater()) {
  				continue;
  			}
  
  			if(g.isPolymeric() ) {
  				// Polymers aren't ligands
  				continue;
  			}
  
  			// It is a ligand!
  
  			// Check that it's within cutoff of something in reduced
  			List<Atom> groupAtoms = g.getAtoms();
  			if( ! grid.hasAnyContact(Calc.atomsToPoints(groupAtoms))) {
  				continue;
  			}
  
  			ligands.add(g);
  		}
  		return ligands;
  	}
docs: Finds all ligand groups from the target which fall within the cutoff distance
  of some atom from the query set.
  
  @param target Set of groups including the ligands
  @param query Atom selection
  @param cutoff Distance from query atoms to consider, in angstroms
  @return All groups from the target with at least one atom within cutoff of a query atom
  @see StructureTools#DEFAULT_LIGAND_PROXIMITY_CUTOFF