Ejemplo n.º 1
0
    def __init__(self):
        # Some dummy data structures.
        self.script_file = None
        self.intro_string = ''
        self.dummy_mode = 1

        # Start the interpreter!
        self.interpreter = Interpreter(self)
        self.interpreter.run()

        # Get the names of the data structures.
        names = sorted(self.local.keys())

        # Alphabetically sort the names of the data structures.

        # Alphabetically sort the names of the data structures.
        for name in names:
            # Skip the name if it is in the blacklist.
            blacklist = [
                'Numeric', 'Scientific', 'intro_off', 'intro_on', 'pi',
                'script'
            ]
            if name in blacklist:
                continue

            # Get the object.
            object = self.local[name]

            # Determine if the structure is user function containing class.
            if hasattr(object, '__relax_help__'):
                # Get the names of the data structures.
                names2 = sorted(dir(object))

                # Alphabetically sort the names of the data structures.
                for name2 in names2:
                    # Skip names begining with an underscore.
                    if search('^_', name2):
                        continue

                    # Get the object.
                    object2 = getattr(object, name2)

                    # Skip the object if there is no docstring.
                    if not hasattr(object2, '__doc__') or not object2.__doc__:
                        continue

                    # Printout.
                    print(name + '.' + name2)

                # Done.
                continue

            # Skip the object if there is no docstring.
            if not hasattr(object, '__doc__') or not object.__doc__:
                continue

            # Print the name.
            print(name)
Ejemplo n.º 2
0
    def __init__(self, methodName=None):
        """Set up the test case class for the system tests."""

        # Execute the base __init__ methods.
        super(Test_align_tensor, self).__init__(methodName)

        # Load the interpreter.
        self.interpreter = Interpreter(show_script=False, raise_relax_error=True)
        self.interpreter.populate_self()
        self.interpreter.on(verbose=False)

        # Alias the user function class.
        self.align_tensor_fns = self.interpreter.align_tensor
Ejemplo n.º 3
0
    def __init__(self, methodName=None):
        """Set up the test case class for the system tests."""

        # Execute the base __init__ methods.
        super(Test_eliminate, self).__init__(methodName)

        # Load the interpreter.
        self.interpreter = Interpreter(show_script=False, raise_relax_error=True)
        self.interpreter.populate_self()
        self.interpreter.on(verbose=False)

        # Place the user functions into a container.
        self.eliminate_fns = Container()
        self.eliminate_fns.eliminate = self.interpreter.eliminate
Ejemplo n.º 4
0
    def __init__(self, methodName=None):
        """Set up the test case class for the system tests."""

        # Execute the TestCase __init__ method.
        super(SystemTestCase, self).__init__(methodName)

        # A string used for classifying skipped tests.
        if not hasattr(self, '_skip_type'):
            self._skip_type = 'system'

        # Load the interpreter.
        self.interpreter = Interpreter(show_script=False,
                                       raise_relax_error=True)
        self.interpreter.populate_self()
        self.interpreter.on(verbose=False)
Ejemplo n.º 5
0
    def run(self, save_path=None):
        """Generate the distribution and alignment data.

        @keyword save_path: The path to place the files into.  If set to None, then the current path will be used.
        @type save_path:    None or str
        """

        # The paths to the files.
        self.path = status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'frame_order'+sep+'cam'+sep
        self.save_path = save_path
        if self.save_path == None:
            self.save_path = getcwd()

        # Load the interpreter.
        self.interpreter = Interpreter(show_script=False, raise_relax_error=True)
        self.interpreter.populate_self()
        self.interpreter.on(verbose=False)

        # Set up for the progress meter (commas between the thousands).
        try:
            locale.setlocale(locale.LC_ALL, 'en_US')
        except:
            pass

        # Build the axis system.
        self.build_axes()
        self.print_axis_system()
        self.axes_to_pdb()

        # Set up the system.
        self._multi_system()

        # Set up the data pipe.
        self._pipe_setup()

        # Calculate the RDC data.
        self._calculate_rdc()

        # Calculate the PCS data.
        self._calculate_pcs()

        # Create the distribution of structures.
        if self.DIST_PDB:
            self._create_distribution()

        # Save a state file for debugging.
        if self.SAVE_STATE:
            self.interpreter.state.save('generate_distribution', dir=self.save_path, force=True)
