def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    frames = opts.frames
    step_size = opts.step_size
    output_path = opts.output_dir
    input_dir = opts.input_dir
    qsub_calls_filepath = opts.qsub_calls_filepath

    try:
        makedirs(output_path)
    except:
        pass

    for i in range(0,int(frames/(step_size*1.0))):
        lower_bound = int((step_size*i)+1)
        upper_bound = int(step_size*i+step_size)

        filename = 'mathematica_script_%d_%d.m' % (lower_bound, upper_bound)
        script_filename = join(output_path, filename)


        fd = open(script_filename, 'w') 
        fd.write(MATHEMATICA_SCRIPT % (frames, input_dir+'/', lower_bound, upper_bound))
        fd.close

        if qsub_calls_filepath:
            fd = open(qsub_calls_filepath, 'a')
            fd.write(QSUB_STRING_CMD % (filename, 'MMA_%d_%d' % (lower_bound,
                upper_bound)))
            fd.close()
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    mapping_fp = opts.mapping_fp
    coloring_header_name = opts.coloring_header_name
    subject_header_name = opts.subject_header_name
    force = opts.force
    coords_fp = opts.coords_fp
    suppress_trajectory_files = opts.suppress_trajectory_files
    sorting_category = opts.sorting_category

    if opts.output_path == None:
        output_path = 'colored_by_%s_separated_by_%s' % (coloring_header_name,
            subject_header_name)
    else:
        output_path = opts.output_path

    try:
        makedirs(output_path)
    except:
        if not force:
            option_parser.error('Pfft something bad happened when creating the '
                'output directory, try a different --output_path.')

    data, headers, _ = parse_mapping_file(open(mapping_fp, 'U'))

    subject_index = headers.index(subject_header_name)
    coloring_index = headers.index(coloring_header_name)

    coloring_values = list(set([row[coloring_index] for row in data]))

    @display_wrap
    def silly_function(ui):
        for c_value in ui.series(coloring_values):
            sample_ids = sample_ids_from_metadata_description(open(mapping_fp, 'U'),
                '%s:%s' % (coloring_header_name, c_value))

            _headers, _data = filter_mapping_file(data, headers, sample_ids, True)
            per_color_subject_values = list(set([row[subject_index] for row in _data]))

            fd = open(join(output_path, 'color_by_'+c_value+'.txt'), 'w')
            for s in ui.series(per_color_subject_values):
                fd.write('%s\n' % s)
            fd.close()

            if not suppress_trajectory_files:
                for s in ui.series(per_color_subject_values):
                    filename = join(output_path, s+'.txt')

                    if opts.verbose:
                        print 'Working on printing', filename

                    COMMAND_CALL = FILTER_CMD % (coords_fp, mapping_fp,
                        '%s:%s' % (subject_header_name, s), filename,
                        sorting_category)
                    o, e, r = qiime_system_call(COMMAND_CALL)
                    if opts.verbose and e:
                        print 'Error happened on filtering step: \n%s' % e
                        continue

                    COMMAND_CALL = CONVERSION_CMD % (filename, filename)
                    o, e, r = qiime_system_call(COMMAND_CALL)
                    if opts.verbose and e:
                        print 'Error happened on conversion step: \n%s' % e
                        continue # useless here but just in case


    silly_function()