<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def getpeptides(self, chain):
 """If peptide ligand chains are defined via the command line options, try to extract the underlying ligand formed by all residues in the given chain without water """

        all_from_chain = [o for o in pybel.ob.OBResidueIter(
            self.proteincomplex.OBMol) if o.GetChain() == chain]  # All residues from chain
        if len(all_from_chain) == 0:
            return None
        else:
            non_water = [o for o in all_from_chain if not o.GetResidueProperty(9)]
            ligand = self.extract_ligand(non_water)
            return ligand