Skip to content

Instantly share code, notes, and snippets.

@mojaveazure
mojaveazure / fakeHeader.sh
Last active October 16, 2018 21:57
A simple script to add the `@HD` header line to a SAM or BAM file in case it wasn't added at the time of creation.
#!/bin/bash
set -e
set -u
set -o pipefail
# Define the usage message
function usage() {
echo -e "\
Usage: ./fakeHeader.sh <option> <file> \n\
@mojaveazure
mojaveazure / soNeedy.sh
Last active April 29, 2019 18:20
A simple script to copy files defined by a list in parallel
#!/bin/bash
set -e
set -u
set -o pipefail
# A simple script to find files listed in a text file and copy them elsewhere
# Written for Chaochih Liu
# Written by Paul Hoffman
@mojaveazure
mojaveazure / .gitignore
Last active August 29, 2015 14:24 — forked from octocat/.gitignore
Nearly-universal .gitignore
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Byte code #
@mojaveazure
mojaveazure / lineCount.py
Last active August 29, 2015 14:25
A simple Python script to get the line count of a file
#!/usr/bin/env python
import sys
try:
import argparse
except ImportError:
sys.exit("Failed to import the argparse library. Please install for Python 2.6 or use Python 2.7 or higher")
Arguments = argparse.ArgumentParser(add_help=True)
Arguments.add_argument('-f',
@mojaveazure
mojaveazure / regionsExtracter.sh
Last active February 29, 2016 18:53
Extract a list of regions defined listed in a BAM file using SAMTools
#!/bin/bash
set -e
set -o pipefail
# Extract regions from a BAM file
# Make sure SAMTools is installed
if ! `command -v samtools > /dev/null 2> /dev/null`
then
@mojaveazure
mojaveazure / basename.py
Created August 6, 2015 20:19
Basename in Python
#!/usr/bin/env python
# A script to get the basename of a file in Python
# Import modules from the standard Python library
import sys
import os
try:
import argparse
except ImportError:
@mojaveazure
mojaveazure / UpdateSettings.sh
Last active June 30, 2017 16:00
My settings files for things
#!/bin/bash
set -eo pipefail
read -p "Choose settings to link: " -a SETTINGS
declare -a SETTINGS=($(echo ${SETTINGS[@]} | tr -d '[:space:]' | grep -o . | sort -u | tr '\n' ' '))
declare -a SETTINGS=($(echo ${SETTINGS[@]} | tr '[:upper:]' '[:lower:]'))
for setting in ${SETTINGS[@]}; do
@mojaveazure
mojaveazure / myFuncs.R
Last active August 29, 2015 14:27
Some R functions that I've found useful
#!/usr/bin/env Rscript
# bootstrap
# A function to bootstrap some data
bootstrap <- function(tmp.data) {
boot.rep <- sample(x = tmp.data, replace = T)
return(mean(boot.rep))
}
# push
@mojaveazure
mojaveazure / singSong.sh
Last active May 9, 2016 03:49
A few ways to make a Mac sing.
#!/binb/bash
# Pomp and Circumstance
say -v Good oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo \
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo \
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo \
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo \
oooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo
# In the Hall of the Mountain King
@mojaveazure
mojaveazure / getCoverage.sh
Last active June 3, 2016 13:06
Calculate the coverage for multiple samples in parallel from histograms generated by BEDTools
#!/bin/bash
set -e
set -u
set -o pipefail
# A simple script to calculate coverage depth
# from the text files from BEDTools coverage
function Usage() { # Display a usage message and exit