Esempio n. 1
0
def get_model_difficulty(modelstring):
    """
    Input a model string like HKY+I+G or LG+G+F, and a guess about how long it
    takes to analyse Right now, this is done with a simple hack. I just return
    a number that is the number of params plus a modifier for extra stuff like
    +I and +G the hardest models are +I+G, then +G, then +I this is just used
    to rank models for ordering the analysis. The return is a 'difficulty'
    score that can be used to rank models for queing and do the hardest first
    """

    elements = modelstring.split("+")

    model_params = get_num_params(modelstring)

    difficulty = 0
    if "G" in elements[1:]:
        difficulty += 2000
    if "I" in elements[1:]:
        difficulty += 1000
    if "F" in elements[1:]:
        difficulty += 3000
    if "X" in elements[1:]:
        difficulty += 4000

    if the_config.datatype == "protein" and "GTR" in modelstring:
        # that's a tough model with 189 free parameters
        difficulty += 10000

    extras = modelstring.count("+")
    total = model_params + extras + difficulty
    log.debug("Model: %s Difficulty: %d" % (modelstring, total))

    return total
def get_model_difficulty(modelstring):
    """
    Input a model string like HKY+I+G or LG+G+F, and a guess about how long it
    takes to analyse Right now, this is done with a simple hack. I just return
    a number that is the number of params plus a modifier for extra stuff like
    +I and +G the hardest models are +I+G, then +G, then +I this is just used
    to rank models for ordering the analysis. The return is a 'difficulty'
    score that can be used to rank models for queing and do the hardest first
    """

    elements = modelstring.split("+")

    model_params = get_num_params(modelstring)

    difficulty = 0
    if "G" in elements[1:]:
        difficulty += 2000
    if "I" in elements[1:]:
        difficulty += 1000
    if "F" in elements[1:]:
        difficulty += 3000
    if "X" in elements[1:]:
        difficulty += 4000

    if the_config.datatype == "protein" and "GTR" in modelstring:
        # that's a tough model with 189 free parameters
        difficulty += 10000

    extras = modelstring.count("+")
    total = model_params + extras + difficulty
    log.debug("Model: %s Difficulty: %d" % (modelstring, total))

    return total
    if "LG4" in modelstring:
        # these models are hard
        difficulty += 9000

    extras = modelstring.count("+")
    total = model_params + extras + difficulty
    log.debug("Model: %s Difficulty: %d" % (modelstring, total))

    return total


if __name__ == "__main__":
    print "  ",
    print "Name".ljust(15),
    print "Params".ljust(10),
    print "Diff".ljust(10),
    print "CommandLine"
    for i, model in enumerate(get_all_dna_models()):
        print str(i + 1).rjust(2),
        print model.ljust(15),
        print str(get_num_params(model)).ljust(10),
        print str(get_model_difficulty(model)).ljust(10),
        print get_model_commandline(model)
    for i, model in enumerate(get_all_protein_models()):
        print str(i + 1).rjust(2),
        print model.ljust(15),
        print str(get_num_params(model)).ljust(10),
        print str(get_model_difficulty(model)).ljust(10),
        print get_model_commandline(model)
    if the_config.datatype == "protein" and "GTR" in modelstring:
        # that's a tough model with 189 free parameters
        difficulty += 10000

    extras = modelstring.count("+")
    total = model_params + extras + difficulty
    log.debug("Model: %s Difficulty: %d" % (modelstring, total))

    return total

if __name__ == "__main__":
    print "  ",
    print "Name".ljust(15),
    print "Params".ljust(10),
    print "Diff".ljust(10),
    print "CommandLine"
    for i, model in enumerate(get_all_dna_models()):
        print str(i+1).rjust(2), 
        print model.ljust(15),
        print str(get_num_params(model)).ljust(10),
        print str(get_model_difficulty(model)).ljust(10),
        print get_model_commandline(model)
    for i, model in enumerate(get_all_protein_models()):
        print str(i+1).rjust(2), 
        print model.ljust(15),
        print str(get_num_params(model)).ljust(10),
        print str(get_model_difficulty(model)).ljust(10),
        print get_model_commandline(model)