Example #1
0
    def test_read_sparky(self):
        """The Sparky peak height loading test."""

        # Load the original state.
        self.interpreter.state.load(state='basic_heights_T2_ncyc1', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states', force=True)

        # Create a new data pipe for the new data.
        self.interpreter.pipe.create('new', 'relax_fit')

        # Load the Lupin Ap4Aase sequence.
        self.interpreter.sequence.read(file="Ap4Aase.seq", dir=status.install_path + sep+'test_suite'+sep+'shared_data', res_num_col=1, res_name_col=2)

        # Name the spins so they can be matched to the assignments.
        self.interpreter.spin.name(name='N')

        # Read the peak heights.
        self.interpreter.spectrum.read_intensities(file="T2_ncyc1_ave.list", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'curve_fitting', spectrum_id='0.0176')


        # Test the integrity of the data.
        #################################

        # Get the data pipes.
        dp_new = pipes.get_pipe('new')
        dp_rx = pipes.get_pipe('rx')

        # Loop over the spins of the original data.
        for mol_index, res_index, spin_index in spin_index_loop():
            # Alias the spin containers.
            new_spin = dp_new.mol[mol_index].res[res_index].spin[spin_index]
            orig_spin = dp_rx.mol[mol_index].res[res_index].spin[spin_index]

            # Check the sequence info.
            self.assertEqual(dp_new.mol[mol_index].name, dp_rx.mol[mol_index].name)
            self.assertEqual(dp_new.mol[mol_index].res[res_index].num, dp_rx.mol[mol_index].res[res_index].num)
            self.assertEqual(dp_new.mol[mol_index].res[res_index].name, dp_rx.mol[mol_index].res[res_index].name)
            self.assertEqual(new_spin.num, orig_spin.num)
            self.assertEqual(new_spin.name, orig_spin.name)

            # Skip deselected spins.
            if not orig_spin.select:
                continue

            # Check intensities (if they exist).
            if hasattr(orig_spin, 'peak_intensity'):
                for id in dp_new.spectrum_ids:
                    self.assertEqual(orig_spin.peak_intensity[id], new_spin.peak_intensity[id])
Example #2
0
    def test_read_sparky(self):
        """The Sparky peak height loading test."""

        # Load the original state.
        self.interpreter.state.load(state='basic_heights_T2_ncyc1', dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'saved_states', force=True)

        # Create a new data pipe for the new data.
        self.interpreter.pipe.create('new', 'relax_fit')

        # Load the Lupin Ap4Aase sequence.
        self.interpreter.sequence.read(file="Ap4Aase.seq", dir=status.install_path + sep+'test_suite'+sep+'shared_data', res_num_col=1, res_name_col=2)

        # Name the spins so they can be matched to the assignments.
        self.interpreter.spin.name(name='N')

        # Read the peak heights.
        self.interpreter.spectrum.read_intensities(file="T2_ncyc1_ave.list", dir=status.install_path + sep+'test_suite'+sep+'shared_data'+sep+'curve_fitting', spectrum_id='0.0176')


        # Test the integrity of the data.
        #################################

        # Get the data pipes.
        dp_new = pipes.get_pipe('new')
        dp_rx = pipes.get_pipe('rx')

        # Loop over the spins of the original data.
        for mol_index, res_index, spin_index in spin_index_loop():
            # Alias the spin containers.
            new_spin = dp_new.mol[mol_index].res[res_index].spin[spin_index]
            orig_spin = dp_rx.mol[mol_index].res[res_index].spin[spin_index]

            # Check the sequence info.
            self.assertEqual(dp_new.mol[mol_index].name, dp_rx.mol[mol_index].name)
            self.assertEqual(dp_new.mol[mol_index].res[res_index].num, dp_rx.mol[mol_index].res[res_index].num)
            self.assertEqual(dp_new.mol[mol_index].res[res_index].name, dp_rx.mol[mol_index].res[res_index].name)
            self.assertEqual(new_spin.num, orig_spin.num)
            self.assertEqual(new_spin.name, orig_spin.name)

            # Skip deselected spins.
            if not orig_spin.select:
                continue

            # Check intensities (if they exist).
            if hasattr(orig_spin, 'peak_intensity'):
                for id in dp_new.spectrum_ids:
                    self.assertEqual(orig_spin.peak_intensity[id], new_spin.peak_intensity[id])
Example #3
0
def copy(pipe_from=None, pipe_to=None, ri_id=None):
    """Copy the relaxation data from one data pipe to another.

    @keyword pipe_from: The data pipe to copy the relaxation data from.  This defaults to the current data pipe.
    @type pipe_from:    str
    @keyword pipe_to:   The data pipe to copy the relaxation data to.  This defaults to the current data pipe.
    @type pipe_to:      str
    @param ri_id:       The relaxation data ID string.
    @type ri_id:        str
    """

    # Defaults.
    if pipe_from == None and pipe_to == None:
        raise RelaxError(
            "The pipe_from and pipe_to arguments cannot both be set to None.")
    elif pipe_from == None:
        pipe_from = pipes.cdp_name()
    elif pipe_to == None:
        pipe_to = pipes.cdp_name()

    # Test if the pipe_from and pipe_to data pipes exist.
    check_pipe(pipe_from)
    check_pipe(pipe_to)

    # Get the data pipes.
    dp_from = pipes.get_pipe(pipe_from)
    dp_to = pipes.get_pipe(pipe_to)

    # Test if pipe_from contains sequence data.
    if not exists_mol_res_spin_data(pipe_from):
        raise RelaxNoSequenceError

    # Test if pipe_to contains sequence data.
    if not exists_mol_res_spin_data(pipe_to):
        raise RelaxNoSequenceError

    # Test if relaxation data ID string exists for pipe_from.
    if ri_id and (not hasattr(dp_from, 'ri_ids')
                  or ri_id not in dp_from.ri_ids):
        raise RelaxNoRiError(ri_id)

    # The IDs.
    if ri_id == None:
        ri_ids = dp_from.ri_ids
    else:
        ri_ids = [ri_id]

    # Init target pipe global structures.
    if not hasattr(dp_to, 'ri_ids'):
        dp_to.ri_ids = []
    if not hasattr(dp_to, 'ri_type'):
        dp_to.ri_type = {}

    # Loop over the Rx IDs.
    for ri_id in ri_ids:
        # Test if relaxation data ID string exists for pipe_to.
        if ri_id in dp_to.ri_ids:
            raise RelaxRiError(ri_id)

        # Copy the global data.
        dp_to.ri_ids.append(ri_id)
        dp_to.ri_type[ri_id] = dp_from.ri_type[ri_id]

        # Copy the frequency information.
        copy_frequencies(pipe_from=pipe_from, pipe_to=pipe_to, id=ri_id)

        # Spin loop.
        for mol_index, res_index, spin_index in spin_index_loop():
            # Alias the spin containers.
            spin_from = dp_from.mol[mol_index].res[res_index].spin[spin_index]
            spin_to = dp_to.mol[mol_index].res[res_index].spin[spin_index]

            # No data or errors.
            if not hasattr(spin_from, 'ri_data') and not hasattr(
                    spin_from, 'ri_data_err'):
                continue

            # Initialise the spin data if necessary.
            if not hasattr(spin_to, 'ri_data'):
                spin_to.ri_data = {}
            if not hasattr(spin_to, 'ri_data_err'):
                spin_to.ri_data_err = {}

            # Copy the value and error from pipe_from.
            spin_to.ri_data[ri_id] = spin_from.ri_data[ri_id]
            spin_to.ri_data_err[ri_id] = spin_from.ri_data_err[ri_id]
Example #4
0
def copy(pipe_from=None, pipe_to=None, ri_id=None):
    """Copy the relaxation data from one data pipe to another.

    @keyword pipe_from: The data pipe to copy the relaxation data from.  This defaults to the current data pipe.
    @type pipe_from:    str
    @keyword pipe_to:   The data pipe to copy the relaxation data to.  This defaults to the current data pipe.
    @type pipe_to:      str
    @param ri_id:       The relaxation data ID string.
    @type ri_id:        str
    """

    # Defaults.
    if pipe_from == None and pipe_to == None:
        raise RelaxError("The pipe_from and pipe_to arguments cannot both be set to None.")
    elif pipe_from == None:
        pipe_from = pipes.cdp_name()
    elif pipe_to == None:
        pipe_to = pipes.cdp_name()

    # Test if the pipe_from and pipe_to data pipes exist.
    pipes.test(pipe_from)
    pipes.test(pipe_to)

    # Get the data pipes.
    dp_from = pipes.get_pipe(pipe_from)
    dp_to = pipes.get_pipe(pipe_to)

    # Test if pipe_from contains sequence data.
    if not exists_mol_res_spin_data(pipe_from):
        raise RelaxNoSequenceError

    # Test if pipe_to contains sequence data.
    if not exists_mol_res_spin_data(pipe_to):
        raise RelaxNoSequenceError

    # Test if relaxation data ID string exists for pipe_from.
    if ri_id and (not hasattr(dp_from, 'ri_ids') or ri_id not in dp_from.ri_ids):
        raise RelaxNoRiError(ri_id)

    # The IDs.
    if ri_id == None:
        ri_ids = dp_from.ri_ids
    else:
        ri_ids = [ri_id]

    # Init target pipe global structures.
    if not hasattr(dp_to, 'ri_ids'):
        dp_to.ri_ids = []
    if not hasattr(dp_to, 'ri_type'):
        dp_to.ri_type = {}

    # Loop over the Rx IDs.
    for ri_id in ri_ids:
        # Test if relaxation data ID string exists for pipe_to.
        if ri_id in dp_to.ri_ids:
            raise RelaxRiError(ri_id)

        # Copy the global data.
        dp_to.ri_ids.append(ri_id)
        dp_to.ri_type[ri_id] = dp_from.ri_type[ri_id]

        # Copy the frequency information.
        copy_frequencies(pipe_from=pipe_from, pipe_to=pipe_to, id=ri_id)

        # Spin loop.
        for mol_index, res_index, spin_index in spin_index_loop():
            # Alias the spin containers.
            spin_from = dp_from.mol[mol_index].res[res_index].spin[spin_index]
            spin_to = dp_to.mol[mol_index].res[res_index].spin[spin_index]

            # No data or errors.
            if not hasattr(spin_from, 'ri_data') and not hasattr(spin_from, 'ri_data_err'):
                continue

            # Initialise the spin data if necessary.
            if not hasattr(spin_to, 'ri_data'):
                spin_to.ri_data = {}
            if not hasattr(spin_to, 'ri_data_err'):
                spin_to.ri_data_err = {}

            # Copy the value and error from pipe_from.
            spin_to.ri_data[ri_id] = spin_from.ri_data[ri_id]
            spin_to.ri_data_err[ri_id] = spin_from.ri_data_err[ri_id]
Example #5
0
def copy(pipe_from=None, pipe_to=None, align_id=None):
    """Copy the PCS data from one data pipe to another.

    @keyword pipe_from: The data pipe to copy the PCS data from.  This defaults to the current data pipe.
    @type pipe_from:    str
    @keyword pipe_to:   The data pipe to copy the PCS data to.  This defaults to the current data pipe.
    @type pipe_to:      str
    @param align_id:    The alignment ID string.
    @type align_id:     str
    """

    # Defaults.
    if pipe_from == None and pipe_to == None:
        raise RelaxError("The pipe_from and pipe_to arguments cannot both be set to None.")
    elif pipe_from == None:
        pipe_from = pipes.cdp_name()
    elif pipe_to == None:
        pipe_to = pipes.cdp_name()

    # Check the pipe setup.
    check_pipe_setup(pipe=pipe_from, pcs_id=align_id, sequence=True, pcs=True)
    check_pipe_setup(pipe=pipe_to, sequence=True)

    # Get the data pipes.
    dp_from = pipes.get_pipe(pipe_from)
    dp_to = pipes.get_pipe(pipe_to)

    # The IDs.
    if align_id == None:
        align_ids = dp_from.align_ids
    else:
        align_ids = [align_id]

    # Init target pipe global structures.
    if not hasattr(dp_to, 'align_ids'):
        dp_to.align_ids = []
    if not hasattr(dp_to, 'pcs_ids'):
        dp_to.pcs_ids = []

    # Loop over the align IDs.
    for align_id in align_ids:
        # Copy the global data.
        if align_id not in dp_to.align_ids and align_id not in dp_to.align_ids:
            dp_to.align_ids.append(align_id)
        if align_id in dp_from.pcs_ids and align_id not in dp_to.pcs_ids:
            dp_to.pcs_ids.append(align_id)

        # Spin loop.
        for mol_index, res_index, spin_index in spin_index_loop():
            # Alias the spin containers.
            spin_from = dp_from.mol[mol_index].res[res_index].spin[spin_index]
            spin_to = dp_to.mol[mol_index].res[res_index].spin[spin_index]

            # No data or errors.
            if (not hasattr(spin_from, 'pcs') or not align_id in spin_from.pcs) and (not hasattr(spin_from, 'pcs_err') or not align_id in spin_from.pcs_err):
                continue

            # Initialise the spin data if necessary.
            if hasattr(spin_from, 'pcs') and not hasattr(spin_to, 'pcs'):
                spin_to.pcs = {}
            if hasattr(spin_from, 'pcs_err') and not hasattr(spin_to, 'pcs_err'):
                spin_to.pcs_err = {}

            # Copy the value and error from pipe_from.
            if hasattr(spin_from, 'pcs'):
                spin_to.pcs[align_id] = spin_from.pcs[align_id]
            if hasattr(spin_from, 'pcs_err'):
                spin_to.pcs_err[align_id] = spin_from.pcs_err[align_id]