Skip to content

Instantly share code, notes, and snippets.

View yagays's full-sized avatar
🦊
hi

Yuki Okuda yagays

🦊
hi
View GitHub Profile
# -*- coding: utf-8 -*-
require "pp"
require "optparse"
def open_t_delimited_file(filename)
h = { }
File.open(filename).readlines.each do |line|
a = line.split("\t")
if /\d+/ =~ a[6]
if h[a[0]] #もし既にidとfpkmの配列がhに入っている場合
#!/bin/sh
#$ -o cuffout.txt -e cufferr.txt
LD_LIBRARY_PATH=/usr/local/boost-1.40.0/lib
export LD_LIBRARY_PATH
/usr/local/cufflinks-0.8.2/bin/cufflinks -p 2 $1
@yagays
yagays / bedgraph.rb
Created August 17, 2010 23:40
tmapっぽい形式のファイルから全遺伝子IDそれぞれのwigファイル(bedgraph format)を作成します.
#/usr/bin/env ruby
require "pp"
require "optparse"
# Usage : ruby bedgraph.rb [-o output_dir] input_file
# Output_dir is optional. Default output_dir is "bedgraph".
#
# Input_file format must be tab delimited file and the following format below.
# gene_id gene_name fpkm chr start end
#
@yagays
yagays / parser.rb
Created August 19, 2010 10:03
タブ区切りテキストをmarshal_dump, marshal_loadするスクリプト
#/usr/bin/env ruby
def open_t_delimited_file(filename)
h = {}
File.open(filename).readlines.each do |line|
a = line.split("\t")
h[a[0]] = a
end
puts filename.to_s + " was loaded."
return h
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
require "pp"
def input_marshal_data(path)
a = 0
a_id_list = []
open(path,"rb") {|f|
a = Marshal.load(f)
#/usr/bin/env ruby
def open_indel_file(filename)
h = []
open(filename) { |f|
f.each_line do |line|
a = line.chomp.split("\t")
h << a
end
@yagays
yagays / _samtools
Created October 23, 2011 04:09
zsh completion function of samtools
#compdef samtools
################################################
# SAMtools commands and options are based on ver. 0.1.18
# http://samtools.sourceforge.net/samtools.shtml
#
# Edited by yag_ays 2011.10.25
################################################
_samtools() {
@yagays
yagays / naive-bayes.clj
Created February 3, 2012 05:21
naive-bayes(clojure)
;; 訓練データ
(def text_classified_p '(["good" "bad" "good" "good"]
["exciting" "exciting"]
["good" "good" "exciting" "boring"]))
(def text_classified_n '(["bad" "boring" "boring" "boring"]
["bad" "good" "bad"]
["bad" "bad" "boring" "exciting"]))
;;多変数ベルヌーイモデル
(defn train [features]
;;; 文字列の指定
(def sentence "mississippi")
(def sentence "Ask not what your country can do for you but what you can do for your country")
;;; 接尾辞リストを作る
(defn tail [x]
(loop [s x result []]
(if (empty? s) (conj result s) (recur (apply str (rest s)) (conj result s) ))))
;;; ソートする
(map #(if (zero? (rem % 3))
(if (zero? (rem % 5))
"fizzbuzz"
"fizz")
(if (zero? (rem % 5))
"buzz"
%))
(range 1 101))