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 / test.sh
Created November 12, 2020 09:34 — forked from arq5x/test.sh
Compress and then Decompress a string with zlib.
# compile
$ g++ zlib-example.cpp -lz -o zlib-example
# run
$ ./zlib-example
Uncompressed size is: 36
Uncompressed string is: Hello Hello Hello Hello Hello Hello!
----------
# compile
$ g++ zlib-example.cpp -lz -o zlib-example
# run
$ ./zlib-example
Uncompressed size is: 36
Uncompressed string is: Hello Hello Hello Hello Hello Hello!
----------
@elowy01
elowy01 / Parse_VCF_BCFs_with_htslib_C++.md
Created November 16, 2020 10:28 — forked from gatoravi/Parse_VCF_BCFs_with_htslib_C++.md
Parse VCF/BCFs with htslib (C++)

#Gist of the gist This is a simple example showing how htslib can be used to parse VCF/BCF files in C++. Compiling options are shown in compile_and_run.sh, this assumes that you have compiled htslib into a static library - libhts.a, post a comment if you'd like help doing that.

The program takes a VCF file and spits out chromosome, position and number_of_alleles for each record in the VCF.

This test in the Samtools repo - [https://github.com/samtools/htslib/blob/1.2.1/test/test-vcf-api.c] also has some useful examples, note you might have to switch to the master branch version of that file to keep up with the currently rapidly evolving htslib API.

#Acknowledgements

#Gist of the gist This is a simple example showing how htslib can be used to parse VCF/BCF files in C++. Compiling options are shown in compile_and_run.sh, this assumes that you have compiled htslib into a static library - libhts.a, post a comment if you'd like help doing that.

The program takes a VCF file and spits out chromosome, position and number_of_alleles for each record in the VCF.

This test in the Samtools repo - [https://github.com/samtools/htslib/blob/1.2.1/test/test-vcf-api.c] also has some useful examples, note you might have to switch to the master branch version of that file to keep up with the currently rapidly evolving htslib API.

#Acknowledgements

# Example extracted from : https://www.geeksforgeeks.org/python-method-overloading/
# Install the required module if needed: pip3 install multipledispatch
from multipledispatch import dispatch
#passing one parameter
@dispatch(int,int)
def product(first,second):
result = first*second
print(result);
#. Initialize an empty dict
adict = dict()
#. Create a dictionary
dict={‘Country’:’India’,’Capital’:’New Delhi’}
#. checking key membership
if 'Country' in dict:
print("There is a key with name 'Country'")
else :
# assert lists equality with pytest
actual = ['bl', 'direction', 'day']
expected = ['bl', 'direction', 'day']
assert len(actual) == len(expected)
assert all([a == b for a, b in zip(actual, expected)])
print(all([a == b for a, b in zip(actual, expected)]))
>>> True
# Altering the editor used by crontab:
export EDITOR=emacs
# Editing or generating a new crontab if it does not exist:
$ crontab -e
# crontab that executes a command every minute
*/1 * * * * echo "hello" > out.txt
# If you want to delete cron jobs you can do it by:
/*
* Example to see how pointer arithmetics work
* We will iterate over an array by using pointers
*/
#include <iostream>
using namespace std;
int main()
{
#doing the backup of a particular table
mysqldump --host=mysql-eg-devel-1.ebi.ac.uk --port=4126 --user=ensrw --password=scr1b3d1 dbname tablename >tablename+.bak
//
#after doing a dump, you can upload the data into the DB like this:
mysql -uusername DATABASENAME -ppwd <DATABASE.sql