'Return reference data for a build.'

def reference(self, trans, dbkey, chrom, low, high):

    self.check_and_reload()
    (dbkey_owner, dbkey) = decode_dbkey(dbkey)
    if dbkey_owner:
        dbkey_user = trans.sa_session.query(trans.app.model.User).filter_by(username=dbkey_owner).first()
    else:
        dbkey_user = trans.user
    if (not self.has_reference_data(dbkey, dbkey_user)):
        return None
    twobit_file_name = None
    if (dbkey in self.genomes):
        twobit_file_name = self.genomes[dbkey].twobit_file
    else:
        user_keys = loads(dbkey_user.preferences['dbkeys'])
        dbkey_attributes = user_keys[dbkey]
        fasta_dataset = trans.sa_session.query(trans.app.model.HistoryDatasetAssociation).get(dbkey_attributes['fasta'])
        msg = fasta_dataset.convert_dataset(trans, 'twobit')
        if msg:
            return msg
        else:
            twobit_dataset = fasta_dataset.get_converted_dataset(trans, 'twobit')
            twobit_file_name = twobit_dataset.file_name
    try:
        twobit = TwoBitFile(open(twobit_file_name))
        if (chrom in twobit):
            seq_data = twobit[chrom].get(int(low), int(high))
            return GenomeRegion(chrom=chrom, start=low, end=high, sequence=seq_data)
    except IOError:
        return None
