Author: bugman Date: Fri Dec 5 21:16:38 2008 New Revision: 8158 URL: http://svn.gna.org/viewcvs/relax?rev=8158&view=rev Log: Merged revisions 8150-8157 via svnmerge from svn+ssh://bugman@xxxxxxxxxxx/svn/relax/1.3 ........ r8152 | semor | 2008-12-05 20:42:50 +0100 (Fri, 05 Dec 2008) | 12 lines Changed the generate_spin_id_data_array() arguments. This follows a post by Ed at: https://mail.gna.org/public/relax-devel/2008-12/msg00032.html (# Message-id: <7f080ed10812051130k7440d48cpf2902ca38dc5786f@xxxxxxxxxxxxxx>) Different arguments had been set in the idea of implementing complete automation for field recognition for the generic file format... This might be implemented at a higher level as discussed in a thread started at : https://mail.gna.org/public/relax-devel/2008-12/msg00029.html (Message-id: <1228504156.9116.6.camel@localhost>) ........ r8154 | bugman | 2008-12-05 20:51:38 +0100 (Fri, 05 Dec 2008) | 3 lines Added a missing RelaxError import. ........ r8155 | bugman | 2008-12-05 21:11:38 +0100 (Fri, 05 Dec 2008) | 3 lines Implemented the interface of the noe.read() user function. ........ r8156 | bugman | 2008-12-05 21:13:15 +0100 (Fri, 05 Dec 2008) | 3 lines Missing import. ........ r8157 | bugman | 2008-12-05 21:14:41 +0100 (Fri, 05 Dec 2008) | 3 lines Fixes for 2 of the noe.read() user function arg unit tests. ........ Modified: branches/multi_processor_merge/ (props changed) branches/multi_processor_merge/generic_fns/spectrum.py branches/multi_processor_merge/prompt/noe.py branches/multi_processor_merge/test_suite/unit_tests/_prompt/test_noe.py Propchange: branches/multi_processor_merge/ ------------------------------------------------------------------------------ --- svnmerge-integrated (original) +++ svnmerge-integrated Fri Dec 5 21:16:38 2008 @@ -1,1 +1,1 @@ -/1.3:1-8149 +/1.3:1-8157 Modified: branches/multi_processor_merge/generic_fns/spectrum.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/generic_fns/spectrum.py?rev=8158&r1=8157&r2=8158&view=diff ============================================================================== --- branches/multi_processor_merge/generic_fns/spectrum.py (original) +++ branches/multi_processor_merge/generic_fns/spectrum.py Fri Dec 5 21:16:38 2008 @@ -468,7 +468,7 @@ print ' ' + `res_num`, h_name, x_name, intensity # Generate the spin identification string. - spin_id = generate_spin_id_data_array(data=line, mol_name_col=None, res_num_col=1, res_name_col=None, spin_num_col=None, spin_name_col=None) + spin_id = generate_spin_id_data_array(data=line, mol_name_col=mol_name_col, res_num_col=res_num_col, res_name_col=res_name_col, spin_num_col=spin_num_col, spin_name_col=spin_name_col) # Return the data. return h_name, x_name, spin_id, intensity Modified: branches/multi_processor_merge/prompt/noe.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/prompt/noe.py?rev=8158&r1=8157&r2=8158&view=diff ============================================================================== --- branches/multi_processor_merge/prompt/noe.py (original) +++ branches/multi_processor_merge/prompt/noe.py Fri Dec 5 21:16:38 2008 @@ -29,7 +29,7 @@ # relax module imports. import help -from relax_errors import RelaxStrError +from relax_errors import RelaxNoneIntError, RelaxNoneStrError, RelaxStrError from specific_fns.setup import noe_obj @@ -44,6 +44,94 @@ # Place relax in the class namespace. self.__relax__ = relax + + + def read(self, file=None, dir=None, proton1_col=None, proton2_col=None, lower_col=None, upper_col=None, sep=None): + """Read NOESY or ROESY constraints from a file. + + Keyword Arguments + ~~~~~~~~~~~~~~~~~ + + file: The name of the file containing the relaxation data. + + dir: The directory where the file is located. + + proton1_col: The column containing the first proton of the NOE or ROE cross peak. + + proton2_col: The column containing the second proton of the NOE or ROE cross peak. + + lower_col: The column containing the lower NOE bound. + + upper_col: The column containing the upper NOE bound. + + sep: The column separator (the default is white space). + + + Description + ~~~~~~~~~~~ + + This function can automatically determine the format of the file, for example Xplor + formatted constraint files. A generically formatted file is also supported if it contains + minimally four columns with the two proton names and the upper and lower bounds, as + specified by the *_col arguments. + + + Examples + ~~~~~~~~ + + To read the Xplor formatted constraint file 'NOE.xpl', type one of: + + relax> noe.read('NOE.xpl') + relax> noe.read(file='NOE.xpl') + + + To read the generic formatted file 'noes', type one of: + + relax> noe.read(file='NOE.xpl', proton1_col=0, proton2_col=1, lower_col=2, upper_col=3) + """ + + # Function intro text. + if self.__relax__.interpreter.intro: + text = sys.ps3 + "noe.read(" + text = text + "file=" + `file` + text = text + ", dir=" + `dir` + text = text + ", proton1_col=" + `proton1_col` + text = text + ", proton2_col=" + `proton2_col` + text = text + ", lower_col=" + `lower_col` + text = text + ", upper_col=" + `upper_col` + text = text + ", sep=" + `sep` + ")" + print text + + # The file name. + if type(file) != str: + raise RelaxStrError, ('file', file) + + # Directory. + if dir != None and type(dir) != str: + raise RelaxNoneStrError, ('directory name', dir) + + # First proton column. + if proton1_col != None and type(proton1_col) != int: + raise RelaxNoneIntError, ('first proton column', proton1_col) + + # Second proton column. + if proton2_col != None and type(proton2_col) != int: + raise RelaxNoneIntError, ('second proton column', proton2_col) + + # Lower bound column. + if lower_col != None and type(lower_col) != int: + raise RelaxNoneIntError, ('lower bound column', lower_col) + + # Upper bound column. + if upper_col != None and type(upper_col) != int: + raise RelaxNoneIntError, ('upper bound column', upper_col) + + # Column separator. + if sep != None and type(sep) != str: + raise RelaxNoneStrError, ('column separator', sep) + + # Execute the functional code. + noe.read(frq=frq, file=file, dir=dir, proton1_col=proton1_col, proton2_col=proton2_col, lower_col=lower_col, upper_col=upper_col, sep=sep) def spectrum_type(self, spectrum_type=None, spectrum_id=None): Modified: branches/multi_processor_merge/test_suite/unit_tests/_prompt/test_noe.py URL: http://svn.gna.org/viewcvs/relax/branches/multi_processor_merge/test_suite/unit_tests/_prompt/test_noe.py?rev=8158&r1=8157&r2=8158&view=diff ============================================================================== --- branches/multi_processor_merge/test_suite/unit_tests/_prompt/test_noe.py (original) +++ branches/multi_processor_merge/test_suite/unit_tests/_prompt/test_noe.py Fri Dec 5 21:16:38 2008 @@ -25,7 +25,7 @@ # relax module imports. from prompt.noe import Noe -from relax_errors import RelaxBoolError, RelaxNoneIntError, RelaxNoneStrError, RelaxStrError +from relax_errors import RelaxBoolError, RelaxIntError, RelaxNoneIntError, RelaxNoneStrError, RelaxStrError # Unit test imports. from data_types import DATA_TYPES @@ -97,11 +97,11 @@ # Loop over the data types. for data in DATA_TYPES: # Catch the int and bin arguments, and skip them. - if data[0] == 'int' or data[0] == 'bin': + if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': continue # The argument test. - self.assertRaises(RelaxIntError, self.noe_fns.read, file='noes', lower_col=data[1]) + self.assertRaises(RelaxNoneIntError, self.noe_fns.read, file='noes', lower_col=data[1]) def test_read_argfail_upper_col(self): @@ -110,11 +110,11 @@ # Loop over the data types. for data in DATA_TYPES: # Catch the int and bin arguments, and skip them. - if data[0] == 'int' or data[0] == 'bin': + if data[0] == 'None' or data[0] == 'int' or data[0] == 'bin': continue # The argument test. - self.assertRaises(RelaxIntError, self.noe_fns.read, file='noes', upper_col=data[1]) + self.assertRaises(RelaxNoneIntError, self.noe_fns.read, file='noes', upper_col=data[1]) def test_read_argfail_sep(self):