def polarpairs(sel1, sel2, cutoff=4.0, angle=63.0, name='', quiet=1):
	'''
ARGUMENTS

    sel1, sel2 = string: atom selections

    cutoff = float: distance cutoff

    angle = float: h-bond angle cutoff in degrees. If angle="default", take
    "h_bond_max_angle" setting. If angle=0, do not detect h-bonding.

SEE ALSO

    cmd.find_pairs, cmd.distance
	'''
	cutoff = float(cutoff)
	quiet = int(quiet)
	if angle == 'default':
		angle = cmd.get('h_bond_max_angle', cmd.get_object_list(sel1)[0])
	angle = float(angle)
	mode = 1 if angle > 0 else 0
	x = cmd.find_pairs('(%s) and donors' % sel1, '(%s) and acceptors' % sel2,
			cutoff=cutoff, mode=mode, angle=angle) + \
		cmd.find_pairs('(%s) and acceptors' % sel1, '(%s) and donors' % sel2,
			cutoff=cutoff, mode=mode, angle=angle)
	x = sorted(set(x))
	if not quiet:
		print 'Settings: cutoff=%.1fangstrom angle=%.1fdegree' % (cutoff, angle)
		print 'Found %d polar contacts' % (len(x))
	if len(name) > 0:
		for p in x:
			cmd.distance(name, '(%s`%s)' % p[0], '(%s`%s)' % p[1])
	return x

cmd.extend('polarpairs', polarpairs)

cmd.auto_arg[0].update({
	'polarpairs'     : [ cmd.selection_sc           , 'selection'       , ', ' ],
})
cmd.auto_arg[1].update({
	'polarpairs'     : [ cmd.selection_sc           , 'selection'       , ''   ],
})
