Skip to content

Instantly share code, notes, and snippets.

@mojaveazure
mojaveazure / downloadSRA.sh
Last active September 2, 2015 16:27
A simple shell script to download samples from the SRA
#!/bin/bash
set -e
set -u
set -o pipefail
if ! `command -v fastq-dump > /dev/null 2> /dev/null`
then
echo "Can't find fastq-dump!"
exit 1
@mojaveazure
mojaveazure / subsample.sh
Last active June 8, 2023 22:12
A script to subsample Fasta/FastQ files using Seqtk
#!/bin/bash
set -e
set -u
set -o pipefail
# A script to subsample Fasta/FastQ files using Seqtk
if ! `command -v seqtk > /dev/null 2> /dev/null`
then
echo "Failed to find seqtk!"
@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
@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 / 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 / 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 / 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 / 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 / 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 / .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 #