예제 #1
0
파일: uf.py 프로젝트: tlinnet/relax
def select_model(model=None, spin_id=None):
    """Function for the selection of a preset model-free model.

    @param model:   The name of the model.
    @type model:    str
    @param spin_id: The spin identification string.
    @type spin_id:  str
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Test if the pipe type is 'mf'.
    function_type = pipes.get_type()
    if function_type != 'mf':
        raise RelaxFuncSetupError(specific_analyses.get_string(function_type))

    # Test if sequence data is loaded.
    if not exists_mol_res_spin_data():
        raise RelaxNoSequenceError

    # Obtain the model info.
    equation, params = model_map(model)

    # Set up the model.
    model_setup(model, equation, params, spin_id)
예제 #2
0
파일: uf.py 프로젝트: pombredanne/relax
def select_model(model=None, spin_id=None):
    """Function for the selection of a preset model-free model.

    @param model:   The name of the model.
    @type model:    str
    @param spin_id: The spin identification string.
    @type spin_id:  str
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Test if the pipe type is 'mf'.
    function_type = pipes.get_type()
    if function_type != "mf":
        raise RelaxFuncSetupError(specific_analyses.get_string(function_type))

    # Test if sequence data is loaded.
    if not exists_mol_res_spin_data():
        raise RelaxNoSequenceError

    # Obtain the model info.
    equation, params = model_map(model)

    # Set up the model.
    model_setup(model, equation, params, spin_id)
예제 #3
0
파일: uf.py 프로젝트: tlinnet/relax
def remove_tm(spin_id=None):
    """Remove local tm from the set of model-free parameters for the given spins.

    @param spin_id: The spin identification string.
    @type spin_id:  str or None
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Test if the pipe type is 'mf'.
    function_type = pipes.get_type()
    if function_type != 'mf':
        raise RelaxFuncSetupError(specific_analyses.get_string(function_type))

    # Test if sequence data is loaded.
    if not exists_mol_res_spin_data():
        raise RelaxNoSequenceError

    # Loop over the spins.
    for spin in spin_loop(spin_id):
        # Skip deselected spins.
        if not spin.select:
            continue

        # Test if a local tm parameter exists.
        if not hasattr(spin, 'params') or not 'local_tm' in spin.params:
            continue

        # Remove tm.
        spin.params.remove('local_tm')

        # Model name.
        if match('^tm', spin.model):
            spin.model = spin.model[1:]

        # Delete the local tm variable.
        del spin.local_tm

        # Set all the minimisation stats to None.
        spin.chi2 = None
        spin.iter = None
        spin.f_count = None
        spin.g_count = None
        spin.h_count = None
        spin.warning = None

    # Set the global minimisation stats to None.
    cdp.chi2 = None
    cdp.iter = None
    cdp.f_count = None
    cdp.g_count = None
    cdp.h_count = None
    cdp.warning = None
예제 #4
0
파일: uf.py 프로젝트: pombredanne/relax
def remove_tm(spin_id=None):
    """Remove local tm from the set of model-free parameters for the given spins.

    @param spin_id: The spin identification string.
    @type spin_id:  str or None
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Test if the pipe type is 'mf'.
    function_type = pipes.get_type()
    if function_type != "mf":
        raise RelaxFuncSetupError(specific_analyses.get_string(function_type))

    # Test if sequence data is loaded.
    if not exists_mol_res_spin_data():
        raise RelaxNoSequenceError

    # Loop over the spins.
    for spin in spin_loop(spin_id):
        # Skip deselected spins.
        if not spin.select:
            continue

        # Test if a local tm parameter exists.
        if not hasattr(spin, "params") or not "local_tm" in spin.params:
            continue

        # Remove tm.
        spin.params.remove("local_tm")

        # Model name.
        if match("^tm", spin.model):
            spin.model = spin.model[1:]

        # Delete the local tm variable.
        del spin.local_tm

        # Set all the minimisation stats to None.
        spin.chi2 = None
        spin.iter = None
        spin.f_count = None
        spin.g_count = None
        spin.h_count = None
        spin.warning = None

    # Set the global minimisation stats to None.
    cdp.chi2 = None
    cdp.iter = None
    cdp.f_count = None
    cdp.g_count = None
    cdp.h_count = None
    cdp.warning = None
