def to_subject_id(s):
if not pimms.is_number(s) and not pimms.is_str(s):<EOL><INDENT>raise ValueError('<STR_LIT>' % str(type(s)))<EOL><DEDENT>if pimms.is_str(s):<EOL><INDENT>try: s = os.path.expanduser(s)<EOL>except Exception: pass<EOL>if os.path.isdir(s): s = s.split(os.sep)[-<NUM_LIT:1>]<EOL><DEDENT>s = int(s)<EOL>if s > <NUM_LIT> or s < <NUM_LIT>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>return s<EOL>
to_subject_id(s) coerces the given string or number into an integer subject id. If s is not a
  valid subejct id, raises an exception.