w Parsing Thermo Finnigan RAW files | Fuzzier Logic

In a rare move, I’m going to largely copy across a post from my work blog, because I hope it contains useful information. For background, I’m trying to write a simple python script that extracts particular metadata from a .RAW file, produced by a Thermo Finnigan mass spectrometer. Tools that exist for parsing these files require access to proprietary XCalibur libraries, which I do not have.

Thermo provided a link to MSFileReader, a ‘freeware’ COM object that should allow interaction with RAW files without an XCalibur installation. They also sent a PDF guide to the COM object. Although this will allow XCalibur to be avoided, the work is still Windows-bound.

Python and COM objects

Python can talk to COM objects, through the win32com.client package. As a test, I installed Python and MSFileReader and the pywin32 libs on my netbook (which is a Windows 7 machine). Can import the required Python module, but need to extent the PATH somewhat:

  1. >>> sys.path.append('C:\\Python26\\Lib\\site-packages\\win32')
  2. >>> sys.path.append('C:\\Python26\\Lib\\site-packages\\win32\\lib')
  3. >>> from win32com.client import Dispatch
  4. >>> x = Dispatch("NAME")

The key thing here is “NAME”:

The provided PDF gives C snippets for each method available in the COM object. This only provides one clue as to the possible name of the COM object

  1. // example for Open
  2. TCHAR* szPathName[] = _T(“c:\\xcalibur\\examples\\data\\steroids15.raw);
  3. long nRet = XRawfileCtrl.Open( szPathName );
  4. if( nRet != 0 ) {
  5.     ::MessageBox( NULL, _T(“Error opening file”), _T(“Error”), MB_OK );
  6.     …
  7. }

XRawfileCtrl is used to call the Open() method. However, this and MSFileReader as “NAME” both fail (Invalid class string).

Found ‘multiplierz‘ which seems to use MSFileReader to create mzAPI – which focusses on access to the actual data, rather than the metadata. The code gives some good clues as to how to use the COM object. [doi:10.1186/1471-2105-10-364]

MSFileReader.XRawfile is used as “NAME” in this code.

So:

  1. >>> sys.path.append('C:\\Python26\\Lib\\site-packages\\win32')
  2. >>> sys.path.append('C:\\Python26\\Lib\\site-packages\\win32\\lib')
  3. >>> from win32com.client import Dispatch
  4. >>> x = Dispatch("MSFileReader.XRawfile")
  5. >>> x.Open("C:\\Users\\path\\to\\file\\msfile.RAW")
  6. >>>

To be continued…

Tagged with:
 

One Response to Parsing Thermo Finnigan RAW files

  1. fallino says:

    Hi,

    I’m trying too to parse the Thermo .raw files, did you continue this quest any further ? I would be very glad to hear from this ! Thanks and keep going

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>