Example #1
0
def main(parser):
    wwarnCalcDict = {}

    config = ConfigParser.RawConfigParser()
    config.read(parser.config_file)
    ageGroups = parseAgeGroups(config.get('GENERAL', 'age_groups'))
    copyNumberGroups = parseCopyNumberGroups(config.get('GENERAL', 'copy_number_groups'))
    (markerGroups, markerCombos) = parseMarkerList(parser.marker_list)

    dataIter = createMysqlIterator(config, parser.study_ids, parser.sites, copyNumberGroups, markerCombos, parser.year_step)
    calculateWWARNStatistics(wwarnCalcDict, dataIter, ageGroups)

    # Before we can print our output we need to group all our statistics together under the 
    # categories and labels found in our marker map
    ageLabels = [t[2] for t in ageGroups]
    groupedStats = generateGroupedStatistics(wwarnCalcDict, markerGroups, ageLabels)

    # Our statistics need to be written to two files:
    #       1.) Statistics not grouped by age
    #       2.) Statistics grouped by age
    allFile = join(parser.output_directory, parser.output_prefix + '.all.calcs')
    ageFile = join(parser.output_directory, parser.output_prefix + '.age.calcs')

    write_statistics_to_file(groupedStats, allFile, ['All'], parser.year_step, parser.debug)
    write_statistics_to_file(groupedStats, ageFile, ageLabels, parser.year_step, parser.debug)