Skip to content

Instantly share code, notes, and snippets.

View elowy01's full-sized avatar

Ernesto Lowy elowy01

  • Biofidelity
  • Cambridge, UK
View GitHub Profile
@elowy01
elowy01 / Markdown syntax cheatsheet
Last active May 26, 2020 09:40
Markdown syntax cheatsheet
*Headers
# H1
## H2
### H3
#### H4
*Change font style to italic:
_thistext_
@elowy01
elowy01 / python_cheat_sheet.txt
Last active August 17, 2023 22:13
Python cheat sheet
#PyPI
Is the module repository in Python (the equivalent to CPAN in Perl)
//
*Initializing 2 variables at the same time:
a=b=0
or
a=b=0.0
@elowy01
elowy01 / Conda cheat sheet
Last active January 31, 2023 11:41
Conda cheat sheet#
//
# Deactivating the activation of the base environment in Python:
conda config --set auto_activate_base false
//
#To install a package
conda install packagename
//
# specifying multiple channels when installing a package
$ conda install scipy --channel conda-forge --channel bioconda
//
@elowy01
elowy01 / nextflow cheat sheet
Last active November 10, 2023 11:57
nextflow cheat sheet
#Example 1:
#!/usr/bin/env nextflow
params.str = 'Hello world!'
process AFcalc {
"""
echo '${params.str}'
@elowy01
elowy01 / mysql query reminder for igsr-analysis project
Last active September 15, 2020 08:48
mysql query reminder for igsr-analysis project
#split input_id from job
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(input_id, ' ', 1), ' ', -1) as prefix,
SUBSTRING_INDEX(SUBSTRING_INDEX(`input_id`, ' ', 2), ' ', -1) as data_id FROM job;
#select analysis_data_id using a join
select * from analysis_data where analysis_data_id in (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`input_id`, ' ', 2), ' ', -1) as data_id FROM job where analysis_id=30 and status='RUN')
#select analysis_data and filtering according to one chromosome (chr8 in this case):
select * from analysis_data where analysis_data_id in (SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(`input_id`, ' ', 2), ' ', -1) as data_id FROM job where analysis_id=29 and status='RUN') and data like '%8:%';
@elowy01
elowy01 / AWK cheat sheet
Last active September 22, 2022 16:11
AWK cheat sheet
awk '/gold/' coins.txt #look for all the records with the word gold and shows
these rows
//
awk '{if ($3 < 1980) print $3, " ",$5,$6,$7,$8}' coins.txt #$3 is a variable
that stores the 3rd word of each row . " " introduces 4 whitespaces for the
printing
//
awk '{if ($3 >= 0) print $3}' filename #same as the previous one but we add the equal sign
//
NR gives you the total number of records being processed or line number.
@elowy01
elowy01 / Docker cheat sheet
Last active December 14, 2022 13:32
Docker cheat sheet
#getting an specific image
docker pull ubuntu
#A container is a running image that you start with the docker run command, like this:
$ docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
#We then run a container from that image:
docker run -it ubuntu /bin/bash #And that’s it, root@4ff0be4995f0:/# means that we are root inside an Ubuntu container
/
#Now, if we want to assign a name to the container created from the ubuntu image
@elowy01
elowy01 / BCFtools cheat sheet
Last active June 29, 2024 05:24
BCFtools cheat sheet
*bcftools filter
*Filter variants per region (in this example, print out only variants mapped to chr1 and chr2)
qbcftools filter -r1,2 ALL.chip.omni_broad_sanger_combined.20140818.snps.genotypes.hg38.vcf.gz
*printing out info for only 2 samples:
bcftools view -s NA20818,NA20819 filename.vcf.gz
*printing stats only for variants passing the filter:
bcftools view -f PASS filename.vcf.gz
@elowy01
elowy01 / reStructuredText cheat sheet
Last active February 3, 2020 16:43
reStructuredText cheat sheet
reStructuredText (RST, ReST, or reST) is a file format for textual data used primarily in the Python programming language community for technical documentation.
//
#inline code block
This is an inline code block ``hello``. Yes
//
# Literal blocks
# The literal blocks need a blank line just before the literal block, also it needs to be indented. It requires another
# blank line after the literal block
This is a normal text paragraph. The next paragraph is a code sample::
// Create a Singularity image from a Docker image that is in the Docker hub
// where /tmp/ is the folder where the image will be created and ubuntu:14.04
// is the docker image used to convert to the Singularity image
docker run \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/:/output \
--privileged -t --rm \
singularityware/docker2singularity \
ubuntu:14.04
//