mailRe: r25603 - /trunk/lib/spectrum/nmrpipe.py


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on September 04, 2014 - 11:06:
Hi Troels,

This also looks good, but needs a whitespace fix for the '=' sign.
For the RelaxError, I would also capitalise the P in Python, as Python
is always with a capitial P and this is the start of a sentence.  It
is also better to use a single sentence for the RelaxError when
possible:

RelaxError:  Python module 'subprocess' not found, cannot call showApod.

I would suggest also changing the logic at the start to be:

"""
if not dep_check.subprocess_module:
    raise RelaxError("Python...
"""

Then you don't need to indent the rest and the code is hence simpler.
You could also add a check of 'if not dep_check.showApod:" to give a
RelaxError when showApod is not available.

Cheers,

Edward


On 3 September 2014 22:50,  <tlinnet@xxxxxxxxxxxxx> wrote:
Author: tlinnet
Date: Wed Sep  3 22:50:33 2014
New Revision: 25603

URL: http://svn.gna.org/viewcvs/relax?rev=25603&view=rev
Log:
To the lib function of spectrum.nmrpipe, added function to call the NMRPipe 
program showApod, to get the output from the program.

Modified:
    trunk/lib/spectrum/nmrpipe.py

Modified: trunk/lib/spectrum/nmrpipe.py
URL: 
http://svn.gna.org/viewcvs/relax/trunk/lib/spectrum/nmrpipe.py?rev=25603&r1=25602&r2=25603&view=diff
==============================================================================
--- trunk/lib/spectrum/nmrpipe.py       (original)
+++ trunk/lib/spectrum/nmrpipe.py       Wed Sep  3 22:50:33 2014
@@ -28,8 +28,14 @@
 from warnings import warn

 # relax module imports.
+import dep_check
 from lib.errors import RelaxError
+from lib.io import get_file_path
 from lib.warnings import RelaxWarning
+
+# Check subprocess is available.
+if dep_check.subprocess_module:
+    import subprocess


 def read_seriestab(peak_list=None, file_data=None, int_col=None):
@@ -185,3 +191,35 @@

         # Add the assignment to the peak list object.
         peak_list.add(res_nums=[res_num1, res_num2], res_names=[res_name1, 
res_name2], spin_names=[name1, name2], shifts=[w1, w2], 
intensity=intensities, intensity_name=spectra)
+
+
+def show_apod_extract(file_name=None, dir=None, 
path_to_command='showApod'):
+    """Extract showApod information for spectrum fourier transformed with 
NMRPipe.
+
+    @keyword file:              The filename of the NMRPipe fourier 
transformed file.
+    @type file:                 str
+    @keyword dir:               The directory where the file is located.
+    @type dir:                  str
+    @keyword path_to_command:   If showApod not in PATH, then specify 
absolute path as: /path/to/showApod
+    @type dir:                  str
+    @return:                    The output from showApod as list of lines.
+    @rtype:                     list of lines
+    """
+
+    # Get the file path.
+    file_path = get_file_path(file_name=file_name, dir=dir)
+
+    if dep_check.subprocess_module:
+        # Call function.
+        Temp=subprocess.Popen([path_to_command, file_path], 
stdout=subprocess.PIPE)
+
+        # Communicate with program, and get outout and exitcode.
+        (output, errput) = Temp.communicate()
+
+        # Wait for finish and get return code.
+        return_value = Temp.wait()
+
+        return output.splitlines()
+
+    else:
+        raise RelaxError("python module 'subprocess' not found.  Cannot 
call showApod.")


_______________________________________________
relax (http://www.nmr-relax.com)

This is the relax-commits mailing list
relax-commits@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-commits



Related Messages


Powered by MHonArc, Updated Fri Sep 12 15:00:12 2014