Ejemplo n.º 6
0
    def __init__(self, methodName=None):
        """Set up the test case class for the system tests."""

        # Execute the base __init__ methods.
        super(Test_state, self).__init__(methodName)

        # Load the interpreter.
        self.interpreter = Interpreter(show_script=False,
                                       raise_relax_error=True)
        self.interpreter.populate_self()
        self.interpreter.on(verbose=False)

        # Alias the user function class.
        self.state = self.interpreter.state

        # Alias the user functions to work with the backend.
        self.state.load_state = self.state.load
        self.state.save_state = self.state.save
Ejemplo n.º 7
0
    def __init__(self,
                 pipe_name=None,
                 pipe_bundle=None,
                 results_dir=None,
                 models=[MODEL_R2EFF],
                 grid_inc=11,
                 mc_sim_num=500,
                 exp_mc_sim_num=None,
                 modsel='AIC',
                 pre_run_dir=None,
                 optimise_r2eff=False,
                 insignificance=0.0,
                 numeric_only=False,
                 mc_sim_all_models=False,
                 eliminate=True,
                 set_grid_r20=False,
                 r1_fit=False):
        """Perform a full relaxation dispersion analysis for the given list of models.

        @keyword pipe_name:                 The name of the data pipe containing all of the data for the analysis.
        @type pipe_name:                    str
        @keyword pipe_bundle:               The data pipe bundle to associate all spawned data pipes with.
        @type pipe_bundle:                  str
        @keyword results_dir:               The directory where results files are saved.
        @type results_dir:                  str
        @keyword models:                    The list of relaxation dispersion models to optimise.
        @type models:                       list of str
        @keyword grid_inc:                  Number of grid search increments.  If set to None, then the grid search will be turned off and the default parameter values will be used instead.
        @type grid_inc:                     int or None
        @keyword mc_sim_num:                The number of Monte Carlo simulations to be used for error analysis at the end of the analysis.
        @type mc_sim_num:                   int
        @keyword exp_mc_sim_num:            The number of Monte Carlo simulations for the error analysis in the 'R2eff' model when exponential curves are fitted.  This defaults to the value of the mc_sim_num argument when not given.  When set to '-1', the R2eff errors are estimated from the Covariance matrix.  For the 2-point fixed-time calculation for the 'R2eff' model, this argument is ignored.
        @type exp_mc_sim_num:               int or None
        @keyword modsel:                    The model selection technique to use in the analysis to determine which model is the best for each spin cluster.  This can currently be one of 'AIC', 'AICc', and 'BIC'.
        @type modsel:                       str
        @keyword pre_run_dir:               The optional directory containing the dispersion auto-analysis results from a previous run.  The optimised parameters from these previous results will be used as the starting point for optimisation rather than performing a grid search.  This is essential for when large spin clusters are specified, as a grid search becomes prohibitively expensive with clusters of three or more spins.  At some point a RelaxError will occur because the grid search is impossibly large.  For the cluster specific parameters, i.e. the populations of the states and the exchange parameters, an average value will be used as the starting point.  For all other parameters, the R20 values for each spin and magnetic field, as well as the parameters related to the chemical shift difference dw, the optimised values of the previous run will be directly copied.
        @type pre_run_dir:                  None or str
        @keyword optimise_r2eff:            Flag to specify if the read previous R2eff results should be optimised.  For R1rho models where the error of R2eff values are determined by Monte-Carlo simulations, it can be valuable to make an initial R2eff run with a high number of Monte-Carlo simulations.  Any subsequent model analysis can then be based on these R2eff values, without optimising the R2eff values.
        @type optimise_r2eff:               bool
        @keyword insignificance:            The R2eff/R1rho value in rad/s by which to judge insignificance.  If the maximum difference between two points on all dispersion curves for a spin is less than this value, that spin will be deselected.  This does not affect the 'No Rex' model.  Set this value to 0.0 to use all data.  The value will be passed on to the relax_disp.insignificance user function.
        @type insignificance:               float
        @keyword numeric_only:              The class of models to use in the model selection.  The default of False allows all dispersion models to be used in the analysis (no exchange, the analytic models and the numeric models).  The value of True will activate a pure numeric solution - the analytic models will be optimised, as they are very useful for replacing the grid search for the numeric models, but the final model selection will not include them.
        @type numeric_only:                 bool
        @keyword mc_sim_all_models:         A flag which if True will cause Monte Carlo simulations to be performed for each individual model.  Otherwise Monte Carlo simulations will be reserved for the final model.
        @type mc_sim_all_models:            bool
        @keyword eliminate:                 A flag which if True will enable the elimination of failed models and failed Monte Carlo simulations through the eliminate user function.
        @type eliminate:                    bool
        @keyword set_grid_r20:              A flag which if True will set the grid R20 values from the minimum R2eff values through the r20_from_min_r2eff user function. This will speed up the grid search with a factor GRID_INC^(Nr_spec_freq). For a CPMG experiment with two fields and standard GRID_INC=21, the speed-up is a factor 441.
        @type set_grid_r20:                 bool
        @keyword r1_fit:                    A flag which if True will activate R1 parameter fitting via relax_disp.r1_fit for the models that support it.  If False, then the relax_disp.r1_fit user function will not be called.
        """

        # Initial printout.
        title(file=sys.stdout,
              text="Relaxation dispersion auto-analysis",
              prespace=4)

        # Safely execute the full protocol.
        try:
            # Execution lock.
            status.exec_lock.acquire(pipe_bundle, mode='auto-analysis')

            # Set up the analysis status object.
            status.init_auto_analysis(pipe_bundle, type='relax_disp')
            status.current_analysis = pipe_bundle

            # Store the args.
            self.pipe_name = pipe_name
            self.pipe_bundle = pipe_bundle
            self.results_dir = results_dir
            self.grid_inc = grid_inc
            self.mc_sim_num = mc_sim_num
            self.exp_mc_sim_num = exp_mc_sim_num
            self.models = models
            self.modsel = modsel
            self.pre_run_dir = pre_run_dir
            self.optimise_r2eff = optimise_r2eff
            self.insignificance = insignificance
            self.set_grid_r20 = set_grid_r20
            self.numeric_only = numeric_only
            self.mc_sim_all_models = mc_sim_all_models
            self.eliminate = eliminate
            self.r1_fit = r1_fit

            # No results directory, so default to the current directory.
            if not self.results_dir:
                self.results_dir = getcwd()

            # Data checks.
            self.check_vars()

            # Check for numerical model using numpy version under 1.8.
            # This will result in slow "for loop" calculation through data, making the analysis 5-6 times slower.
            self.check_numpy_less_1_8_and_numerical_model()

            # Load the interpreter.
            self.interpreter = Interpreter(show_script=False,
                                           raise_relax_error=True)
            self.interpreter.populate_self()
            self.interpreter.on(verbose=False)

            # Execute.
            self.run()

        # Clean up.
        finally:
            # Final printout.
            title(file=sys.stdout,
                  text="Completion of the relaxation dispersion auto-analysis",
                  prespace=4)
            print_elapsed_time(time() - status.start_time)

            # Finish and unlock execution.
            status.auto_analysis[self.pipe_bundle].fin = True
            status.current_analysis = None
            status.exec_lock.release()
