Author: bugman Date: Thu Nov 6 11:06:42 2008 New Revision: 7970 URL: http://svn.gna.org/viewcvs/relax?rev=7970&view=rev Log: Merged revisions 7942-7948,7952,7961-7963,7965-7968 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r7942 | bugman | 2008-10-23 16:44:53 +0200 (Thu, 23 Oct 2008) | 6 lines Fix for the relax IO logging with the -l command line argument. This is a partial fix for bug #12489 (https://gna.org/bugs/?12489). The teeing problem still has to be fixed. ........ r7943 | bugman | 2008-10-23 16:54:43 +0200 (Thu, 23 Oct 2008) | 3 lines Converted the tee class method into a module function. ........ r7944 | bugman | 2008-10-23 16:56:12 +0200 (Thu, 23 Oct 2008) | 3 lines Epydoc'd the tee function docstring. ........ r7945 | bugman | 2008-10-23 16:57:45 +0200 (Thu, 23 Oct 2008) | 3 lines Docstring improvements for the log() function. ........ r7946 | bugman | 2008-10-23 16:58:04 +0200 (Thu, 23 Oct 2008) | 3 lines Removed a line of redundant code. ........ r7947 | bugman | 2008-10-23 16:58:56 +0200 (Thu, 23 Oct 2008) | 3 lines Added the missing import of relax_io.tee. ........ r7948 | bugman | 2008-10-23 17:01:18 +0200 (Thu, 23 Oct 2008) | 5 lines Final fixes for bug #12489 (https://gna.org/bugs/?12489). The log() and tee() functions are now operational. ........ r7952 | bugman | 2008-10-23 17:39:25 +0200 (Thu, 23 Oct 2008) | 9 lines Fix for bug #12487 (https://gna.org/bugs/index.php?12487). This bug was reported by Tyler Reddy (TREDDY at dal dot ca). The problem was that missing XH bond vector data was being manifested as the spin.xh_vect object being set to None. The overfit_deselect() function which is responsible for deselecting unsuitable spins prior to optimisation was only checking if the object existed, not if it was None! ........ r7961 | bugman | 2008-10-24 13:44:28 +0200 (Fri, 24 Oct 2008) | 3 lines Added a check to the atom_loop() to make sure structural data is loaded. ........ r7962 | bugman | 2008-10-24 13:56:38 +0200 (Fri, 24 Oct 2008) | 3 lines Added a check for empty PDB files in the internal structural object. ........ r7963 | bugman | 2008-10-24 14:22:44 +0200 (Fri, 24 Oct 2008) | 3 lines Added another spin to try to catch a program bug (unsuccessfully). ........ r7965 | semor | 2008-10-24 15:41:46 +0200 (Fri, 24 Oct 2008) | 5 lines Introduced verifications for the '-t' and '-l' options not to erase the python script used. This should fix bug 12498 (http://gna.org/bugs/?12498). ........ r7966 | bugman | 2008-10-24 16:14:19 +0200 (Fri, 24 Oct 2008) | 3 lines Created a system test using Tyler Reddy's bug report - bug #12487 (https://gna.org/bugs/?12487). ........ r7967 | semor | 2008-10-24 16:19:17 +0200 (Fri, 24 Oct 2008) | 7 lines Modified the '-l' and '-t' options so they check for an existing file and don't overwrite it. This was proposed by Edward in a post at: https://mail.gna.org/public/relax-devel/2008-10/msg00087.html (Message ID: 7f080ed10810240648p19b83da1x4c8990acf1834c5b@xxxxxxxxxxxxxx) ........ r7968 | semor | 2008-10-24 17:55:21 +0200 (Fri, 24 Oct 2008) | 7 lines Still improved the detection of existing files not to be overwritten when logging or teeing. This follows a post by Edward at: https://mail.gna.org/public/relax-devel/2008-10/msg00091.html (Message ID: 7f080ed10810240816o30acc1ddlbaa131bc5a9ea1ff@xxxxxxxxxxxxxx) ........ Added: branches/multi_processor_merge/test_suite/shared_data/results_files/tylers_peptide_trunc.bz2 - copied unchanged from r7968, 1.3/test_suite/shared_data/results_files/tylers_peptide_trunc.bz2 branches/multi_processor_merge/test_suite/shared_data/structures/tylers_peptide_trunc.pdb - copied unchanged from r7968, 1.3/test_suite/shared_data/structures/tylers_peptide_trunc.pdb branches/multi_processor_merge/test_suite/system_tests/scripts/tylers_peptide.py - copied unchanged from r7968, 1.3/test_suite/system_tests/scripts/tylers_peptide.py Modified: branches/multi_processor_merge/ (props changed) branches/multi_processor_merge/generic_fns/structure/internal.py branches/multi_processor_merge/relax branches/multi_processor_merge/relax_io.py branches/multi_processor_merge/specific_fns/model_free/main.py branches/multi_processor_merge/test_suite/system_tests/model_free.py branches/multi_processor_merge/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py Propchange: branches/multi_processor_merge/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Thu Nov 6 11:06:42 2008 @@ -1,1 +1,1 @@ -/1.3:1-7940 +/1.3:1-7969 Modified: branches/multi_processor_merge/generic_fns/structure/internal.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/generic_fns/structure/internal.py?rev=7970&r1=7969&r2=7970&view=diff ============================================================================== --- branches/multi_processor_merge/generic_fns/structure/internal.py (original) +++ branches/multi_processor_merge/generic_fns/structure/internal.py Thu Nov 6 11:06:42 2008 @@ -35,7 +35,7 @@ from api_base import Base_struct_API from generic_fns import pipes, relax_re from generic_fns.mol_res_spin import Selection -from relax_errors import RelaxError +from relax_errors import RelaxError, RelaxNoPdbError from relax_io import open_read_file from relax_warnings import RelaxWarning @@ -321,6 +321,10 @@ file = open_read_file(file_path) lines = file.readlines() file.close() + + # Check for empty files. + if lines == []: + raise RelaxError, "The PDB file is empty." # Init. model = None @@ -645,6 +649,10 @@ element name (str), and atomic position (array of len 3). """ + # Check that the structure is loaded. + if not len(self.structural_data): + raise RelaxNoPdbError + # Generate the selection object. sel_obj = Selection(atom_id) Modified: branches/multi_processor_merge/relax URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/relax?rev=7970&r1=7969&r2=7970&view=diff ============================================================================== --- branches/multi_processor_merge/relax (original) +++ branches/multi_processor_merge/relax Thu Nov 6 11:06:42 2008 @@ -53,7 +53,7 @@ from prompt.gpl import gpl from prompt import interpreter import relax_errors -from relax_io import log +from relax_io import log, tee import relax_warnings from test_suite.test_suite_runner import Test_suite_runner import version @@ -206,6 +206,10 @@ # The log file. self.log_file = options.log + + # Fail if the file already exists. + if access(log_file, F_OK): + parser.error("the log file " + `log_file` + " already exists") else: self.log_file = None @@ -217,6 +221,10 @@ # The tee file. self.tee_file = options.tee + + # Fail if the file already exists. + if access(tee_file, F_OK): + parser.error("the tee file " + `tee_file` + " already exists") else: self.tee_file = None Modified: branches/multi_processor_merge/relax_io.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/relax_io.py?rev=7970&r1=7969&r2=7970&view=diff ============================================================================== --- branches/multi_processor_merge/relax_io.py (original) +++ branches/multi_processor_merge/relax_io.py Thu Nov 6 11:06:42 2008 @@ -170,7 +170,7 @@ def log(file_name=None, dir=None, verbosity=1): - """Function for turning logging on. + """Turn on logging, sending both STDOUT and STDERR streams to a file. @param file_name: The name of the file to extract the data from. @type file_name: str @@ -184,6 +184,11 @@ # Log file. log_file, file_path = open_write_file(file_name=file_name, dir=dir, force=True, verbosity=verbosity, return_path=True) + # Logging IO streams. + log_stdin = stdin + log_stdout = None + log_stderr = SplitIO() + # Print out. if verbosity: print "Redirecting the sys.stdin IO stream to the python stdin IO stream." @@ -192,7 +197,7 @@ # Set the logging IO streams. log_stdout = log_file - log_stderr.split(python_stderr, log_file) + log_stderr.split(stderr, log_file) # IO stream redirection. sys.stdin = log_stdin @@ -399,6 +404,45 @@ return new +def tee(file_name=None, dir=None, compress_type=0, verbosity=1): + """Turn on teeing to split both STDOUT and STDERR streams and sending second part to a file. + + @param file_name: The name of the file to extract the data from. + @type file_name: str + @param dir: The path where the file is located. If None, then the current directory + is assumed. + @type dir: str + @param compress_type: The compression type. The integer values correspond to the compression + type: 0, no compression; 1, Bzip2 compression; 2, Gzip compression. + @type compress_type: int + @param verbosity: The verbosity level. + @type verbosity: int + """ + + # Tee file. + tee_file, file_path = open_write_file(file_name=file_name, dir=dir, force=True, compress_type=compress_type, verbosity=verbosity, return_path=1) + + # Tee IO streams. + tee_stdin = stdin + tee_stdout = SplitIO() + tee_stderr = SplitIO() + + # Print out. + if verbosity: + print "Redirecting the sys.stdin IO stream to the python stdin IO stream." + print "Redirecting the sys.stdout IO stream to both the python stdout IO stream and the log file '%s'." % file_path + print "Redirecting the sys.stderr IO stream to both the python stderr IO stream and the log file '%s'." % file_path + + # Set the tee IO streams. + tee_stdout.split(stdout, tee_file) + tee_stderr.split(stderr, tee_file) + + # IO stream redirection. + sys.stdin = tee_stdin + sys.stdout = tee_stdout + sys.stderr = tee_stderr + + def test_binary(binary): """Function for testing that the binary string corresponds to a valid executable file. @@ -576,28 +620,6 @@ sys.stderr = self.python_stderr - def tee(self, file_name=None, dir=None, compress_type=0, verbosity=1): - """Function for turning logging on.""" - - # Tee file. - self.tee_file, file_path = self.open_write_file(file_name=file_name, dir=dir, force=True, compress_type=compress_type, verbosity=verbosity, return_path=1) - - # Print out. - if verbosity: - print "Redirecting the sys.stdin IO stream to the python stdin IO stream." - print "Redirecting the sys.stdout IO stream to both the python stdout IO stream and the log file '%s'." % file_path - print "Redirecting the sys.stderr IO stream to both the python stderr IO stream and the log file '%s'." % file_path - - # Set the tee IO streams. - self.tee_stdout.split(self.python_stdout, self.tee_file) - self.tee_stderr.split(self.python_stderr, self.tee_file) - - # IO stream redirection. - sys.stdin = self.tee_stdin - sys.stdout = self.tee_stdout - sys.stderr = self.tee_stderr - - class SplitIO: def __init__(self): """Class for splitting an IO stream to two outputs.""" Modified: branches/multi_processor_merge/specific_fns/model_free/main.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/specific_fns/model_free/main.py?rev=7970&r1=7969&r2=7970&view=diff ============================================================================== --- branches/multi_processor_merge/specific_fns/model_free/main.py (original) +++ branches/multi_processor_merge/specific_fns/model_free/main.py Thu Nov 6 11:06:42 2008 @@ -1969,6 +1969,8 @@ # Test for structural data if required. elif need_vect and not hasattr(spin, 'xh_vect'): + spin.select = False + elif need_vect and spin.xh_vect == None: spin.select = False Modified: branches/multi_processor_merge/test_suite/system_tests/model_free.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/test_suite/system_tests/model_free.py?rev=7970&r1=7969&r2=7970&view=diff ============================================================================== --- branches/multi_processor_merge/test_suite/system_tests/model_free.py (original) +++ branches/multi_processor_merge/test_suite/system_tests/model_free.py Thu Nov 6 11:06:42 2008 @@ -989,6 +989,13 @@ self.assertEqual(cdp.mol[0].res[1].spin[0].r, NH_BOND_LENGTH) + def test_tylers_peptide(self): + """Try a component of model-free analysis on Tyler Reddy's peptide data (truncated).""" + + # Execute the script. + self.relax.interpreter.run(script_file=sys.path[-1] + '/test_suite/system_tests/scripts/tylers_peptide.py') + + def test_write_results(self): """Writing of model-free results using the user function results.write().""" Modified: branches/multi_processor_merge/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py?rev=7970&r1=7969&r2=7970&view=diff ============================================================================== --- branches/multi_processor_merge/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py (original) +++ branches/multi_processor_merge/test_suite/unit_tests/_generic_fns/test_mol_res_spin.py Thu Nov 6 11:06:42 2008 @@ -67,6 +67,7 @@ cdp.mol[1].res[1].spin[0].name = 'C8' cdp.mol[1].res[0].spin.add_item(spin_name='N5') cdp.mol[1].res[1].spin.add_item(spin_name='N5') + cdp.mol[1].res[1].spin.add_item(spin_name='2H', spin_num=132) # Deselect a number of spins. cdp.mol[0].res[0].spin[0].select = 0 @@ -487,8 +488,8 @@ """ # Test the number of spins counted. - self.assertEqual(mol_res_spin.count_spins(), 3) - self.assertEqual(mol_res_spin.count_spins(skip_desel=False), 7) + self.assertEqual(mol_res_spin.count_spins(), 4) + self.assertEqual(mol_res_spin.count_spins(skip_desel=False), 8) self.assertEqual(mol_res_spin.count_spins(selection='@N5'), 1) self.assertEqual(mol_res_spin.count_spins(selection='@N5', skip_desel=False), 2) @@ -1194,6 +1195,7 @@ spin2 = mol_res_spin.return_spin(selection=':2&:Glu') spin3 = mol_res_spin.return_spin(selection=':4&:Pro', pipe='orig') spin4 = mol_res_spin.return_spin(selection='#RNA:-5@N5', pipe='orig') + spin5 = mol_res_spin.return_spin(selection=':-4@2H', pipe='orig') # Test the data of spin 1. self.assertNotEqual(spin1, None) @@ -1214,6 +1216,11 @@ self.assertNotEqual(spin4, None) self.assertEqual(spin4.num, None) self.assertEqual(spin4.name, 'N5') + + # Test the data of the RNA res -4, spin 2H. + self.assertNotEqual(spin5, None) + self.assertEqual(spin5.num, 132) + self.assertEqual(spin5.name, '2H') def test_return_spin_pipe_fail(self): @@ -1347,8 +1354,8 @@ """ # Spin data. - select = [0, 1, 0, 0, 1, 1, 0] - name = ['NH', 'NH', None, 'C8', 'N5', 'C8', 'N5'] + select = [0, 1, 0, 0, 1, 1, 0, 1] + name = ['NH', 'NH', None, 'C8', 'N5', 'C8', 'N5', '2H'] # Loop over the spins. i = 0 @@ -1363,7 +1370,7 @@ i = i + 1 # Test loop length. - self.assertEqual(i, 7) + self.assertEqual(i, 8) def test_spin_loop_single_spin(self):