def obj_to_dict(obj, names_getters_map): apply_to_obj = partial2(apply_to_object, obj) return dictmap(apply_to_obj, names_getters_map)
'POS' : int, 'MAPQ' : int, 'CIGAR' : str, 'RNEXT' : str, 'PNEXT' : int, 'TLEN' : int, #'MRNM' : str, #'MRNM' : '*='.__contains__, #'MPOS' : int, #'ISIZE' : int, 'SEQ' : str, 'QUAL' : str, #'OPTIONS' : str } #['OPT', 'MPOS', 'MRNM', 'ISIZE'] basic_schema = Schema(dictmap(Use, basic_scheme)) options_scheme = { 'A' : chr, 'i' : int, 'f' : float, 'Z' : str, 'H' : int, # hex 'B' : parse_array } def parse_option(option_str): ''' alternatively: tag, type, val = option_str.split('\t') ''' #_join = partial(reduce, lambda a, b: a+':'+b) # tag_type_val = op.itemgetter(0, 2, 4) # _tag = Regex(r'[A-Za-z][A-Za-z0-9]')