Ejemplo n.º 8
0
    def __init__(self,
                 stage=1,
                 results_dir=None,
                 num_ens=10000,
                 num_models=10,
                 configs=None,
                 snapshot_dir='snapshots',
                 snapshot_min=None,
                 snapshot_max=None,
                 pseudo=None,
                 noe_file=None,
                 noe_norm=None,
                 rdc_name=None,
                 rdc_file=None,
                 rdc_spin_id1_col=None,
                 rdc_spin_id2_col=None,
                 rdc_data_col=None,
                 rdc_error_col=None,
                 bond_length=None,
                 bond_length_file=None,
                 log=None,
                 bucket_num=200,
                 lower_lim_noe=0.0,
                 upper_lim_noe=600.0,
                 lower_lim_rdc=0.0,
                 upper_lim_rdc=1.0):
        """Set up for the stereochemistry analysis.

        @keyword stage:             Stage of analysis (see the module docstring above for the options).  
        @type stage:                int
        @keyword results_dir:       The optional directory to place all results files into.
        @type results_dir:          None or str
        @keyword num_ens:           Number of ensembles.
        @type num_ens:              int
        @keyword num_models:        Ensemble size.
        @type num_models:           int
        @keyword configs:           All the configurations.
        @type configs:              list of str
        @keyword snapshot_dir:      Snapshot directories (corresponding to the configurations).
        @type snapshot_dir:         list of str
        @keyword snapshot_min:      The number of the first snapshots (corresponding to the configurations).
        @type snapshot_min:         list of int
        @keyword snapshot_max:      The number of the last snapshots (corresponding to the configurations).
        @type snapshot_max:         list of int
        @keyword pseudo:            The list of pseudo-atoms.  Each element is a list of the pseudo-atom name and a list of all those atoms forming the pseudo-atom.  For example, pseudo = [["Q7", ["@H16", "@H17", "@H18"]], ["Q9", ["@H20", "@H21", "@H22"]]].
        @type pseudo:               list of list of str and list of str
        @keyword noe_file:          The name of the NOE restraint file.
        @type noe_file:             str
        @keyword noe_norm:          The NOE normalisation factor (equal to the sum of all NOEs squared).
        @type noe_norm:             float
        @keyword rdc_name:          The label for this RDC data set.
        @type rdc_name:             str
        @keyword rdc_file:          The name of the RDC file.
        @type rdc_file:             str
        @keyword rdc_spin_id1_col:  The spin ID column of the first spin in the RDC file.
        @type rdc_spin_id1_col:     None or int
        @keyword rdc_spin_id2_col:  The spin ID column of the second spin in the RDC file.
        @type rdc_spin_id2_col:     None or int
        @keyword rdc_data_col:      The data column of the RDC file.
        @type rdc_data_col:         int
        @keyword rdc_error_col:     The error column of the RDC file.
        @type rdc_error_col:        int
        @keyword bond_length:       The bond length value in meters.  This overrides the bond_length_file argument.
        @type bond_length:          float or None
        @keyword bond_length_file:  The file of bond lengths for each atom pair in meters.  The first and second columns must be the spin ID strings and the third column must contain the data.
        @type bond_length_file:     float or None
        @keyword log:               Log file output flag (only for certain stages).
        @type log:                  bool
        @keyword bucket_num:        Number of buckets for the distribution plots.
        @type bucket_num:           int
        @keyword lower_lim_noe:     Distribution plot limits.
        @type lower_lim_noe:        int
        @keyword upper_lim_noe:     Distribution plot limits.
        @type upper_lim_noe:        int
        @keyword lower_lim_rdc:     Distribution plot limits.
        @type lower_lim_rdc:        int
        @keyword upper_lim_rdc:     Distribution plot limits.
        @type upper_lim_rdc:        int
        """

        # Initial printout.
        title(file=sys.stdout, text="Stereochemistry auto-analysis")

        # Safely execute the full protocol.
        try:
            # Execution lock.
            status.exec_lock.acquire('auto stereochem analysis',
                                     mode='auto-analysis')

            # Set up the analysis status object.
            status.init_auto_analysis('stereochem', type='stereochem')
            status.current_analysis = 'auto stereochem analysis'

            # Store all the args.
            self.stage = stage
            self.results_dir = results_dir
            self.num_ens = num_ens
            self.num_models = num_models
            self.configs = configs
            self.snapshot_dir = snapshot_dir
            self.snapshot_min = snapshot_min
            self.snapshot_max = snapshot_max
            self.pseudo = pseudo
            self.noe_file = noe_file
            self.noe_norm = noe_norm
            self.rdc_name = rdc_name
            self.rdc_file = rdc_file
            self.rdc_spin_id1_col = rdc_spin_id1_col
            self.rdc_spin_id2_col = rdc_spin_id2_col
            self.rdc_data_col = rdc_data_col
            self.rdc_error_col = rdc_error_col
            self.bond_length = bond_length
            self.bond_length_file = bond_length_file
            self.log = log
            self.bucket_num = bucket_num
            self.lower_lim_noe = lower_lim_noe
            self.upper_lim_noe = upper_lim_noe
            self.lower_lim_rdc = lower_lim_rdc
            self.upper_lim_rdc = upper_lim_rdc

            # Load the interpreter.
            self.interpreter = Interpreter(show_script=False,
                                           raise_relax_error=True)
            self.interpreter.populate_self()
            self.interpreter.on(verbose=False)

            # Create the results directory.
            if self.results_dir:
                mkdir_nofail(self.results_dir)

            # Or use the current working directory.
            else:
                self.results_dir = getcwd()

            # Create a directory for log files.
            if self.log:
                mkdir_nofail(self.results_dir + sep + "logs")

        # Clean up.
        finally:
            # Final printout.
            title(file=sys.stdout,
                  text="Completion of the stereochemistry auto-analysis")
            print_elapsed_time(time() - status.start_time)

            # Finish and unlock execution.
            status.auto_analysis['stereochem'].fin = True
            status.current_analysis = None
            status.exec_lock.release()
