Commit 5d4597d3 authored by Sean Solari's avatar Sean Solari
Browse files

Bug fix for ete3 module import

parent 52f741c3
......@@ -7,7 +7,7 @@
Conda installation is recommended. Create a new environment before installing expam.
```console
$ conda install -c bioconda expam
conda install -c bioconda expam
```
#### From PyPI
......@@ -15,15 +15,15 @@ $ conda install -c bioconda expam
You may need to update g++ resources on your local machine. For linux, you can run the following.
```console
$ apt update
$ apt-get install build-essential
apt update
apt-get install build-essential
```
Then install from PyPi.
```console
$ python3 -m pip install --upgrade pip
$ python3 -m pip install expam
python3 -m pip install --upgrade pip
python3 -m pip install expam
```
#### From GitLab source
......@@ -35,23 +35,23 @@ most common of which are outlined in the FAQ section below.
You may need to update g++ resources on your local machine. For linux, you can run the following.
```console
$ apt update
$ apt-get install build-essential
apt update
apt-get install build-essential
```
First download the source code from the GitLab repository.
```console
$ git clone https://github.com/seansolari/expam.git
git clone https://github.com/seansolari/expam.git
```
This can then be installed locally by executing the following command from the
source code root:
```console
$ cd expam
$ python3 -m pip install --upgrade pip
$ python3 -m pip install -r requirements.txt
$ python3 setup.py install
cd expam
python3 -m pip install --upgrade pip
python3 -m pip install -r requirements.txt
python3 setup.py install
```
<hr style="border:1px solid #ADD8E6"> </hr>
......@@ -77,7 +77,7 @@ See the Quick Start Tutorial for a guide to expam's basic usage and download lin
This is simply a matter of updating the compiler.
```bash
$ sudo apt-get install build-essential
sudo apt-get install build-essential
```
<hr>
......@@ -86,7 +86,7 @@ $ sudo apt-get install build-essential
This simply means you need to install/update the Python development files for version 3.
```bash
$ sudo apt-get install python3-dev
sudo apt-get install python3-dev
```
(Reference - [SO](https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory/21530768))
......@@ -97,23 +97,47 @@ $ sudo apt-get install python3-dev
For instance, `ImportError: cannot import name 'NodeStyle'`.
The *ete3* module depends on Qt, and for Linux it may take some tweaking to get Python
to recognise the local installation of Qt. The following seems to work for a broad
collection of circumstances.
The *ete3* module depends on Qt to draw things, and there are two stages to getting this to work: first, Qt needs to be installed, and then you need to let Python know that Qt is installed. Follow the following instructions depending on your OS.
***Mac***
Install qt5 using brew.
```bash
brew install qt5
brew list --versions qt5
```
This should show you the precise version that brew installed. We now tell Python which version of Qt5 to link up with. Say we have `qt@5 5.15.3` from the above command, then we would run
```bash
python3 -m pip install pyqt5==5.15
```
Had the output been `qt@5 5.12.0`, we would run
```bash
python3 -m pip install pyqt5==5.12
```
ie. the first two parts of the version from brew. This should remedy the problem.
***Linux***
First update the local installation of Qt.
```bash
$ sudo apt-get install qt5-default
sudo apt-get install qt5-default
```
Now double-check which version of Qt has been installed.
```bash
$ dpkl -l | grep "pyqt5"
dpkg -l | grep "pyqt5"
```
Install the corresponding Python interface to Qt.
Take the first two parts of the version output from this, and pass it to this following install with Pip. For instance, if we have `qt5 5.12.0`, take the `5.12` component. Install the corresponding Python interface to Qt.
```bash
$ pip3 install pyqt5==5.12
python3 -m pip install pyqt5==5.12
```
### OOM Killer
......@@ -125,20 +149,20 @@ To prevent this occurring, make prudent use of the `expam_limit` functionality (
If you suspect that OOM killer has been invoked, this can be confirmed using the following command:
```bash
$ dmesg -T | egrep -i 'killed process'
dmesg -T | egrep -i 'killed process'
```
In the event OOM killer has been called, it is prudent to check
how much shared memory is currently being used by the system.
```bash
$ df -h /dev/shm
df -h /dev/shm
```
If the amount of shared memory used is higher than you would expect, you can first check if there are any residual resources that need to be cleaned up.
```bash
$ ls -lah /dev/shm
ls -lah /dev/shm
```
If there are files starting with 'psm' and owned by you, these may be residual files that need to be cleaned up. Contact your systems administrator to remove these files.
......@@ -148,13 +172,13 @@ It may also be the case that OOM killer has killed some child process, leaving t
To check for sleeping (expam) processes, run
```bash
$ sudo lsof /dev/shm | grep "expam"
sudo lsof /dev/shm | grep "expam"
```
These sleeping processes should then be killed by running
```bash
$ kill -9 <PID>
kill -9 <PID>
```
Confirm that the leaked memory has been freed by running `df -h /dev/shm`.
......@@ -167,8 +191,8 @@ Confirm that the leaked memory has been freed by running `df -h /dev/shm`.
A complete list of available commands can by found by using the `-h`/`--help`
flags.
```console
$ expam --version
$ expam --help
expam --version
expam --help
...
```
......
......@@ -610,9 +610,16 @@ class Index:
name_to_taxon=None, use_phyla=False, keep_zeros=True, use_node_names=True, log_scores=False,
itol_mode=False):
counts = pd.read_csv(file_path, sep='\t', index_col=0, header=0, skiprows=skiprows)
self.draw_tree(out_dir, counts=counts, groups=groups, cutoff=cutoff, cpm=cpm, colour_list=colour_list,
name_to_taxon=name_to_taxon, use_phyla=use_phyla, keep_zeros=keep_zeros,
use_node_names=use_node_names, log_scores=log_scores, itol_mode=itol_mode)
# Remove any columns that contain only zeros.
counts = counts.loc[:, (counts > 0).any().values]
if counts.shape[1]:
self.draw_tree(out_dir, counts=counts, groups=groups, cutoff=cutoff, cpm=cpm, colour_list=colour_list,
name_to_taxon=name_to_taxon, use_phyla=use_phyla, keep_zeros=keep_zeros,
use_node_names=use_node_names, log_scores=log_scores, itol_mode=itol_mode)
else:
print("No samples with counts in this matrix. Skipping plotting of %s." % file_path)
def draw_tree(self, out_dir, counts, groups=None, cutoff=None, cpm=None, colour_list=None, name_to_taxon=None,
use_phyla=False, keep_zeros=True, use_node_names=True, log_scores=True, itol_mode=False):
......@@ -682,7 +689,6 @@ class Index:
if cutoff is None and cpm is None:
nodes_with_counts = nodes
else:
nodes_with_counts = set()
......@@ -763,12 +769,16 @@ class Index:
# Draw with ete3.
try:
from ete3 import AttrFace, faces, TreeStyle, NodeStyle, TextFace
except ModuleNotFoundError as e:
print("Could not import ete3 plotting modules! Error raised:")
print(traceback.format_exc())
print("Skipping plotting...")
return
except ImportError as e:
print("Could not import drawing attributes from ete3. Error raised:")
print(traceback.format_exc())
print("See FAQ section on GitHub for fix to this problem.\n\t(https://github.com/seansolari/expam#problems-during-installation)")
print("Skipping plotting...")
return
"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment