Skip to content

Installing the UniDec Source Code

michaelmarty edited this page Aug 17, 2022 · 9 revisions

Why do it?

Many people are happy with just running UniDec as a compiled software package with fixed features. However, you may want to modify some of the settings, build onto it, or develop new workflows with the UniDec code. For example, you can script your UniDec deconvolution with Python scripts to rapidly analyze a large amount of data and collect it into custom figures.

This is meant to be a guide for beginners, and people already familiar with Python may be able to skip a lot of this.

How to install the source code

I will walk through source code installation with Windows, because that is what most people use. The same principles apply to Mac and Linux systems, but you need to do some additional compiling of the binaries.

Install Python 3

Download the Python installer from this website: https://www.python.org/downloads/windows/. I'd recommend getting Python 3.9. The key is to download the Windows x86-64 executable installer. This is the 64-bit version of Python. As of August 2022, some libraries are not supported in Python 3.10, so I would highly recommend the latest release of 3.9.

As soon as you launch the installer, check the button for "Add Python to PATH". This will make it easier to install the required libraries by command line.

Then, click Customize Installation. The optional features should stay the same; just make sure pip is checked. Under advanced options, I recommend checking "Install for all users", "Add Python to environment variables", "Precompile standard library". I also recommend installing it to a folder outside the default AppData folder. I usually install mine to C:\Python39 (or whatever the version number is, such as 37). Click install and follow along.

Checking for pip.exe

Now that Python is installed, you need to install the libraries that UniDec needs to run on. First, you need to find the pip.exe file. It should be in C:\Python39\Scripts. The easiest thing is to access this through the command line.

If you hit the windows key and type cmd.exe, it will bring up a command prompt. Type:

where pip

It should show something like "C:\Python39\Scripts". If it can't find it, hit the windows key and type "Edit the System Environment Variables". It will open the System Properties window under the advanced tab. You will then want to click "Environment Variables". Under System Variables, edit the Path variable. Add both the C:\Python39 and the C:\Python39\Scripts folders to the Path. Hit ok and ok to close both windows.

Now, relaunch the cmd.exe. You will need to relaunch the cmd to update the path. If it doesn't work, close out and reopen it again. Try the where pip command again. It should now see pip.exe in the Scripts folder.

Installing NumPy and SciPy

The first step is to install NumPy. You could just install it with the command pip install numpy, but we want to install the fast version of numpy that is built with the Intel Math Kernel Library (mkl).

Visit this website to grab the latest numpy+mkl binary: https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy. Importantly, you want to get the latest version, but it has to match your Python version. For example, if you have Python 3.8, you will need to download numpy‑1.18.2+mkl‑cp38‑cp38‑win_amd64.whl. The cp38 tells you it is Python 3.8. The win_amd64 tells you it is the 64-bit, and not the 32-bit. Because we installed the 64-bit version (see above), we need to match that.

Download the numpy .whl file to somewhere convenient. I usually save it to the Downloads folder. Then, using the command line, navigate to the Downloads folder (or wherever you save it). For those who haven't used the command line, you use the command cd to change the directory. The command line defaults to the user folder, so you can just type cd Downloads to change the directory to that folder. If you type dir, it will list all the files and folders in the Downloads folder. You should see your numpy whl file here.

Now type: pip install numpy‑1.18.2+mkl‑cp38‑cp38‑win_amd64.whl or whatever your correct version is. You can also use the tab key to autocomplete the file name after you've typed part of it, which helps in avoiding mistakes typing the whole thing out. Hit enter, and it will install numpy.

After installing numpy (not before!), it is time to install scipy with a very similar process. Go to https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy and grab the latest scipy version that matches the Python version (cp38) and is 64 bit (amd64). Repeat the process of downloading it and typing pip install scipy‑1.4.1‑cp38‑cp38‑win_amd64.whl. Also, do the same with pythonnet.

Now that you have installed numpy, scipy, and pythonnet, you can install the remaining libraries from the command line and don't need to download any other files.

Installing the remaining libraries

For the remaining libraries, you can easily install them from the command line by typing: pip install <package1> <package2> .... You can either type all packages or install one a time until they are all done. You will need the following packages: matplotlib wxpython natsort pymzml networkx h5py pypubsub. There are also some optional libraries like multiplierz (Windows only, for some raw file format imports), massql, pymsfilereader, pyimzml. These don't all need to be installed, but you might as well.

If you type: pip install matplotlib wxpython natsort pymzml networkx h5py pypubsub, it should install all the remaining libraries.

Note: there are some issues with wxpython 4.1, so for the time being, type wxpython==4.0.7.post2. If you really want 4.1, email me to get the workarounds.

Downloading the UniDec source code

It is easy to download the UniDec source code. Simply go to: https://github.com/michaelmarty/UniDec and click the clone or download button. You can download the whole source code package as a zip file. You can also download specific versions under the Release tab: https://github.com/michaelmarty/UniDec/releases.

It will download a zip file. Extract the files to someplace convenient.

Launching UniDec

Depending on your installation, you may be able to just double click Launcher.py in the main UniDec folder, and it will launch the main window. If that doesn't work, just navigate to the UniDec folder with the command line and type python Launcher.py.

The end

You should now be able to run UniDec from the source code. To learn more about scripting, check out the Get Started section here https://github.com/michaelmarty/UniDec.

Let me know how that goes and if you have any questions.

Common problems

You may find some sort of error like: ImportError: No module named [something]. This means that Python is looking for a specific library and can't find it. The easiest way to fix it is to try opening a command prompt and typing pip install [something]. Usually, that will install the missing library. Otherwise, it may be that I forgot to upload the file to GitHub, in which case, email me or create an issue in GitHub.

An additional tip

I really like to use PyCharm (https://www.jetbrains.com/pycharm/) for code editing and management. It is a fantastic package for Python programming.