Ejemplo n.º 9
0
    def __init__(self,
                 pipe_name=None,
                 pipe_bundle=None,
                 file_root='rx',
                 results_dir=None,
                 grid_inc=11,
                 mc_sim_num=500,
                 view_plots=True):
        """Perform relaxation curve fitting.

        To use this auto-analysis, a data pipe with all the required data needs to be set up.  This data pipe should contain the following:

            - All the spins loaded.
            - Unresolved spins deselected.
            - All the peak intensities loaded and relaxation delay times set.
            - Either the baseplane noise RMSD values should be set or replicated spectra loaded.

        @keyword pipe_name:     The name of the data pipe containing all of the data for the analysis.
        @type pipe_name:        str
        @keyword pipe_bundle:   The data pipe bundle to associate all spawned data pipes with.
        @type pipe_bundle:      str
        @keyword file_root:     File root of the output filea.
        @type file_root:        str
        @keyword results_dir:   The directory where results files are saved.
        @type results_dir:      str
        @keyword grid_inc:      Number of grid search increments.
        @type grid_inc:         int
        @keyword mc_sim_num:    The number of Monte Carlo simulations to be used for error analysis at the end of the analysis.
        @type mc_sim_num:       int
        @keyword view_plots:    Flag to automatically view grace plots after calculation.
        @type view_plots:       bool
        """

        # Initial printout.
        title(file=sys.stdout, text="Relaxation curve-fitting auto-analysis")

        # Safely execute the full protocol.
        try:
            # Execution lock.
            status.exec_lock.acquire(pipe_bundle, mode='auto-analysis')

            # Set up the analysis status object.
            status.init_auto_analysis(pipe_bundle, type='relax_fit')
            status.current_analysis = pipe_bundle

            # Store the args.
            self.pipe_name = pipe_name
            self.pipe_bundle = pipe_bundle
            self.file_root = file_root
            self.results_dir = results_dir
            if self.results_dir:
                self.grace_dir = results_dir + sep + 'grace'
            else:
                self.grace_dir = 'grace'
            self.mc_sim_num = mc_sim_num
            self.grid_inc = grid_inc
            self.view_plots = view_plots

            # Data checks.
            self.check_vars()

            # Set the data pipe to the current data pipe.
            if self.pipe_name != cdp_name():
                switch(self.pipe_name)

            # Load the interpreter.
            self.interpreter = Interpreter(show_script=False,
                                           raise_relax_error=True)
            self.interpreter.populate_self()
            self.interpreter.on(verbose=False)

            # Execute.
            self.run()

        # Clean up.
        finally:
            # Final printout.
            title(
                file=sys.stdout,
                text="Completion of the relaxation curve-fitting auto-analysis"
            )
            print_elapsed_time(time() - status.start_time)

            # Finish and unlock execution.
            status.auto_analysis[self.pipe_bundle].fin = True
            status.current_analysis = None
            status.exec_lock.release()
