treetime/wrappers.py
def create_gtr(params):
    """
    parse the arguments referring to the GTR model and return a GTR structure
    """
    model = params.gtr
    gtr_params = params.gtr_params
    if model == 'infer':
        gtr = GTR.standard('jc', alphabet='aa' if params.aa else 'nuc')
    else:
        try:
            kwargs = {}
            if gtr_params is not None:
                for param in gtr_params:
                    keyval = param.split('=')
                    if len(keyval)!=2: continue
                    if keyval[0] in ['pis', 'pi', 'Pi', 'Pis']:
                        keyval[0] = 'pi'
                        keyval[1] = list(map(float, keyval[1].split(',')))
                    elif keyval[0] not in ['alphabet']:
                        keyval[1] = float(keyval[1])
                    kwargs[keyval[0]] = keyval[1]
            else:
                print ("GTR params are not specified. Creating GTR model with default parameters")

            gtr = GTR.standard(model, **kwargs)
            infer_gtr = False
        except:
            print ("Could not create GTR model from input arguments. Using default (Jukes-Cantor 1969)")
            gtr = GTR.standard('jc', alphabet='aa' if params.aa else 'nuc')
            infer_gtr = False
    return gtr
def create_gtr(params):
    model = params.gtr
    gtr_params = params.gtr_params
    if model == 'infer':
        gtr = GTR.standard('jc', alphabet='aa' if params.aa else 'nuc')
    else:
        try:
            kwargs = {}
            if gtr_params is not None:
                for param in gtr_params:
                    keyval = param.split('=')
                    if len(keyval)!=2: continue
                    if keyval[0] in ['pis', 'pi', 'Pi', 'Pis']:
                        keyval[0] = 'pi'
                        keyval[1] = list(map(float, keyval[1].split(',')))
                    elif keyval[0] not in ['alphabet']:
                        keyval[1] = float(keyval[1])
                    kwargs[keyval[0]] = keyval[1]
            else:
                print ("GTR params are not specified. Creating GTR model with default parameters")

            gtr = GTR.standard(model, **kwargs)
            infer_gtr = False
        except:
            print ("Could not create GTR model from input arguments. Using default (Jukes-Cantor 1969)")
            gtr = GTR.standard('jc', alphabet='aa' if params.aa else 'nuc')
            infer_gtr = False
    return gtr
def create_gtr ( params ) : model = params . gtr gtr_params = params . gtr_params if model == 'infer' : gtr = GTR . standard ( 'jc' , alphabet = 'aa' if params . aa else 'nuc' ) else : try : kwargs = { } if gtr_params is not None : for param in gtr_params : keyval = param . split ( '=' ) if len ( keyval ) != 2 : continue if keyval [ 0 ] in [ 'pis' , 'pi' , 'Pi' , 'Pis' ] : keyval [ 0 ] = 'pi' keyval [ 1 ] = list ( map ( float , keyval [ 1 ] . split ( ',' ) ) ) elif keyval [ 0 ] not in [ 'alphabet' ] : keyval [ 1 ] = float ( keyval [ 1 ] ) kwargs [ keyval [ 0 ] ] = keyval [ 1 ] else : print ( "GTR params are not specified. Creating GTR model with default parameters" ) gtr = GTR . standard ( model , * * kwargs ) infer_gtr = False except : print ( "Could not create GTR model from input arguments. Using default (Jukes-Cantor 1969)" ) gtr = GTR . standard ( 'jc' , alphabet = 'aa' if params . aa else 'nuc' ) infer_gtr = False return gtr
parse the arguments referring to the GTR model and return a GTR structure
parse the arguments referring to the GTR model and return a GTR structure