Sha256: 410074af19615a069aa31eda1a05d71e503cacad096959a7f448d405bad12ea9

Contents?: true

Size: 1.33 KB

Versions: 116

Compression:

Stored size: 1.33 KB

Contents

require 'rbbt'
require 'rbbt/sources/biomart'
require 'rbbt/sources/entrez'

def tsv_file(url, native, extra, options = {})
  options = Misc.add_defaults options, :persist => false, :keep_empty => true

  case
  when Array === native
    options = Misc.add_defaults options, :key => native.last 
    key_field = native.first
  when (String === native or Integer === native)
    options = Misc.add_defaults options, :key => native
    key_field = nil
  else
    key_field = nil
  end

  case
  when (Array === extra and Array === extra.first)
    options = Misc.add_defaults options, :fields => extra.collect{|e| e.last}
    fields = extra.collect{|e| e.first}
  when (Array === extra and not Array === extra.first)
    options = Misc.add_defaults options, :fields => extra
    fields = (1..extra.length).to_a.collect{|i| "Field#{i}"}
  else
    fields = nil
  end

  tsv = TSV.open(Open.open(url), options)
  tsv.key_field ||= key_field
  tsv.fields    ||= fields
  tsv
end

def merge_entrez(data, taxs, native, fix = nil, select = nil)
  entrez =  Entrez.entrez2native(taxs, :fix => fix, :select => select)
  entrez.key_field = "Entrez Gene ID"
  entrez.fields = [native]
  entrez

  data.attach entrez, "Entrez Gene ID"
end

def merge_biomart(lexicon, db, native, other, match = nil)
  match ||= native.first
  lexicon.attach BioMart.tsv(db, native, other)
end

Version data entries

116 entries across 116 versions & 1 rubygems

Version Path
rbbt-sources-3.1.4 share/install/lib/helpers.rb
rbbt-sources-3.1.3 share/install/lib/helpers.rb
rbbt-sources-3.1.2 share/install/lib/helpers.rb
rbbt-sources-3.1.1 share/install/lib/helpers.rb
rbbt-sources-3.1.0 share/install/lib/helpers.rb
rbbt-sources-3.0.37 share/install/lib/helpers.rb
rbbt-sources-3.0.36 share/install/lib/helpers.rb
rbbt-sources-3.0.35 share/install/lib/helpers.rb
rbbt-sources-3.0.34 share/install/lib/helpers.rb
rbbt-sources-3.0.33 share/install/lib/helpers.rb
rbbt-sources-3.0.32 share/install/lib/helpers.rb
rbbt-sources-3.0.31 share/install/lib/helpers.rb
rbbt-sources-3.0.30 share/install/lib/helpers.rb
rbbt-sources-3.0.29 share/install/lib/helpers.rb
rbbt-sources-3.0.28 share/install/lib/helpers.rb
rbbt-sources-3.0.27 share/install/lib/helpers.rb
rbbt-sources-3.0.26 share/install/lib/helpers.rb
rbbt-sources-3.0.25 share/install/lib/helpers.rb
rbbt-sources-3.0.24 share/install/lib/helpers.rb
rbbt-sources-3.0.23 share/install/lib/helpers.rb