Ejemplo n.º 10
0
# Module docstring.
"""Functions for the local tm grid optimisation tests."""

# Python module imports.
from math import pi
from os import sep
from re import search

# relax module imports.
from prompt.interpreter import Interpreter
from status import Status

status = Status()

# Initialise the interpreter.
interpreter = Interpreter(show_script=False, raise_relax_error=True)
interpreter.populate_self()
interpreter.on()


def create_sequence(num_res):
    """Generate the required sequence.

    @param num_res:     The total number of residues to create.
    @type num_res:      int
    """

    # Create the molecule.
    interpreter.molecule.create(mol_name='Polycarbonate')

    # Create the spins and residues.
Ejemplo n.º 11
0
# GNU General Public License for more details.                                #
#                                                                             #
# You should have received a copy of the GNU General Public License           #
# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
#                                                                             #
###############################################################################

# Python module imports.
from re import search

# relax module imports.
from prompt.interpreter import Interpreter


# Initialise the interpreter!
interpreter = Interpreter(self)

# Get the names of the data structures.
names = sorted(interpreter._locals.keys())

# Alphabetically sort the names of the data structures.
for name in names:
    # Skip the name if it is in the blacklist.
    blacklist = ['intro_off', 'intro_on', 'pi', 'script']
    if name in blacklist:
        continue

    # Get the object.
    object = interpreter._locals[name]

    # Determine if the structure is user function containing class.
