def write_full_mapping_file(study, study_input_dir,zip_fname,files_to_remove,
                            output_dir):
    """ Generate a merged mapping file """
    
    # write per_run mapping files and then return the prefixes
    run_prefixes=write_db_mapping_files(study,True,study_input_dir,False)
    
    # define the full mapping file
    mapping_fname='study_%s_mapping_file.txt' % (str(study))
    final_mapping_fp=join(output_dir,mapping_fname)
    # add to list of files to remove
    files_to_remove.append(final_mapping_fp)
    
    # iterate over run_prefixes and create a list of files that need to be
    # merged
    mapping_files_to_merge=[]
    for i in run_prefixes:
        mapping_fp=join(study_input_dir,'study_%s_run_%s_mapping.txt' % \
                                        (str(study),str(i)))
        # add to list of files to remove
        files_to_remove.append(mapping_fp)
        mapping_files_to_merge.append(open(mapping_fp,'U'))
    
    # merge the mapping files and return tabular data
    mapping_data = merge_mapping_files(mapping_files_to_merge,\
                                       no_data_value='no_data')
    # write the full mapping file
    write_mapping_file(mapping_data,final_mapping_fp)
    
    # zip the full mapping file
    #cmd_call='cd %s; tar czvf %s %s' % (study_input_dir,zip_fname,mapping_fname)
    #system(cmd_call)
    
    return files_to_remove
Exemple #2
0
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)
      
    verbose = opts.verbose
    output_fp = opts.output_fp
    mapping_files = [open(fp,'U') for fp in opts.mapping_fps]
    no_data_value = opts.no_data_value
    
    mapping_data = merge_mapping_files(mapping_files,\
                                       no_data_value=no_data_value)
    write_mapping_file(mapping_data,output_fp)
def main():
    option_parser, opts, args = parse_command_line_parameters(**script_info)

    verbose = opts.verbose
    output_fp = opts.output_fp
    mapping_files = [open(fp, 'U') for fp in opts.mapping_fps]
    no_data_value = opts.no_data_value

    mapping_data = merge_mapping_files(mapping_files,
                                       no_data_value=no_data_value)
    write_mapping_file(mapping_data, output_fp)