def prepareGrammar( options ):
    
    num_blocks = options.num_blocks

    labels = string.letters.upper()
    annotate_terminals = {}
    for x in range(num_blocks):
        annotations = []
        key = "B%i" % x
        annotations.append( Annotation( row = "STATE",
                                        column = key,
                                        label = labels[x % len(labels)] ))

        annotate_terminals[ key ] = annotations

    input_model = DNA.buildModel( substitution_model = "gtr",
                                  num_blocks = num_blocks,
                                  grammar_type = options.grammar_type,
                                  shared_frequencies = False,
                                  shared_rates = False,
                                  annotate_terminals = annotate_terminals,
                                  )

    rate = 0.2
    for x in range(num_blocks):
        for param in ("alpha", "beta", "gamma", "delta", "theta", "epsilon"):
            p = "B%i_%s" % (x,param)
            input_model.mGrammar.removeParameter( p )
            input_model.mGrammar.addParameter( (p, rate), is_explicit = True )
        rate += 0.1

    grammar = input_model.mGrammar.mRules
    pseudononterminals = dict( [ ( ("NT_B%i*" % x,), ("NT_B%i" % x,) ) for x in range(num_blocks) ] )
    
    prob_same = options.probability_block
    prob_diff = (1.0 - prob_same) / len(pseudononterminals)

    for source in pseudononterminals.keys():
        mapped_source = pseudononterminals[source]
        for target,rule in grammar[source].items():
            if target == mapped_source:
                rule.mRate = (rule.mRate[0], prob_same )
            else:
                rule.mRate = (rule.mRate[0], prob_diff )

    writeModel( input_model, "input", options )

    return input_model

##-----------------------------------------------------------------------------------
##-----------------------------------------------------------------------------------
##-----------------------------------------------------------------------------------
This method drops UC from table and works for mysql, postgresql and
dataset/ETHPy150Open CGATOxford/cgat/obsolete/xrate_blocks.py/prepareGrammar--crossover with--dataset/ETHPy150Open openstack/rack/rack/db/sqlalchemy/utils.py/drop_unique_constraint