1

Topic: Automatically import bruker spectra on linux

mMass imports bruker spectra automatically when compassxport is installed. Unfortunately this functionality isn't available on linux. Since compassxport works perfectly via wine, the conversion can be done automatically

Quick guide
1. install compassxport (do not modify default installation location)
2. install vc runtime 2008 (winetricks vcrun2008)
3. Put mfc90.dll and vcomp90.dll near Compassxport.exe
4. apply this patch (Note: python 2.7+ is required)

diff -ru mMass/gui/dlg_preferences.py mMass_lin/gui/dlg_preferences.py
--- mMass/gui/dlg_preferences.py    2013-06-30 14:23:36.000000000 +0400
+++ mMass_lin/gui/dlg_preferences.py    2014-11-01 20:07:27.704541770 +0300
@@ -54,8 +54,7 @@
         self.notebook = wx.Notebook(self, -1)
         
         # add pages
-        if wx.Platform == '__WXMSW__':
-            self.notebook.AddPage(self.makeCompassPanel(), 'CompassXport')
+        self.notebook.AddPage(self.makeCompassPanel(), 'CompassXport')
         self.notebook.AddPage(self.makeUpdatesPage(), 'Software Updates')
         
         # pack elements
diff -ru mMass/gui/main_frame.py mMass_lin/gui/main_frame.py
--- mMass/gui/main_frame.py    2013-06-30 14:23:36.000000000 +0400
+++ mMass_lin/gui/main_frame.py    2014-11-02 21:32:56.081757649 +0300
@@ -3572,7 +3572,7 @@
         self.tmpCompassXport = False
         
         # check platform
-        if not wx.Platform == '__WXMSW__':
+        if not wx.Platform in ('__WXMSW__', '__WXGTK__'):
             wx.Bell()
             dlg = mwx.dlgMessage(self, title="Unable to convert data.", message="Unfortunately, it is not possible to use Bruker's CompassXport tool\non this platform.")
             dlg.ShowModal()
@@ -3634,14 +3634,32 @@
         mode = choices[config.main['compassFormat']]
         
         # convert data
-        try:
-            output = os.path.join(os.path.dirname(path), 'Analysis.'+config.main['compassFormat'])
-            retcode = subprocess.call(['CompassXport.exe', '-a', path, '-o', output, '-raw', str(raw), '-mode', str(mode)], shell=True)
-            if retcode == 0:
-                self.tmpCompassXport = output
+        output = os.path.join(os.path.dirname(path), 'Analysis.'+config.main['compassFormat'])
+        if wx.Platform == '__WXMSW__':
+            try:
+                retcode = subprocess.call(['CompassXport.exe', '-a', path, '-o', output, '-raw', str(raw), '-mode', str(mode)], shell=True)
+                if retcode == 0:
+                    self.tmpCompassXport = output
+                    return
+            except:
                 return
-        except:
-            return
+        else:
+            try:
+                # python 2.7+ required
+                # winepath appends \n to output
+                path_wine = subprocess.check_output(['winepath', '-w', path]).strip()
+                output_wine = subprocess.check_output(['winepath', '-w', output]).strip()
+            except:
+                print sys.stderr, "Wine can't reach input file", path
+                return
+            try:
+                retcode = subprocess.call(['wine', 'c:/Program Files/Bruker Daltonik/CompassXport/CompassXport.exe', '-a', path_wine, '-o', output_wine, '-raw', str(raw), '-mode', str(mode)], shell=False)
+                if retcode == 0:
+                    self.tmpCompassXport = output
+                    return
+            except:
+                return
+
     # ----
     
     

2

Re: Automatically import bruker spectra on linux

Hi,

Beforehands, BIG thanks for posting a solution to this kind of problems! :-)

I'm having troubles with the last part of the quick guide, as I'm not too experienced with linux:

I basically tried applying the patch executing "patch -i /path/to/patch" from the console in the /usr/share/mmass folder, leading to this output:

can't find file to patch at input line 4                                                     
Perhaps you should have used the -p or --strip option?                                       
The text leading up to this was:                                                             
--------------------------                                                                   
|diff -ru mMass/gui/dlg_preferences.py mMass_lin/gui/dlg_preferences.py                     
|--- mMass/gui/dlg_preferences.py    2013-06-30 14:23:36.000000000 +0400                     
|+++ mMass_lin/gui/dlg_preferences.py    2014-11-01 20:07:27.704541770 +0300                 
--------------------------         

Did I do something wrong, or do you know the cause of this problem?

(Using -p0 I get an error report: File gui/dlg_preferences.py is read-only; trying to patch anyway                             
patch: **** Can't create temporary file gui/dlg_preferences.py.oBDWicL : Permission denied)

Many thanks in advance!

3

Re: Automatically import bruker spectra on linux

You should run patch command as root if you want to modify file system. If you are in mMass directory (where mmass.py and 'gui' folder reside) then run
most linux distributions:

su
patch -p1 -i patch_location

('su' will ask for root password)

ubuntu and other distributions with disabled root login (never checked but it should work):

sudo patch -p1 -i patch_location

('sudo' will ask for user password)

I also recommend you to change

'c:/Program Files/Bruker Daltonik/CompassXport/CompassXport.exe'

in this patch to

'CompassXport.exe'

to avoid problems with 64-bit wineprefix

You can also simply replace these 2 files in 'gui' folder with patched version

main_frame.py
http://fpaste.org/335296/

dlg_preferences.py
http://fpaste.org/335299/73805211/