Matrix Science Mascot Parser toolkit
 
Loading...
Searching...
No Matches
Python toolkit installation

To use the toolkit, a Python interpreter must be installed.

On Windows, all versions of 64-bit Python 3, version 3.6 or later, are supported. We recommend the official Python (CPython) from https://python.org, but the module should also work with:

Other Python builds may work but have not been officially tested.

On Linux, all versions of 64-bit Python 3, version 3.6 or later, are supported. Python can be installed from the package repository of most Linux distributions, and it can also be downloaded and compiled from source from from https://python.org/.

The Parser module has been compiled using Python's stable API and should be binary compatible with all Python versions from 3.6 and up. Please contact us if you require Mascot Parser for a different version of Python.

Note
Mascot Parser Python modules are not Unicode-aware. Make sure that any string objects you pass as parameters to Mascot Parser functions are non-Unicode string objects.

To use Mascot Parser in your program, the files msparser.py and _msparser.pyd (_msparser.so on Linux) must either be in the same directory as your program, or in a directory searched by the Python interpreter. In the latter case, there are three alternatives.

Define or modify PYTHONPATH:

You can define the PYTHONPATH environment variable to point to the directory where Mascot Parser Python files are located.

Use sys.path.append():

You can use sys.path.append() in your program to add the directory where Mascot Parser files are located to the module search path. This is equivalent to modifying PYTHONPATH, except that the path is hardcoded in your program.

Global installation:

You can copy the Mascot Parser Python files to the site-packages directory of your Python installation.

  • In Windows, assuming CPython 3.11 or ActivePython 3.11, this could be C:\Python311\Lib\site-packages. The exact path depends on where Python was installed. Please refer to the official Python documentation: https://docs.python.org/3/using/windows.html#windows-finding-modules
  • In Linux, this is similar to /usr/local/lib/python3.11/site-packages, assuming Python 3.11. The exact path depends on where Python was installed.

Visual C++ Redistributable Package (Windows)

You may also need to install the Microsoft Visual C++ 2015 (or later) Redistributable Package
To check if you need this:

  1. Download and run depends.exe from http://www.dependencywalker.com/ or Dependencies program from https://github.com/lucasg/Dependencies
  2. Open msparser.dll in the program.
  3. If it reports that the dependent MSVCR140.dll and MSVCP140.dll are missing, download the Visual C++ 2015 (or later) redistributable package from the Microsoft Download Center: https://support.microsoft.com/en-us/topic/the-latest-supported-visual-c-downloads-2647da03-1eea-4433-9aff-95f26a218cc0
  4. Choose vc_redist.x64.exe for 64-bit

Running a Python example on Windows

Open a command prompt, and change to the example_python directory. To run, say, resfile_error.py:

    python.exe resfile_error.py C:\Inetpub\mascot\data\F981119.dat

If python.exe is not in PATH%, prefix the command with the absolute path to python.exe.

Running a Python example on Linux

Open a terminal window, and change to the example_python directory. To run, say, resfile_error.py:

    ./resfile_error.py /usr/local/mascot/data/F981119.dat

This only works if resfile_error.py has the executable bit set, and if the script has the correct "shebang" line. The "shebang" line is the first line of the script, and gives the location of the Python interpreter:

    #!/usr/bin/python

You can use the Python interpreter directly:

    python resfile_error.py /usr/local/mascot/data/F981119.dat

Using the Python toolkit

Reasonable proficiency in Python programming will be required. Please see Quickstart: how to open a results file and Examples for the results file module.