'Parses and sets species, chromosomes, index from MAF file.'

def set_meta(self, dataset, overwrite=True, **kwd):

    from galaxy.tools.util.maf_utilities import build_maf_index_species_chromosomes
    (indexes, species, species_chromosomes, blocks) = build_maf_index_species_chromosomes(dataset.file_name)
    if (indexes is None):
        return
    dataset.metadata.species = species
    dataset.metadata.blocks = blocks
    chrom_file = dataset.metadata.species_chromosomes
    if (not chrom_file):
        chrom_file = dataset.metadata.spec['species_chromosomes'].param.new_file(dataset=dataset)
    chrom_out = open(chrom_file.file_name, 'wb')
    for (spec, chroms) in species_chromosomes.items():
        chrom_out.write(('%s DCTB %s\n' % (spec, ' DCTB '.join(chroms))))
    chrom_out.close()
    dataset.metadata.species_chromosomes = chrom_file
    index_file = dataset.metadata.maf_index
    if (not index_file):
        index_file = dataset.metadata.spec['maf_index'].param.new_file(dataset=dataset)
    indexes.write(open(index_file.file_name, 'wb'))
    dataset.metadata.maf_index = index_file
