Skip to content

Instantly share code, notes, and snippets.

View ewels's full-sized avatar

Phil Ewels ewels

View GitHub Profile
@ewels
ewels / .bashrc
Created August 27, 2014 07:28
Bash function to extract any compressed file. Code snippet stolen from @robinandeer - https://github.com/robinandeer/dotfiles
# One command to extract them all
extract () {
if [ $# -ne 1 ]
then
echo "Error: No file specified."
return 1
fi
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xvjf $1 ;;
@ewels
ewels / front-page.php
Created March 24, 2014 23:00
Example theme code for Bootstrap Feature Widgets plugin
<?php
// Outputting the widget area on your homepage
// Accomodates one to four active widget areas, fits bootstrap columns accordingly
// front-page.php
$widget_count = 0;
for ($i = 1; $i <= 4; $i++){
if ( is_active_sidebar('homepage-widget-area-'.$i) ) $widget_count++;
}
if ( $widget_count > 0) {
@ewels
ewels / stripplot_SeqMonk_reports.r
Created February 4, 2014 15:24
Make strip plots for all files in a directory
setwd('C:/Your/Directory/Here')
files <- list.files(pattern="txt$")
i <- 0
values <- list()
for(file in files) {
i <- i+1
cc <- c(rep("NULL", 12), "numeric")
values[[i]] <- as.numeric(unlist(read.delim(file, colClasses = cc, skip=1, header = FALSE)))
}
@ewels
ewels / genome_RE_sites.pl
Created August 7, 2013 16:44
A tool to search a genome of your choice for a restriction endonuclease recognition site and output the co-ordinates of all cut sites.
#!/usr/bin/perl
use warnings;
use strict;
#############################################################
# Name: Genome RE Sites #
# Author: Phil Ewels #
# Version 1.0 – 25/05/2011 #
# ————————————————————————————————————————————————————————— #
# Outputs a file with locations of restriction endonuclease #
# sites (not resulting fragments) #
@ewels
ewels / find_uncompressed_files.pl
Created August 7, 2013 16:28
In bioinformatics, raw ASCII text file can get massive. This script sniffs out large uncompressed text files and sends their paths to STDOUT for piping to a file or zipping command.
#/usr/bin/perl
use warnings;
use strict;
use Cwd;
use File::Find;
####
# FIND UNCOMPRESSED FILES
# Prints the full path of any files larger than 50mb which are uncompressed
# One file path per newline, so output can be piped to other tools, eg:
# perl find_uncompressed_files.pl | xargs gzip