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 / samtools cheat sheet
Last active October 16, 2022 12:22
Cheat sheet for SAMtools
#getting the insert size from a BAM file
samtools view -F 0x4 accepted_hits.bam | awk '{if ($9 >0) {sum+=$9;sumsq+=$9*$9;N+=1}} END {print "mean = " sum/N " SD=" sqrt(sumsq/N - (sum/N)**2)}'
#slicing a BAM file
samtools view aln.sorted.bam chr2:20100000-20200000
# extract a subsequence from a FASTA file
# 1) Index the Fasta file
samtools faidx hs37d5.ch20.fa
# 2) Fetch the sequence
@elowy01
elowy01 / gist:05b26635a0df93b8b06e27c19c3f9164
Created March 27, 2019 14:49
Phased and Imputed format files
# HAPS/SAMPLE format
Explanation of format can be found at https://mathgen.stats.ox.ac.uk/genetics_software/shapeit/shapeit.html#hapsample
@elowy01
elowy01 / cpp_cheat_sheet
Last active December 4, 2019 16:50
Cheat sheet on the C++ language
// # Environment variables:
CPLUS_INCLUDE_PATH=/opt/gdbm-1.8.3/includ
export CPLUS_INCLUDE_PATH
/ Link path:
LIBRARY_PATH=/opt/gdbm-1.8.3/lib
export LIBRARY_PATH
# C-style guide
http://archive.oreilly.com/oreillyschool/courses/cplusplus1/style.html#functions
@elowy01
elowy01 / CMake_cheat_sheet.txt
Last active October 24, 2019 15:27
CMake_cheat_sheet
//
In CMake we use # for adding comments
//
On the top level of a CMake file we have:
project(MyProject VERSION 1.0
DESCRIPTION "Very nice project"
LANGUAGES CXX)
//
Making an executable
# One can insert images in jupyter nb in different ways:
a) Insert this in a Code type cell
%%html
<img src="img/folder_str1.png",width=100,height=100>
Where you have a folder named img at the same level of your notebook
b) Insert this in a Markdown type cell:
![alt text](img/folder_str1.png)
#
# Enabling Table of Contents (TOC) extention in jupyter:
1) conda install -c anaconda boost
2) Boost libraries will be placed within /path/to/installation/miniconda3/include/
3) Then,modify CMakeList for Clion to point to your Boost folder:
cmake_minimum_required(VERSION 3.15)
project(test)
set(CMAKE_CXX_STANDARD 14)
add_executable(test main.cpp gzip.h)
#include <string>
#include <boost/algorithm/string.hpp>
using namespace std;
int main()
{
//split tab-separated string into vector of strs
string line("test\ttest2\ttest3");
vector<string> strs;
# how to make iterm to move cursor back and forwards one work at a time
Follow instructions at:
https://medium.com/@jonnyhaynes/jump-forwards-backwards-and-delete-a-word-in-iterm2-on-mac-os-43821511f0a
# Command lsid
View LSF version, cluster name, and current master host
# Command lsclusters
Run lsclusters to find out who your cluster administrator is and see a summary of your cluster:
# bparams
Run bparams to display the generic configuration parameters of LSF. These include default queues, job dispatch interval, job checking interval, and job accepting interval.
# modifyng limits for a certain job group
# Reading multiple .csv files
# files/input.cova
# files/input.covb
# .....
import dask.dataframe as dd
df = dd.read_csv('files/input.cov*', names=['chr','pos','cov'], sep='\t')
print("Descriptors: {0}".format(df['cov'].describe().compute()))