Sha256: 4079d8d5d5421d69b3ef394395dc930a801c688b187fdb95c34e0a479580644d

Contents?: true

Size: 1.49 KB

Versions: 147

Compression:

Stored size: 1.49 KB

Contents

module Sinatra
  module RbbtMiscHelpers
    def OR_matrices(m1, m2)
      samples = m1.fields
      new = TSV.setup({}, :key_field => "Ensembl Gene ID", :fields => samples)

      m1.each do |gene, values|
        new[gene] = values
      end

      m2.each do |gene, values|
        if new.include? gene
          new[gene] = new[gene].zip(values).collect do |old, new|
            case
            when old == new
              old
            else
              "TRUE"
            end
          end
        else
          new[gene] = values
        end
      end

      new
    end

    def exome_bed_file_for_genes(genes)
      bed = TSV.setup({}, :key_field => "Ensembl Exon ID", :fields => %w(chr start end gene), :type => :list)
      organism = genes.organism
      exon_info = Organism.exons(organism).tsv :fields => ["Chromosome Name", "Exon Chr Start", "Exon Chr End"], :persist => true
      exons_for = Organism.exons(organism).tsv :key_field => "Ensembl Gene ID", :fields => ["Ensembl Exon ID"], :persist => true, :merge => true, :type => :flat
      genes.each do |gene|
        exons = exons_for[gene.ensembl]
        exons.each do |exon|
          chr, start, eend = exon_info[exon]
          bed[exon] = [chr, start, eend, gene]
        end
      end
      bed
    end

    def format_name(name)
      parts = name.split("_")
      hash = parts.pop
      clean_name = parts * "_"
      "<span class='name' jobname='#{ name }'>#{ clean_name }</span><span class='hash'>#{ hash }</span>"
    end
  end
end

Version data entries

147 entries across 147 versions & 1 rubygems

Version Path
rbbt-rest-1.8.7 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.6 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.5 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.4 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.3 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.2 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.1 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.0 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.20 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.19 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.18 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.17 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.16 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.15 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.14 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.13 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.12 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.11 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.10 lib/rbbt/rest/helpers.rb
rbbt-rest-1.7.9 lib/rbbt/rest/helpers.rb