Sha256: 49bea5a5249b12cae4240747d1907c4daf79bde85c84a1332e4d19635af389f9

Contents?: true

Size: 1.34 KB

Versions: 1

Compression:

Stored size: 1.34 KB

Contents


class Bio::Blat
  def self.align(database , query , output)
    cmdline = "blat #{database} #{query}  #{output}"
    puts $stderr.puts cmdline
    status, stdout, stderr = systemu cmdline
    if status.exitstatus == 0
      alns = Array.new unless block_given?
      blat_aln = Bio::Blat::Report.new(Bio::FlatFile.open(output).to_io)
      #p blat_aln
      blat_aln.each_hit() do |hit|
        if block_given?
          yield hit
        else
          alns << hit
        end
      end
      return alns unless block_given?
    else
      raise Exception.new(), "Error running exonerate. Command line was '#{cmdline}'\nBlat STDERR was:\n#{stderr}"
    end
  end
end

class Bio::Blat::Report::Hit
  
  #Function to parse stuff like: IWGSC_CSS_1AL_scaff_110
  def wheat_chr_arm
    @wheat_chr_arm if @wheat_chr_arm
    @wheat_chr_arm = target_id.split('_')[2]
  end
  
  def wheat_chr
    wheat_chr_arm[0,2]
  end
  
  def wheat_chr_group 
    raise Exception.new(), "No wheat group for #{target_id} #{self.inspect}"  unless wheat_chr
    wheat_chr_arm[0]
  end
  
  def wheat_genome
    wheat_chr_arm[1]
  end
  
  def wheat_arm
    wheat_chr_arm[2]
  end
  
  def percentage_covered
    ( match + mismatch ) * 100.0 / query_len.to_f
  end
  
end


class Hash
  def join(keyvaldelim=$,, entrydelim=$,)
    map {|e| e.join(keyvaldelim) }.join(entrydelim)
  end
end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bio-polyploid-tools-0.4.1 lib/bio/BIOExtensions.rb