pytest-cov collects no data on Travis

I recently switched from nosetests to pytest and pytest-cov for one of my Python project (http://easydev-python.readthedocs.io).

Locally, everything seemed to work fine and once on Travis, all tests passed as expected.

Yet, before the coverage report, I noticed this warning:

and more importantly, the final coverage reported was 0% !!

I later realised that one __init__.py file in the test/ directory was present locally but not in the github source code. After a commit, travis found the missing file and the coverage came back to normal.

So, this __init__.py seems important for pytest-cov

Posted in Python | Tagged , , | 2 Comments

Remove extension in a bash script

Imagine a bunch of files with extension fastq.dsrc, the following script will decompress the files by looping over the N files. One issue was to remove the extension in the script. See below the usage of //

Posted in Linux | Tagged | Leave a comment

git synchronisation of a forked repository

Let us assume you have forked a repository (from https://github.com/project/repository_name). You now have a local version at a given time of the repository repository_name.

Time flyes and you come back to the local repository and you are not synchronised anymore. So, you need to fetch the new commits from the upstream repo, pull and push into your repository. this is done as follows:

Posted in Uncategorized | Leave a comment

gimp: how to make a transparent background

How to make a transparent background/selection on an image using GIMP

    1. Open your image.
    2. Select the area you want to make transparent.

    1. Select the appropriate selection tool from the Tool window or the Tools – Selection Tools menu on the Layer window. I usually use the magic wand/fuzzy select (Select contiguous region) tool or the Select regions by color tool.
    2. Click in the region you want selected. Use shift-click to add more regions/colors.Tip: It’s easier if you zoom in (View – Zoom menu) to see finer details of exactly what you’re selecting.

    3. In the Layer window (the one showing your image), select Layer – Transparency – Add Alpha Channel.If this is blanked out then it’s already done. This makes sure your image can store transparency data
    4. Select Edit – Clear. This makes the selection transparent.
    5. Save the file. Note: If you save it as a PNG file, be sure to select the ‘Save colour values from transparent pixels’ option in the Save as PNG dialog box.

Posted in photos | Tagged | Leave a comment

lost your linux root password ?

Lost your root password ?
=========================

Under Fedora, at boot time, press e, select the kernel and add 1 (run level), which will let you enter into a shell session, where you can edit the /etc/passwd file to reset the password.

Posted in Linux | Tagged | Leave a comment

vim: multiple buffers

In order to work with several view ports of the same file in the same Vim window, type:

You may also open another file in the same window. To do so issue the command::

To switch between buffers, use ctrl+w

To open a vertical buffer use :vsp filename.

Posted in Linux | Tagged | Leave a comment

vim: create function to remove white spaces

In the .vimrc file, add the following lines ( here ^M is a special character for the return carriage created using CTRL+V):

those functions call then be called within vim typing:

some Explanation of the function removeWhiteSpace().

  1. first line replaces a line that starts and ends with white spaces
  2. second line replaces a single white space that is alone on a line.
  3. third line replaces the end of a line that finishes with trailing spaces
  4. same as 3 but for the single white space case
Posted in Linux | Tagged | Leave a comment

yumex-dnf is locked

Under Fedora 23, starting yumex-dnf, I got a message that yumex-dnf was locked. I could not find any lock file in /var/cache/dnf and therefore was stuck. Finally, running

did kill the faulty process and could start yumex-dnf again…

Posted in Linux | Tagged | 5 Comments

conda and bioconda channel

Anaconda ( https://www.continuum.io/downloads ) provides a Python distribution with more than 400 of the most popular Python packages for science, math, engineering, and data analysis. Anaconda installs an executable called conda that will be your entry point.

Anaconda solves two problems.

First it is a virtual environment similar to virtualenv, which is used in the Python community. The advantage I found with compared to a tool such as virtualenv is that you can easily have any Python environment on your system (e.g. 2.6, 3.4 and so on) without the need to have to install the specific Python version yourself (see other posts on this subjet , , .

Second, installation of packages (e.g. numpy) to be found on the conda website will be fast and smooth since packages are pre-compiled: no compilation errors (in principle) and no time spent waiting for the compilation to be finished. This is very valuable since it also means that your software can be installed by anybody who will use anaconda (and therefore the same pre-compiled libraries as yours).

conda can download more than 400 packages but there are much more out there ! First, you can still use pip to install any package to be found on website.
Besides, conda provides a mechanism that ease the creation of parallel channels. One of them dedicated to biology is called bioconda. The bioconda channel can be added to your environment by typing

You can then install a tool such as bwa (sequence alignment) as follows:

Again the great advantages here will be that bwa will be installed in a second (time to download the package) and the executable ready to be used !

I mentionned the fact that you can use different version of Python. How does that work ? You need to create an environment. A default one is provided once Anaconda is installed but you can create as many as you want by naming them and setting the version of Python to be used. For instance, let us create an environment with python3.5:

You can then activate it as follows:

You can check that you have indeed the correct python version by starting a python shell and check the version

For more information, visit those two sites:

https://bioconda.github.io/
https://www.continuum.io/downloads

Posted in biology, Python | Tagged , , | 1 Comment

pypi upload failed (401)

On a new computer after a fresh installation, I tried to upload a new version of an existing package on the pypi repository. Of course, I have already a username/password and uploaded packages in the past. However, in the source directory, when typing

I got the following error message:

I just forgot to create a special file named .pypirc in the HOME directory with this content:

Posted in Python | Tagged | Leave a comment