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:
@ktym
ktym / insdc.owl
Created December 12, 2012 08:49
Draft version of INSDC (DDBJ/EMBL/GenBank/RefSeq) ontology in RDF/Turtle format.
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix obo: <http://purl.obolibrary.org/obo/> .
@prefix : <http://insdc.org/owl/#> .
<http://insdc.org/owl/>
a owl:Ontology .
@ktym
ktym / rs_id.json
Last active October 13, 2015 05:27
RefSeq db_xref to Identifiers.org mapping
{
/*
* NCBI RefSeq
*/
"RefSeq": {
"label": "NCBI RefSeq", // custom
"class": "RefSeq",
"prefix": "http://identifiers.org/refseq/"
},
@ktym
ktym / miriam_xml2rdf.rb
Created October 31, 2012 07:51
MIRIAM XML to RDF
#!/usr/bin/env ruby
#
# Convert MIRIAM Registry XML file (http://www.ebi.ac.uk/miriam/main/export/) to RDF
#
# Copyright (C) 2012 Toshiaki Katayama <[email protected]>
#
# Pre requirements:
# % curl http://www.ebi.ac.uk/miriam/main/export/xml/ > miriam.xml
# % gem install nokogiri
# % miriam_xml2rdf.rb miriam.xml > miriam.rdf
@ktym
ktym / biogitax.rb
Created October 1, 2012 13:54
Classify NCBI GI numbers into given clades (NCBI taxids)
#!/usr/bin/env ruby-1.9
ENV["BIO_GITAX_DB"] = "#{ENV['HOME']}/ncbi/taxonomy/gitax"
require "rubygems"
require "open-uri"
require "fileutils"
begin
require "kyotocabinet"
@ktym
ktym / PfCRT.ttl
Created October 1, 2012 09:19
Example of refseq2rdf_urn.rb (PfCRT gene in NC_004328.2)
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
# SO:chromosome, SO:linear
<urn:uuid:63a091c1-1409-4a91-9f46-db9b04bce8f6>
<http://genome.db/sw/feature_chromosome> 7 ;
<http://genome.db/sw/feature_isolate> "3D7" ;
<http://genome.db/sw/length> 1501717 ;
<http://genome.db/sw/location> "1..1501717" ;
<http://genome.db/sw/molecularType> "genomic DNA" ;
<http://genome.db/sw/organism> "Plasmodium falciparum 3D7" ;
@ktym
ktym / refseq2rdf_urn.rb
Created October 1, 2012 08:58
Convert RefSeq genome entry into RDF/Turtle using FALDO (BH12) and URN
#!/usr/bin/env ruby-1.9
require 'rubygems'
require 'uri'
require 'bio'
require 'json'
require 'securerandom'
# [TODO] integrate this into BioRuby
module Bio
@ktym
ktym / refseq2rdf.rb
Created September 12, 2012 04:30
Convert RefSeq genome entry into RDF/Turtle using FALDO (BH12)
#!/usr/bin/env ruby-1.9
require 'rubygems'
require 'bio'
require 'json'
require 'securerandom'
# [TODO] true to combine the result with the EdgeDB
if $DEBUG
$edgedb = true
@ktym
ktym / ft_so.json
Last active October 10, 2015 06:48
INSDC feature table to OBO sequence ontology mapping based on http://sequenceontology.org/resources/mapping/FT_SO.html
{
"-": {
"so_id": "SO:0000110",
"so_term": "located_sequence_feature",
"ft_desc": "\"-\" is a placeholder for no key; should be used when the need is merely to mark region in order to comment on it or to use it in another feature's location",
"so_desc": "A biological feature that can be attributed to a region of biological sequence."
},
"-10_signal": {
"so_id": "SO:0000175",
"so_term": "minus_10_signal",
@ktym
ktym / sparql.rb
Last active June 20, 2024 20:45
SPARQL query interface
#!/usr/bin/env ruby
require "rubygems"
require "net/http"
require "uri"
require "cgi"
require "json" # gem install json
class SPARQL