Ejemplo n.º 12
0
Archivo: noe.py Proyecto: tlinnet/relax
    def __init__(self,
                 pipe_name=None,
                 pipe_bundle=None,
                 file_root='noe',
                 results_dir=None,
                 save_state=True):
        """Perform relaxation curve fitting.

        To use this auto-analysis, a data pipe with all the required data needs to be set up.  This data pipe should contain the following:

            - All the spins loaded.
            - Unresolved spins deselected.
            - The NOE peak intensities from the saturated and reference spectra.
            - Either the baseplane noise RMSD values should be set or replicated spectra loaded.

        @keyword pipe_name:     The name of the data pipe containing all of the data for the analysis.
        @type pipe_name:        str
        @keyword pipe_bundle:   The data pipe bundle to associate all spawned data pipes with.
        @type pipe_bundle:      str
        @keyword file_root:     File root of the output filea.
        @type file_root:        str
        @keyword results_dir:   The directory where results files are saved.
        @type results_dir:      str
        @keyword save_state:    A flag which if True will cause a relax save state to be created at the end of the analysis.
        @type save_state:       bool
        """

        # Initial printout.
        title(file=sys.stdout, text="Steady-state NOE auto-analysis")

        # Safely execute the full protocol.
        try:
            # Execution lock.
            status.exec_lock.acquire(pipe_bundle, mode='auto-analysis')

            # Set up the analysis status object.
            status.init_auto_analysis(pipe_bundle, type='noe')
            status.current_analysis = pipe_bundle

            # Store the args.
            self.save_state = save_state
            self.pipe_name = pipe_name
            self.pipe_bundle = pipe_bundle
            self.file_root = file_root
            self.results_dir = results_dir
            if self.results_dir:
                self.grace_dir = results_dir + sep + 'grace'
            else:
                self.grace_dir = 'grace'

            # Data checks.
            self.check_vars()

            # Set the data pipe to the current data pipe.
            if self.pipe_name != cdp_name():
                switch(self.pipe_name)

            # Load the interpreter.
            self.interpreter = Interpreter(show_script=False,
                                           raise_relax_error=True)
            self.interpreter.populate_self()
            self.interpreter.on(verbose=False)

            # Execute.
            self.run()

        # Clean up.
        finally:
            # Final printout.
            title(file=sys.stdout,
                  text="Completion of the steady-state NOE auto-analysis")
            print_elapsed_time(time() - status.start_time)

            # Finish and unlock execution.
            status.auto_analysis[self.pipe_bundle].fin = True
            status.current_analysis = None
            status.exec_lock.release()