Skip to content

Instantly share code, notes, and snippets.

@cmdcolin
cmdcolin / twitter_updater.sh
Last active April 2, 2016 23:15
Command for updating twitter with all the commands you run; add to your bashrc/zshrc
preexec() {
[[ $1 == "git status" || $1 == "cd"* || $1 == "ll"* || $1 == "vim"* ]] || t update "$1"
}
@cmdcolin
cmdcolin / agp2gff3
Last active April 2, 2016 17:35
Convert AGP file into GFF to show gaps in genome assembly
#!/usr/bin/env Rscript
library(data.table)
library(R.utils)
source="agpfile"
type="scaffold"
args <- commandArgs(trailingOnly = TRUE)
if(length(args)<1) {
stop("Usage: agp2gff3 file.agp > file.gff")
@cmdcolin
cmdcolin / chain2bam.pl
Created April 12, 2016 19:54
A crazy method for converting a UCSC chain file into a BAM read with deletions and insertions
use strict;
use Bio::DB::Fasta;
my $inx = Bio::DB::Fasta->new('btau5_alignments');
my $flag = 0;
my @arr;
my $cigar;
my $seq;
while(<>) {
@cmdcolin
cmdcolin / chain2gff.pl
Last active June 10, 2016 20:41
A crazy method for converting a UCSC chain file to GFF
#!/usr/bin/env perl
use strict;
# chain line
my ($score, $tName, $tSize, $tStrand, $tStart, $tEnd, $qName, $qSize, $qStrand, $qStart, $qEnd, $cId);
# track positions
my $qCurrentPos;
my $qCurrentEnd;
@cmdcolin
cmdcolin / ggplot_time_series.R
Created April 26, 2016 23:06
GGplot time series
library(lubridate)
library(ggplot2)
library(data.table)
x=fread('test2.txt')
x$V1=(lubridate::period_to_seconds(hm(x$V1))-lubridate::period_to_seconds(hm(x$V1[1])))/60
png('test.png',width=1000,height=600)
ggplot(x,aes(V1,V2)) + stat_smooth() + geom_point() + xlab('Time (minutes)') + ylab('Annotations loaded') + ggtitle('Annotations loaded Apollo')
@cmdcolin
cmdcolin / snap2gff.pl
Last active June 15, 2021 09:37
Convert snap to gff
#!/usr/bin/env perl
use strict;
use warnings;
# accept SNAP ("ZFF") format such as
# >chr1
# Einit 5343 5444 + 8.956 0 0 2 chr1-snap.1
# Exon 6401 6498 + -0.203 0 2 1 chr1-snap.1
# Eterm 6727 6781 + 7.370 1 0 1 chr1-snap.1
@cmdcolin
cmdcolin / filetimes.R
Created April 26, 2016 23:24
R animation and command line arguments example
#!/usr/bin/env Rscript
library(animation)
library(getopt)
args <- commandArgs(trailingOnly = TRUE)
library('getopt');
#get options, using the spec as defined by the enclosed list.
#we read the options from the default: commandArgs(TRUE).
spec = matrix(c(
'help' , 'h', 0, "logical",
@cmdcolin
cmdcolin / twitter_fishshell.sh
Last active May 16, 2016 14:58
Twitter fishshell
function preexec_test --on-event fish_preexec
switch $argv
case 'cd*'
case 'ssh*'
case 'll*'
case 'git status*'
case 'git commit*'
case '*'
t update $argv
end
@cmdcolin
cmdcolin / cia_factbook.Rmd
Created July 24, 2016 03:16
Playing with CIA world factbook data
---
title: "World Factbook"
author: "Colin Diesh"
date: "July 23, 2016"
output: html_document
---
```{r setup, include=FALSE}
library(ggplot2)
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="genome.css">
<title>SOAP JavaScript Client Test</title>
<style type="text/css">
.header {
height:50px;
background:#A0C0F0;