class JgiGenesIterator
Public Class Methods
new(jgiGenesGffObj)
click to toggle source
# File lib/jgi_genes.rb, line 242 def initialize(jgiGenesGffObj) @genbank = jgiGenesGffObj # Setup cycle for iterator @cur_gene = @genbank.next_gene @next_gene = @genbank.next_gene @next_is_first = true end
Public Instance Methods
has_next_distance()
click to toggle source
# File lib/jgi_genes.rb, line 251 def has_next_distance return !@next_gene.nil? end
next_distance()
click to toggle source
Return the upstream distance between one gene and another
# File lib/jgi_genes.rb, line 261 def next_distance # if the first gene in the list if @next_is_first # cycle has already been setup in initialisation @next_is_first = false; else #cycle through things if !@cur_gene #if nothing is found raise Exception, 'Unexpected nil cur_gene - a software coding error?' end @prev_gene = @cur_gene @cur_gene = @next_gene @next_gene = @genbank.next_gene end if !@cur_gene raise Exception, 'Overrun iterator - no more genes available. Use has_next_distance' end # We look at the current gene, and return its upstream distance if @cur_gene.positive_strand? # so we want the distance between cur and last then # if last gene undefined or on a different scaffold, return nothing if !@prev_gene or @prev_gene.seqname != @cur_gene.seqname return nil end return @cur_gene.cds_start.to_i - @prev_gene.cds_end.to_i else if !@next_gene or @next_gene.seqname != @cur_gene.seqname return nil end return @next_gene.cds_start.to_i - @cur_gene.cds_end.to_i end end
next_gene()
click to toggle source
Return the next gene to be worked on
# File lib/jgi_genes.rb, line 256 def next_gene return @cur_gene end