Follow me
-
Recent Posts
calendar
December 2024 M T W T F S S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 Recent Comments
- Stan on python argparse issues with the help argument (TypeError: %o format: a number is required, not dict)
- Cormac on Pandas : how to compare dataframe with None
- LP on AWK: the substr command to select a substring
- jrab on python argparse issues with the help argument (TypeError: %o format: a number is required, not dict)
- How to disable SSL verification for urlretrieve? – Peter's blog on python: certificate verified failed
Archives
Categories
Meta
Author Archives: Thomas Cokelaer
Python: how to copy a list
To explain how to create a copy of a list, let us first create a list. We will use a simple list of 4 items: list1 = [1, 2, "a", "b"]list1 = [1, 2, "a", "b"] Why do we want … Continue reading
Python: ternary operator
In C language (and many other languages), there is a compact ternary conditional operator that is a compact if-else conditional construct. For instance, in C, a traditional if-else construct looks like: if (a > b) { result = x; } … Continue reading
Posted in Python
Leave a comment
Difference between __repr__ and __str__ in Python
When implementing a class in Python, you usually implement the __repr__ and __str__ methods. __str__ should print a readable message __repr__ should print a message that is unambigous (e.g. name of an identifier, class name, etc). You can see __str__ … Continue reading
python: how to merge two dictionaries
Let us suppose two dictionaries storing ages of different individuals: list1 = {"Pierre": 28, "Jeanne": 27} list2 = {"Marc": 32, "Helene": 34}list1 = {"Pierre": 28, "Jeanne": 27} list2 = {"Marc": 32, "Helene": 34} If you do mind losing the contents … Continue reading
Search for a pattern in a set of files using find and grep commands
A common task for developers is to search for a pattern amongst a bunch of files that are in different directories. For instance, you are looking for the pattern “import sys” within a set of Python files. Those files are … Continue reading
okular: export annotations in the PDF file
One open source software to add annotations under Linux is okular (https://okular.kde.org/). One can add annotations easily (go to Tools, tick review, or just type F6). Then, it is time to save your document or to send it to a … Continue reading
No more space left on /tmp under Fedora
Under Fedora, one of my software requires more than 4Gb of temporary space and I realised that the /tmp directory is limited to 4Gb. In order to increase the /tmp directory, just edit the /etc/fstab file and add this line … Continue reading
Posted in Linux
Leave a comment
blasr (pacbio) installation on fedora box
I wanted to use blasr tool for Pacbio mapping and had difficulties in using or installing the tool. I first use a local installation of the tool on the provided cluster and it look like the installation was quite old. … Continue reading
swapping two columns with awk keeping tabulation
Assuming you have a data file with N columns and you want to swap the first and second one, just type: awk -F $’\t’ ‘ { t = $1; $1 = $2; $2 = t; print; } ‘ OFS=$’\t’ input_fileawk … Continue reading
set a default version to an environment module
Context: “The environment modules package provides for an easy dynamic modification of a user’s environment via modulefiles. which typically instruct the module command to alter or set shell environment variables such as PATH, MANPATH, etc. as well as define aliases … Continue reading