Skip to content

Instantly share code, notes, and snippets.

View ctokheim's full-sized avatar

Collin Tokheim ctokheim

  • Dana-Farber Cancer Institute
  • Boston, MA
View GitHub Profile
@ctokheim
ctokheim / gist:4350659
Last active December 10, 2015 00:19
Awk: MATS to PrimerSeq
# SE
cat SE.MATS.ReadsOnTargetAndJunctionCounts.txt | awk -F"\t" '{if($5=="+") print $5 $4 ":" $6 "-" $7 "," $5 $4 ":" $8 "-" $9 "," $5 $4 ":" $10 "-" $11; else print $5 $4 ":" $6 "-" $7 "," $5 $4 ":" $10 "-" $11 "," $5 $4 ":" $8 "-" $9;}' | tail -n +2 > se.txt
# MXE
cat MXE.MATS.ReadsOnTargetAndJunctionCounts.txt | awk -F"\t" '{if($5=="+") print $5 $4 ":" $6 "-" $7 "," $5 $4 ":" $10 "-" $11 "," $5 $4 ":" $12 "-" $13; else print $5 $4 ":" $6 "-" $7 "," $5 $4 ":" $12 "-" $13 "," $5 $4 ":" $10 "-" $11 }' | tail -n +2 > mxe.txt
@ctokheim
ctokheim / gist:4357866
Created December 22, 2012 07:17
Bash (shell): GNU libc (glibc)
# Old versions of GNU libc can create problems for running binaries on linux.
# In general GNU libc is backward compatible but in no way is
# "forward" compatible. This means when creating binaries for applications,
# like python with pyinstaller, you need to use the oldest version of GNU libc
# as possible. To check the version, use the following command:
ldd --version
@ctokheim
ctokheim / python27_local_install.sh
Last active April 3, 2023 08:15
Bash (shell): Install local python
#!/bin/bash
#########################################
# Installing python and necessary packages
# locally. This script will install python
# into the ~/local/bin directory and install
# numpy + scipy
#########################################
# installing python 2.7.3
@ctokheim
ctokheim / tmux_local_install.sh
Last active December 11, 2015 05:19 — forked from ryin/tmux_local_install.sh
Bash (shell): install tmux locally
#!/bin/bash
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# PATH variable will need to be updated with $HOME/local/bin and the
# LD_LIBRARY_PATH variable will need $HOME/local/lib
# exit on error
set -e
@ctokheim
ctokheim / git_tricks.sh
Last active December 11, 2015 11:48
Git: tricks
# if get recieve.denyCurrentBranch error try to pull from
# the repository instead of pushing. Alternatively just
# switch to a tmp branch.
# Permanently going back to previous commit
git reset --hard 123abc
# undo adding a file to be staged for commit
git reset myfile
@ctokheim
ctokheim / pandas_tricks.py
Last active September 14, 2016 13:28
Python: tricks
import pandas as pd
import numpy as np
# read df from delimited file
df = pd.read_csv('filename.txt', sep='\t')
# force printing out of dataframe
print df.to_string()
# apply a function to column/row

Sublime Text 2 – Useful Shortcuts (PC)

Loosely ordered with the commands I use most towards the top. Sublime also offer full documentation.

Editing

Ctrl+C copy current line (if no selection)
Ctrl+X cut current line (if no selection)
Ctrl+⇧+K delete line
Ctrl+↩ insert line after
@ctokheim
ctokheim / bash_zsh_tricks.sh
Last active January 11, 2016 22:01
Bash/Zsh (shell): Sh scripting tricks
# run command on certain files in a directory
for file in ./myDir/*.abc
do
cmd [options] $file > output.txt
done
# run command using integer ranges
for i in {1..5}
do
echo "Welcome $i times"
@ctokheim
ctokheim / UCSCTrackHub.md
Last active April 21, 2022 22:09
UCSC Genome Browser Track Hub

Overview

UCSC's track hubs allow multiple wig files to be displayed in a single custom track. Thus possibly overlaying multiple types of data or displaying strand specific read depth. Individual sub-tracks within a custom track can then be toggled on/off.

Getting Started

The official documentation of UCSC's track hubs can be found at http://genome.ucsc.edu/goldenPath/help/hgTrackHubHelp.html.

@ctokheim
ctokheim / awk_tricks.sh
Last active April 18, 2017 21:55
Awk: tricks
# sum a column
cat your_file.txt | awk '{sum+=$5} END {print sum}'
# use specific delimiters
cat your_file.txt | awk -F" " '{OFS="\t";}{print $1, $2-1, $3-1, $5}'
# grab certain lines in a file
cat your_file.txt | awk 'FNR==10'