A compound of formula, or a pharmaceutically acceptable salt or ester thereof, wherein: B is a saturated or partially unsaturated monocyclic or bicyclic, heterocyclic group optionally substituted by one or more R 10 groups and optionally containing one or more CO groups; X is selected from SO 2, CO 2, CO, CONR 11, NR 11 CO and (CR 12 R 13) p; each R 1 is independently selected from halogen, OR 14, SR 14 and R 14; R 2 is selected from H and alkyl; R 3 is selected from H, alkyl, cycloalkyl and heterocycloalkyl, each of which is optionally substituted by one or more substituents selected from NR 24 R 25 and R 26; or R 2 and R 3 are linked together with the nitrogen to which they are attached to form a saturated heterocyclic group optionally containing one or more additional heteroatoms selected from O, N and S, and optionally substituted by one or more R 27 groups; each R 4 and R 5 is independently selected from H, alkyl, (CH 2) s OR 15 and (CH 2) t NR 16 R 17; or one of R 4 and R 5 is H or alkyl and the other is linked to R 3 to form a saturated heterocyclic group; each R 6 and R 7 is independently selected from H, alkyl, (CH 2) u OR 18 and (CH 2) v NR 19 R 20; or one of R 6 and R 7 is H or alkyl and the other is linked to R 3 to form a saturated heterocyclic group; each R 8 and R 9 is independently selected from H, alkyl, (CH 2) w OR 21 and (CH 2) x NR 22 R 23; or one of R 8 and R 9 is H or alkyl and the other is linked to R 3 to form a saturated heterocyclic group; or one of R 8 and R 9 is linked to one of R 4 and R 5 to form a cyclic group; R 10 is selected from alkyl, OH, halogen, alkoxy, CO 2 -alkyl, COOH, CO-alkyl and CN; R 11, R 12,R 13, R 15, R 16, R 17, R 18, R 19, R 20, R 21, R 22, R 23, R 24 and R 25 are each independently H or alkyl; R 14, R 26 and R 27 are each independently alkyl; m, q and r are each independently 0, 1 or 2, such that the sum of m + q + r is 2, 3 or 4; n is an integer selected from 1, 2, 3 and 4; p is an integer selected from 0, 1 and 2; and s, t, u, v, w and x are each independently 0, 1, 2, 3 or 4. B is a saturated or partially unsaturated monocyclic or bicyclic, heterocyclic group optionally substituted by one or more R 10 groups and optionally containing one or more CO groups; X is selected from SO 2, CO 2, CO, CONR 11, NR 11 CO and (CR 12 R 13) p; each R 1 is independently selected from halogen, OR 14, SR 14 and R 14; R 2 is selected from H and alkyl; R 3 is selected from H, alkyl, cycloalkyl and heterocycloalkyl, each of which is optionally substituted by one or more substituents selected from NR 24 R 25 and R 26; or R 2 and R 3 are linked together with the nitrogen to which they are attached to form a saturated heterocyclic group optionally containing one or more additional heteroatoms selected from O, N and S, and optionally substituted by one or more R 27 groups; each R 4 and R 5 is independently selected from H, alkyl, (CH 2) s OR 15 and (CH 2) t NR 16 R 17; or one of R 4 and R 5 is H or alkyl and the other is linked to R 3 to form a saturated heterocyclic group; each R 6 and R 7 is independently selected from H, alkyl, (CH 2) u OR 18 and (CH 2) v NR 19 R 20; or one of R 6 and R 7 is H or alkyl and the other is linked to R 3 to form a saturated heterocyclic group; each R 8 and R 9 is independently selected from H, alkyl, (CH 2) w OR 21 and (CH 2) x NR 22 R 23; or one of R 8 and R 9 is H or alkyl and the other is linked to R 3 to form a saturated heterocyclic group; or one of R 8 and R 9 is linked to one of R 4 and R 5 to form a cyclic group; R 10 is selected from alkyl, OH, halogen, alkoxy, CO 2 -alkyl, COOH, CO-alkyl and CN; R 11, R 12,R 13, R 15, R 16, R 17, R 18, R 19, R 20, R 21, R 22, R 23, R 24 and R 25 are each independently H or alkyl; R 14, R 26 and R 27 are each independently alkyl; m, q and r are each independently 0, 1 or 2, such that the sum of m + q + r is 2, 3 or 4; n is an integer selected from 1, 2, 3 and 4; p is an integer selected from 0, 1 and 2; and s, t, u, v, w and x are each independently 0, 1, 2, 3 or 4.