Sha256: 4a6ddd07653ef22d7d2b24526ba736f71d2824b0da1c8ff57e5b1afefd1730f9

Contents?: true

Size: 744 Bytes

Versions: 5

Compression:

Stored size: 744 Bytes

Contents

#!/usr/local/bin/ruby-1.9

# usage:
# ./num-gene-exon <genomic-interval>
# example:
# ./num-gene-exon chr1:12345-45678
#
# Based on hg18-RefSeq genes table, print a list of included genes,
# number of genes, and maximum number of exons.
#

require 'bio-ucsc'

interval = Bio::GenomicInterval.parse(ARGV[0])

Bio::Ucsc::Hg18::DBConnection.connect

genes = Bio::Ucsc::Hg18::RefGene.with_interval(interval).find(:all).map{|e|e.name2}.uniq
puts "Included  genes:"
puts genes
puts "Number of genes:"
puts genes.size

total_exons = 0
genes.each do |gene|
  total_exons +=
    Bio::Ucsc::Hg18::RefGene.
    with_interval(interval).
    find_all_by_name2(gene).
    map{|e|e.exonCount}.
    max
end

puts "Number of exons (maximum):"
puts total_exons

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bio-ucsc-api-0.5.3 samples/num-gene-exon.rb
bio-ucsc-api-0.5.2 samples/num-gene-exon.rb
bio-ucsc-api-0.5.1 samples/num-gene-exon.rb
bio-ucsc-api-0.5.0 samples/num-gene-exon.rb
bio-ucsc-api-0.4.0 samples/num-gene-exon.rb