Sha256: e0d670a52341ef41f5b52678589393e0b7f1525cafbb94dfd61964f9e19feb1b

Contents?: true

Size: 1.49 KB

Versions: 35

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

35 entries across 35 versions & 1 rubygems

Version Path
rbbt-rest-1.8.45 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.44 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.43 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.42 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.41 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.40 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.38 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.37 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.36 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.35 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.34 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.32 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.31 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.30 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.29 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.28 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.27 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.26 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.25 lib/rbbt/rest/helpers.rb
rbbt-rest-1.8.23 lib/rbbt/rest/helpers.rb