예제 #5
0
파일: uf.py 프로젝트: tlinnet/relax
def create_model(model=None, equation=None, params=None, spin_id=None):
    """Function for creating a custom model-free model.

    @param model:       The name of the model.
    @type model:        str
    @param equation:    The equation type to use.  The 3 allowed types are:  'mf_orig' for the original model-free equations with parameters {s2, te}; 'mf_ext' for the extended model-free equations with parameters {s2f, tf, s2, ts}; and 'mf_ext2' for the extended model-free equations with parameters {s2f, tf, s2s, ts}.
    @type equation:     str
    @param params:      A list of the parameters to include in the model.  The allowed parameter names includes those for the equation type as well as chemical exchange 'rex', the bond length 'r', and the chemical shift anisotropy 'csa'.
    @type params:       list of str
    @param spin_id:     The spin identification string.
    @type spin_id:      str
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Test if the pipe type is 'mf'.
    function_type = pipes.get_type()
    if function_type != 'mf':
        raise RelaxFuncSetupError(specific_analyses.get_string(function_type))

    # Test if sequence data is loaded.
    if not exists_mol_res_spin_data():
        raise RelaxNoSequenceError

    # Check the validity of the model-free equation type.
    valid_types = ['mf_orig', 'mf_ext', 'mf_ext2']
    if not equation in valid_types:
        raise RelaxError("The model-free equation type argument " +
                         repr(equation) + " is invalid and should be one of " +
                         repr(valid_types) + ".")

    # Check the validity of the parameter array.
    s2, te, s2f, tf, s2s, ts, rex, csa, r = 0, 0, 0, 0, 0, 0, 0, 0, 0
    for i in range(len(params)):
        # Invalid parameter flag.
        invalid_param = 0

        # S2.
        if params[i] == 's2':
            # Does the array contain more than one instance of S2.
            if s2:
                invalid_param = 1
            s2 = 1

            # Does the array contain S2s.
            s2s_flag = 0
            for j in range(len(params)):
                if params[j] == 's2s':
                    s2s_flag = 1
            if s2s_flag:
                invalid_param = 1

        # te.
        elif params[i] == 'te':
            # Does the array contain more than one instance of te and has the extended model-free formula been selected.
            if equation == 'mf_ext' or te:
                invalid_param = 1
            te = 1

            # Does the array contain the parameter S2.
            s2_flag = 0
            for j in range(len(params)):
                if params[j] == 's2':
                    s2_flag = 1
            if not s2_flag:
                invalid_param = 1

        # S2f.
        elif params[i] == 's2f':
            # Does the array contain more than one instance of S2f and has the original model-free formula been selected.
            if equation == 'mf_orig' or s2f:
                invalid_param = 1
            s2f = 1

        # S2s.
        elif params[i] == 's2s':
            # Does the array contain more than one instance of S2s and has the original model-free formula been selected.
            if equation == 'mf_orig' or s2s:
                invalid_param = 1
            s2s = 1

        # tf.
        elif params[i] == 'tf':
            # Does the array contain more than one instance of tf and has the original model-free formula been selected.
            if equation == 'mf_orig' or tf:
                invalid_param = 1
            tf = 1

            # Does the array contain the parameter S2f.
            s2f_flag = 0
            for j in range(len(params)):
                if params[j] == 's2f':
                    s2f_flag = 1
            if not s2f_flag:
                invalid_param = 1

        # ts.
        elif params[i] == 'ts':
            # Does the array contain more than one instance of ts and has the original model-free formula been selected.
            if equation == 'mf_orig' or ts:
                invalid_param = 1
            ts = 1

            # Does the array contain the parameter S2 or S2s.
            flag = 0
            for j in range(len(params)):
                if params[j] == 's2' or params[j] == 's2f':
                    flag = 1
            if not flag:
                invalid_param = 1

        # Rex.
        elif params[i] == 'rex':
            if rex:
                invalid_param = 1
            rex = 1

        # Interatomic distances.
        elif params[i] == 'r':
            if r:
                invalid_param = 1
            r = 1

        # CSA.
        elif params[i] == 'csa':
            if csa:
                invalid_param = 1
            csa = 1

        # Unknown parameter.
        else:
            raise RelaxError("The parameter " + params[i] +
                             " is not supported.")

        # The invalid parameter flag is set.
        if invalid_param:
            raise RelaxError("The parameter array " + repr(params) +
                             " contains an invalid combination of parameters.")

    # Set up the model.
    model_setup(model, equation, params, spin_id)
예제 #6
0
파일: uf.py 프로젝트: pombredanne/relax
def create_model(model=None, equation=None, params=None, spin_id=None):
    """Function for creating a custom model-free model.

    @param model:       The name of the model.
    @type model:        str
    @param equation:    The equation type to use.  The 3 allowed types are:  'mf_orig' for the original model-free equations with parameters {s2, te}; 'mf_ext' for the extended model-free equations with parameters {s2f, tf, s2, ts}; and 'mf_ext2' for the extended model-free equations with parameters {s2f, tf, s2s, ts}.
    @type equation:     str
    @param params:      A list of the parameters to include in the model.  The allowed parameter names includes those for the equation type as well as chemical exchange 'rex', the bond length 'r', and the chemical shift anisotropy 'csa'.
    @type params:       list of str
    @param spin_id:     The spin identification string.
    @type spin_id:      str
    """

    # Test if the current data pipe exists.
    check_pipe()

    # Test if the pipe type is 'mf'.
    function_type = pipes.get_type()
    if function_type != "mf":
        raise RelaxFuncSetupError(specific_analyses.get_string(function_type))

    # Test if sequence data is loaded.
    if not exists_mol_res_spin_data():
        raise RelaxNoSequenceError

    # Check the validity of the model-free equation type.
    valid_types = ["mf_orig", "mf_ext", "mf_ext2"]
    if not equation in valid_types:
        raise RelaxError(
            "The model-free equation type argument "
            + repr(equation)
            + " is invalid and should be one of "
            + repr(valid_types)
            + "."
        )

    # Check the validity of the parameter array.
    s2, te, s2f, tf, s2s, ts, rex, csa, r = 0, 0, 0, 0, 0, 0, 0, 0, 0
    for i in range(len(params)):
        # Invalid parameter flag.
        invalid_param = 0

        # S2.
        if params[i] == "s2":
            # Does the array contain more than one instance of S2.
            if s2:
                invalid_param = 1
            s2 = 1

            # Does the array contain S2s.
            s2s_flag = 0
            for j in range(len(params)):
                if params[j] == "s2s":
                    s2s_flag = 1
            if s2s_flag:
                invalid_param = 1

        # te.
        elif params[i] == "te":
            # Does the array contain more than one instance of te and has the extended model-free formula been selected.
            if equation == "mf_ext" or te:
                invalid_param = 1
            te = 1

            # Does the array contain the parameter S2.
            s2_flag = 0
            for j in range(len(params)):
                if params[j] == "s2":
                    s2_flag = 1
            if not s2_flag:
                invalid_param = 1

        # S2f.
        elif params[i] == "s2f":
            # Does the array contain more than one instance of S2f and has the original model-free formula been selected.
            if equation == "mf_orig" or s2f:
                invalid_param = 1
            s2f = 1

        # S2s.
        elif params[i] == "s2s":
            # Does the array contain more than one instance of S2s and has the original model-free formula been selected.
            if equation == "mf_orig" or s2s:
                invalid_param = 1
            s2s = 1

        # tf.
        elif params[i] == "tf":
            # Does the array contain more than one instance of tf and has the original model-free formula been selected.
            if equation == "mf_orig" or tf:
                invalid_param = 1
            tf = 1

            # Does the array contain the parameter S2f.
            s2f_flag = 0
            for j in range(len(params)):
                if params[j] == "s2f":
                    s2f_flag = 1
            if not s2f_flag:
                invalid_param = 1

        # ts.
        elif params[i] == "ts":
            # Does the array contain more than one instance of ts and has the original model-free formula been selected.
            if equation == "mf_orig" or ts:
                invalid_param = 1
            ts = 1

            # Does the array contain the parameter S2 or S2s.
            flag = 0
            for j in range(len(params)):
                if params[j] == "s2" or params[j] == "s2f":
                    flag = 1
            if not flag:
                invalid_param = 1

        # Rex.
        elif params[i] == "rex":
            if rex:
                invalid_param = 1
            rex = 1

        # Interatomic distances.
        elif params[i] == "r":
            if r:
                invalid_param = 1
            r = 1

        # CSA.
        elif params[i] == "csa":
            if csa:
                invalid_param = 1
            csa = 1

        # Unknown parameter.
        else:
            raise RelaxError("The parameter " + params[i] + " is not supported.")

        # The invalid parameter flag is set.
        if invalid_param:
            raise RelaxError("The parameter array " + repr(params) + " contains an invalid combination of parameters.")

    # Set up the model.
    model_setup(model, equation, params, spin_id)