Skip to content

Instantly share code, notes, and snippets.

View Puriney's full-sized avatar

Yun YAN Puriney

View GitHub Profile
@Puriney
Puriney / spliceAnal.py
Last active December 22, 2015 22:29
Python: Splicing Analysis
# Copied From: https://svn.transvar.org/repos/genomes/trunk/pub/src/spliceAnal.py
#!/usr/bin/env python
"""
This file contains code for analyzing novel splicing events from
FindJunctions or Tophat junction features.
If running this interactively, use the writeJunctions method to create
a file that classifies junctions according to whether they are new or
novel, internal or external to a known gene, and their frequency of
@Puriney
Puriney / FM-index.py
Created August 23, 2013 21:29
Python: Lazy FM-index.py
EOS = "$"
'''
All sort algorithm here use the Built-in `sort` function inside Python
'''
refSeq = raw_input("Your ref: ")
if not refSeq:
refSeq = "ACAACG"
def print_table(table):
'''
@Puriney
Puriney / Smith_Warterman.py
Created August 20, 2013 19:49
Python: Smith Waterman
#!/usr/bin/python
from math import *
strG = str(raw_input("Genome sequence: "))
strR = str(raw_input("Read sequence: "))
strG = strG.upper()
strR = strR.upper()
print "Your genome ref input : " +strG
print "Your read ref input : " +strR
matrix = []
@Puriney
Puriney / pROC.R
Created August 13, 2013 03:14
R: ROC
require(pROC)
set.seed(1026)
obs<-rep(0:1, each=50)
pred<-c(runif(50,min=0,max=0.8),runif(50,min=0.3,max=0.6))
plot(roc(obs,pred),print.auc=TRUE, auc.polygon=TRUE,max.auc.polygon=TRUE,auc.polygon.col="#DEEBE8",grid=c(0.1,0.2),grid.col=c("blue","red"),print.thres=TRUE)
@Puriney
Puriney / Bioconductor_DEG.R
Created August 9, 2013 15:31
R: DEG Bioconductor
#### Author: http://web1.sph.emory.edu/users/hwu30/
#### example scripts to play with BAM files.
library(GenomicRanges)
library(GenomicFeatures)
library(Rsamtools)
## first get gene information from UCSC. This will take 2 minutes or so.
## Or if you have these saved you can load them in using: refGene.hg18=loadFeatures("refGene.hg18.GR.sqlite")
refGene.hg18=makeTranscriptDbFromUCSC(genom="hg18",tablename="refGene")
tx=transcripts(refGene.hg18)
@Puriney
Puriney / SimpleSVM.R
Last active December 20, 2015 18:09 — forked from zjf/lazy_man_svm.R
R: SVM
set.seed(1026)
# dummy 2-D data: yi~xi(x1,x2)
x = rbind(cbind(rnorm(50, 1, 0.3), rnorm(50, 2, 0.3)), cbind(rnorm(50, 2, 0.3), rnorm(50, 1, 0.3)))
# [,1] [,2]
# [1,] 1.6565944 1.696906
# [2,] 0.9467358 1.458583
# [3,] 0.9444174 1.513886
# [4,] 0.2480391 2.273355
# [5,] 0.8328066 2.078371
# [6,] 0.9569322 2.174178
@Puriney
Puriney / QuickSort.R
Created July 26, 2013 03:19
R: Quick Sort
qsort <- function(v) {
if ( length(v) > 1 )
{
pivot <- median(v) # median value as pivot value
c(qsort(v[v < pivot]), v[v == pivot], qsort(v[v > pivot]))
} else v
}
@Puriney
Puriney / QuickSort.PL
Created July 26, 2013 01:58
PERL: Quick Sort
#http://rosettacode.org/wiki/Sorting_algorithms/Quicksort#Perl
sub quick_sort {
my @a = @_;
return @a if @a < 2;
my $p = pop @a;
quick_sort(grep $_ < $p, @a), $p, quick_sort(grep $_ >= $p, @a);
}
my @array = (1,4,2,3,6,5,8,7);
@array = quick_sort @array;
print "@array\n";
@Puriney
Puriney / OS X termial theme
Created July 25, 2013 19:24 — forked from puriney2/OS X termial theme
BASH: Terminal Theme
# OS X termial theme
# tell ls to be colourful
export CLICOLOR=1
export LSCOLORS=gxBxhxDxfxhxhxhxhxcxcx
# tell grep to highlight matches
export GREP_OPTIONS='--color=auto'
# alias
alias ls='ls -FGal'
# set custom bash prompt
#export PS1="\[\033[1;34m\]\!\[\033[0m\] \[\033[1;35m\]\u\[\033[0m\]:\[\033[1;35m\]\W\[\033[0m\]$ "
@Puriney
Puriney / insertcode.sublime-snippet
Created July 25, 2013 19:23 — forked from puriney2/insertcode.sublime-snippet
ST: Snippet Insert Codes
<snippet>
<content><![CDATA[
{% highlight ${1:LanguageType} %}
${2:CodesHere}
{% endhighlight %}
$0]]></content>
<tabTrigger>mdcd</tabTrigger>
<scope>text.html.markdown.multimarkdown, text.html.markdown</scope>
</snippet>