Author: bugman Date: Thu Jan 10 11:18:44 2013 New Revision: 18182 URL: http://svn.gna.org/viewcvs/relax?rev=18182&view=rev Log: Fix for bug #20417 (https://gna.org/bugs/?20417). The backwards compatibility hook for the loading of old relax state and results files can now handle the presence of proton spins. The data structures are now correctly converted to the current data pipe design. This is only the case for old files containing PCS data. Modified: trunk/data/__init__.py Modified: trunk/data/__init__.py URL: http://svn.gna.org/viewcvs/relax/trunk/data/__init__.py?rev=18182&r1=18181&r2=18182&view=diff ============================================================================== --- trunk/data/__init__.py (original) +++ trunk/data/__init__.py Thu Jan 10 11:18:44 2013 @@ -1,6 +1,6 @@ ############################################################################### # # -# Copyright (C) 2003-2012 Edward d'Auvergne # +# Copyright (C) 2003-2013 Edward d'Auvergne # # # # This file is part of the program relax (http://www.nmr-relax.com). # # # @@ -212,8 +212,13 @@ # The current spin ID. spin_id = generic_fns.mol_res_spin.generate_spin_id(mol_name=mol.name, res_num=res.num, res_name=res.name, spin_name=spin.name, spin_num=spin.num) - # The interatomic data container design. - if hasattr(spin, 'heteronuc_type'): + # Convert proton spins (the 'heteronuc_type' variable indicates a pre-interatomic container design state). + if hasattr(spin, 'heteronuc_type') and hasattr(spin, 'element') and spin.element == 'H': + # Rename the nuclear isotope. + spin.isotope = spin.proton_type + + # Convert heteronuclear spins (the 'heteronuc_type' variable indicates a pre-interatomic container design state). + elif hasattr(spin, 'heteronuc_type'): # Rename the nuclear isotope. spin.isotope = spin.heteronuc_type @@ -236,13 +241,21 @@ spin_id1 = generic_fns.mol_res_spin.generate_spin_id(mol_name=mol.name, res_num=res.num, res_name=res.name, spin_name=spin.name, spin_num=spin.num) spin_id2 = generic_fns.mol_res_spin.generate_spin_id(mol_name=mol.name, res_num=res.num, res_name=res.name, spin_name=proton_name) - # Create a new spin container for the proton. - h_spin = generic_fns.mol_res_spin.create_spin(mol_name=mol.name, res_num=res.num, res_name=res.name, spin_name=proton_name, pipe=pipe_name) - h_spin.select = False - - # Set up a dipole interaction between the two spins. - generic_fns.mol_res_spin.set_spin_element(spin_id=spin_id2, element='H', pipe=pipe_name) - generic_fns.mol_res_spin.set_spin_isotope(spin_id=spin_id2, isotope='1H', pipe=pipe_name) + # Fetch the proton spin if it exists. + h_spin = generic_fns.mol_res_spin.return_spin(spin_id2, pipe=pipe_name) + if h_spin: + spin_id2 = generic_fns.mol_res_spin.generate_spin_id(mol_name=mol.name, res_num=res.num, res_name=res.name, spin_name=proton_name, spin_num=h_spin.num) + + # Create a new spin container for the proton if needed. + if not h_spin: + h_spin = generic_fns.mol_res_spin.create_spin(mol_name=mol.name, res_num=res.num, res_name=res.name, spin_name=proton_name, pipe=pipe_name) + h_spin.select = False + + # Set up a dipole interaction between the two spins if needed. + if not hasattr(h_spin, 'element'): + generic_fns.mol_res_spin.set_spin_element(spin_id=spin_id2, element='H', pipe=pipe_name) + if not hasattr(h_spin, 'isotope'): + generic_fns.mol_res_spin.set_spin_isotope(spin_id=spin_id2, isotope='1H', pipe=pipe_name) generic_fns.dipole_pair.define(spin_id1, spin_id2, verbose=False, pipe=pipe_name) # Get the interatomic data container.