Class: BlastQuery
- Inherits:
-
Object
- Object
- BlastQuery
- Defined in:
- lib/scbi_blast/blast_query.rb
Overview
Object to encapsulate a Blast Query
Instance Attribute Summary collapse
-
#full_query_length ⇒ Object
Returns the value of attribute full_query_length.
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#query_def ⇒ Object
Returns the value of attribute query_def.
-
#query_id ⇒ Object
Returns the value of attribute query_id.
Instance Method Summary collapse
-
#add_hit(h) ⇒ Object
add a hit to query.
- #compare?(query) ⇒ Boolean
-
#initialize(query_id) ⇒ BlastQuery
constructor
initializes a new Query object.
-
#inspect ⇒ Object
inspect query values with all hits.
-
#merged_hits!(overlap_threshold = 0, merged_ids = nil) ⇒ Object
merge overlapping hits.
-
#size ⇒ Object
get num of hits.
-
#sort(comand) ⇒ Object
sort hits by command.
Constructor Details
#initialize(query_id) ⇒ BlastQuery
initializes a new Query object
30 31 32 33 34 35 36 |
# File 'lib/scbi_blast/blast_query.rb', line 30 def initialize(query_id) @query_id = query_id @query_def = query_id @full_query_length = 0 @hits = [] # inspect end |
Instance Attribute Details
#full_query_length ⇒ Object
Returns the value of attribute full_query_length.
27 28 29 |
# File 'lib/scbi_blast/blast_query.rb', line 27 def full_query_length @full_query_length end |
#hits ⇒ Object
Returns the value of attribute hits.
26 27 28 |
# File 'lib/scbi_blast/blast_query.rb', line 26 def hits @hits end |
#query_def ⇒ Object
Returns the value of attribute query_def.
27 28 29 |
# File 'lib/scbi_blast/blast_query.rb', line 27 def query_def @query_def end |
#query_id ⇒ Object
Returns the value of attribute query_id.
27 28 29 |
# File 'lib/scbi_blast/blast_query.rb', line 27 def query_id @query_id end |
Instance Method Details
#add_hit(h) ⇒ Object
add a hit to query
39 40 41 |
# File 'lib/scbi_blast/blast_query.rb', line 39 def add_hit(h) @hits.push h end |
#compare?(query) ⇒ Boolean
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/scbi_blast/blast_query.rb', line 78 def compare?(query) res=true # same hits res &&=( @hits.count==query.hits.count) # if !res # puts "Queries not equal:" # puts inspect # puts "="*20 # puts query.inspect # end if res @hits.each_with_index do |h,i| res &&= h.compare?(query.hits[i]) end end # if !res # puts "Queries hits not equal:" # puts inspect # puts "="*20 # puts query.inspect # end res &&=( @query_id==query.query_id) res &&=( @query_def==query.query_def) res &&=( @full_query_length==query.full_query_length) return res end |
#inspect ⇒ Object
inspect query values with all hits
44 45 46 47 48 49 50 |
# File 'lib/scbi_blast/blast_query.rb', line 44 def inspect res = "\n * Query #{@query_id}, #{@query_def}, #{@full_query_length} :" res += "subject_id ident align_len mismatches gaps q_beg q_end s_beg s_end e_val bit_score reversed\n\n" @hits.each{ |h| res+= "=="+h.inspect+"\n" } return res end |
#merged_hits!(overlap_threshold = 0, merged_ids = nil) ⇒ Object
merge overlapping hits
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/scbi_blast/blast_query.rb', line 63 def merged_hits!(overlap_threshold=0, merged_ids=nil) res = [] merge_hits(@hits,res,merged_ids) begin res2=res # iterate until no more overlaps res = [] merge_hits(res2,res,merged_ids) end until (res2.count == res.count) return res end |
#size ⇒ Object
get num of hits
53 54 55 |
# File 'lib/scbi_blast/blast_query.rb', line 53 def size return @hits.size end |
#sort(comand) ⇒ Object
sort hits by command
58 59 60 |
# File 'lib/scbi_blast/blast_query.rb', line 58 def sort(comand) return @hits.sort(comand) end |