Skip to content

Instantly share code, notes, and snippets.

@tfuji
tfuji / genome_reports2ttl.rb
Last active August 29, 2015 14:02
genome_reports2ttl_v2.rb
#!/usr/bin/env ruby
#
# convert genome_reprots to RDF
# * ftp://ftp.ncbi.nlm.nih.gov/genomes/GENOME_REPORTS/prokaryotes.txt
# * ftp://ftp.ncbi.nlm.nih.gov/genomes/GENOME_REPORTS/eukaryotes.txt
#
require 'date'
#!/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
@tfuji
tfuji / parse_st.rb
Created March 14, 2016 10:59
INSDC structured comment parser
#!/usr/bin/env ruby
require 'rubygems'
require 'bio'
def parse_st_comment comment
tagset_id = nil
tag_name = tag_value = ''
st = Hash.new { |h,k| h[k] = {} }
comment.split("\n").each do |line|
@tfuji
tfuji / ft_rfam.json
Last active June 30, 2016 09:58
Rfam 12.1 to INSDC feature table mapping based on ftp://ftp.ebi.ac.uk/pub/databases/Rfam/11.0/misc/Rfam2INSDC.types
This file has been truncated, but you can view the full file.
{
"RF00001": {
"AC": "RF00001",
"ID": "5S_rRNA",
"DE": "5S ribosomal RNA",
"feature": "rRNA",
"qualifiers": [
{
"product": "5S ribosomal RNA"
},
@tfuji
tfuji / biosample2ttl.rb
Created February 20, 2015 02:17
biosample2ttl.rb v0.2
#!/usr/bin/env ruby
require 'nokogiri'
require 'erb'
#require 'uri'
#require 'pp'
class BioSampleSet
include Enumerable
#require 'open-uri'
require 'rdf/raptor'
require 'json'
require 'json/ld'
require 'pp'
require "faraday"
require 'faraday_middleware'
require 'fileutils'
require 'systemu'
#!/usr/bin/env ruby
require 'nokogiri'
#require 'erb'
require 'pp'
require 'json'
#require 'thor'
# 1. wget https://www.ncbi.nlm.nih.gov/biosample/docs/attributes/?format=xml -O ncbi_biosample_attributes.xml
# 2. %ruby ncbi_biosample_attributes_extend2ttl.rb ncbi_biosample_attributes.xml > biosample_attributes_extend.ttl
#!/usr/bin/env ruby
#
# ruby load_sample.rb biosample/annotated_json dev
require 'elasticsearch'
require 'json'
require 'pp'
#client = Elasticsearch::Client.new({log: true, hosts: { host: 'localhost', user: 'user', password: 'password' }})
client = Elasticsearch::Client.new({log: true, hosts: { host: 'localhost'}})
@tfuji
tfuji / es_msearch_test.rb
Last active October 30, 2019 02:33
es_msearch_test.rb
#!/usr/bin/env ruby
require 'elasticsearch'
require 'json'
require 'pp'
begin
#client = Elasticsearch::Client.new({log: true, hosts: { host: 'localhost'}})
client = Elasticsearch::Client.new({hosts: { host: 'localhost', port: 9291 }})
q ='water'
from = 0
size = 20
@tfuji
tfuji / json2ld-context.json
Last active December 24, 2019 02:48
togovar
{
"@context": [
"https://schema.org/docs/jsonldcontext.json",
{
"@vocab": "http://togovar.biosciencedbc.jp/ontology/",
"tgv": "http://togovar.biosciencedbc.jp/ontology/",
"dcterms": "http://purl.org/dc/terms/",
"m2r": "http://med2rdf.org/ontology/med2rdf",
"faldo": "http://biohackathon.org/resource/faldo#",
"obo": "http://purl.obolibrary.org/obo/",