Skip to content

Instantly share code, notes, and snippets.

View ktym's full-sized avatar

Toshiaki Katayama ktym

  • Database Center for Life Science
  • Japan
View GitHub Profile
@ktym
ktym / unwebarchive.rb
Created February 12, 2013 18:03
Extract contents of a .webarchive file.
#!/usr/bin/env ruby
#
# Mac OS X webarchive is a binary format of a plist file. You can extract the contents manually:
# 1. convert the plist file into XML by "plutil -convert xml1 file.webarchive"
# 2. parse the resulted XML file by some XML parser
# 3. decode "WebResourceData" by Base64.decode64(data) in each key
# 4. save the decoded content into a file indicated by "WebResourceData"
# Thankfully, the plist library can take care of annoying steps 2 and 3.
#
# Preparation:
"""
Example RDF/Turtle:
hnt:A0A024QYV7-Q00653
bp3:dataSource <http://identifiers.org/HINT> ;
bp3:displayName "A0A024QYV7-Q00653"^^xsd:string ;
bp3:evidence pint:evidence-pubmed_14743216-MI_0007-literature-curated , pint:evidence-pubmed_14743216-MI_0676-literature-curated ;
bp3:name "A0A024QYV7-Q00653"^^xsd:string ;
bp3:participant [
obo:BFO_0000051 uni:A0A024QYV7 ;
@ktym
ktym / bwt.rb
Created September 29, 2018 01:06
#!/usr/bin/env ruby
#
# https://qiita.com/erukiti/items/f11f448d3f4d73fbc1f9
# https://research.preferred.jp/2012/11/burrows-wheeler-transform-lf-mapping/
#
class BWT
def initialize(str)
@str = str + '$'
#!/usr/bin/env ruby
require 'json'
uniq = File.open("uniq_node.txt").map {|x| x.stip.to_i}
json = JSON.parse(ARGF.read)
json.each do |ary|
read_id = ary.shift
#!/usr/bin/env ruby
matrix = []
ARGF.each do |line|
ary = line.strip.split
matrix << ary
end
matrix.transpose.each do |row|
# Dockerfile for https://github.com/dbcls/sparqlist
FROM ubuntu:16.04
ARG node_version=v7.9.0
RUN apt-get -qq update && apt-get -qq install -y \
pkg-config \
sudo \
curl \
#!/usr/bin/env ruby-2.3
=begin
# SPARQL endpoint
https://stirdf.jglobal.jst.go.jp/sparql
# SPARQL query
select *
where {
?term a skos:Concept ;
@ktym
ktym / sparql.rb
Last active June 30, 2016 07:24
SPARQL query interface
#!/usr/bin/env ruby
require "rubygems"
require "net/http"
require "uri"
require "cgi"
require "json" # gem install json
class SPARQL
@ktym
ktym / sparql2das.rb
Created January 18, 2014 10:07
Generate BioDAS XML from a SPARQL endpoint which stores genome sequences/annotations using FALDO
#!/usr/bin/env ruby
#
# Usage:
# DAS XML for http://togogenome.org/das/645657/features?segment=NC_017196.1:1,100000 can be generated by
# % ruby sparql2das.rb 645657 features segment=NC_017196.1:1,100000
# With ruby -d option, you'll see debug massages with pretty formatted XML (will miss <?xml> tag though)
#
# TODO:
# Wrap as an Rack app and add X-DAS-* HTTP headers
#
@ktym
ktym / .emacs
Last active December 20, 2015 02:09
Configuration for multi-line editing mode in Emacs 24.
;;; library
(let ((default-directory "~/lib/lisp"))
(normal-top-level-add-subdirs-to-load-path))
;; multiple-cursors
; % git clone https://github.com/magnars/multiple-cursors.el.git
; % mv multiple-cursors.el lib/lisp/multiple-cursors