Skip to content

Instantly share code, notes, and snippets.

View ewels's full-sized avatar

Phil Ewels ewels

View GitHub Profile
@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
@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 / 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 / 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 / .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 August 27, 2014 20:01
Child front-page.php for a full width carousel using the Unite wordpress theme: https://github.com/puikinsh/Unite-Theme
<?php
if ( get_option( 'show_on_front' ) == 'posts' ) {
get_template_part( 'index' );
} elseif ( 'page' == get_option( 'show_on_front' ) ) {
get_header();
while ( have_posts() ) : the_post();
@ewels
ewels / cytobands.pl
Created September 17, 2014 07:31
Cytoband Coordinate Converter
#!/usr/bin/perl
use CGI::Carp qw(fatalsToBrowser); # pipe errors to the browser instead of the terminal for debugging
use warnings;
use strict;
use Data::Dumper;
#print Dumper(\%args);
print "Content-type: text/plain\n\n";
#############################################################
# Name: Cytobands - Coordinates: Online Version #
@ewels
ewels / sra_illumina_stats.r
Created September 18, 2014 16:57
SRA Sequencing Platform Statistics
#' ---
#' title: "SRA Sequencing Platform Analysis"
#' author: "Phil Ewels"
#' date: September 2014
#' ---
#' The Sequence Read Archive [(SRA)](http://www.ncbi.nlm.nih.gov/sra)
#' contains the raw DNA-sequencing data for many published datasets.
#' We were interested in which sequencing platforms were prevalent,
#' or rather, how prevalent Illumina Sequencing is. We were specifically
@ewels
ewels / rcolorbrewer_example.html
Created December 5, 2014 12:37
RColorBrewer example
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
@ewels
ewels / check_bismark_analysis.sh
Last active August 18, 2016 15:24
Quick and dirty script to check for common warning signs in a Bismark BS-seq methylation analysis
#!/bin/bash
# Check bisulfite analysis results for any modes of failure that I can think of.
# Assumes data is processed by Cluster Flow / bismark and is in subdirectories.
# For a basic quick summary, just run:
# bash check_bismark_analysis.sh
# To filter which subdirectories are checked, pass a glob expression. For example:
# bash check_bismark_analysis.sh run2_*