Class: BlastHit

Inherits:
Object
  • Object
show all
Defined in:
lib/rocker/blasthit.rb

Overview

Author:

  • Luis M. Rodriguez-R <lmrodriguezr at gmail dot com>

  • Luis (Coto) Orellana

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ln, aln = nil) ⇒ BlastHit

Initialize from BLAST using new(ln,aln), initialize from TABLE using new(ln)



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rocker/blasthit.rb', line 11

def initialize(ln, aln=nil)
   l = ln.chomp.split(/\t/)
   if aln.nil?
	 @sbj	= l[0]
	 @sfrom	= l[1].to_i
	 @sto	= l[2].to_i
	 @bits	= l[3].to_f
	 @istrue = l[4]=='1'
	 @midpoint = l[5].to_i
   else
	 s = aln.seq(l[1])
	 return nil if s.nil?
	 @sbj	= s.id
	 a	= s.pos2col(l[8].to_i)
	 b 	= s.pos2col(l[9].to_i)
	 @sfrom	= [a,b].min
	 @sto	= [a,b].max
	 @bits	= l[11].to_f
	 @istrue = ! /@%/.match(l[0]).nil?
	 @midpoint = s.pos2col(((l[8].to_f+l[9].to_f)/2).ceil)
   end
end

Instance Attribute Details

#bitsObject (readonly)

Returns the value of attribute bits.



9
10
11
# File 'lib/rocker/blasthit.rb', line 9

def bits
  @bits
end

#istrueObject (readonly)

Returns the value of attribute istrue.



9
10
11
# File 'lib/rocker/blasthit.rb', line 9

def istrue
  @istrue
end

#midpointObject (readonly)

Returns the value of attribute midpoint.



9
10
11
# File 'lib/rocker/blasthit.rb', line 9

def midpoint
  @midpoint
end

#sbjObject (readonly)

Returns the value of attribute sbj.



9
10
11
# File 'lib/rocker/blasthit.rb', line 9

def sbj
  @sbj
end

#sfromObject (readonly)

Returns the value of attribute sfrom.



9
10
11
# File 'lib/rocker/blasthit.rb', line 9

def sfrom
  @sfrom
end

#stoObject (readonly)

Returns the value of attribute sto.



9
10
11
# File 'lib/rocker/blasthit.rb', line 9

def sto
  @sto
end

Instance Method Details

#to_sObject



33
34
35
36
37
# File 'lib/rocker/blasthit.rb', line 33

def to_s
   self.sbj.nil? ? "" :
	 [self.sbj, self.sfrom.to_s, self.sto.to_s, self.bits.to_s,
  self.istrue ? '1' : '0', self.midpoint].join("\t") + "\n"
end