scbi_blast 0.0.31 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +2 -2
- data/lib/scbi_blast/blast_hit.rb +8 -0
- data/lib/scbi_blast/blast_query.rb +48 -5
- data/lib/scbi_blast.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -12,7 +12,7 @@ Hoe.plugin :newgem
|
|
12
12
|
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
13
13
|
$hoe = Hoe.spec 'scbi_blast' do
|
14
14
|
self.developer 'Dario Guerrero & Almudena Bocinos', 'dariogf@gmail.com, alkoke@gmail.com'
|
15
|
-
self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
15
|
+
# self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
16
16
|
self.rubyforge_name = self.name # TODO this is default value
|
17
17
|
# self.extra_deps = [['activesupport','>= 2.0.2']]
|
18
18
|
|
@@ -23,4 +23,4 @@ Dir['tasks/**/*.rake'].each { |t| load t }
|
|
23
23
|
|
24
24
|
# TODO - want other tests/tasks run by default? Add them to the list
|
25
25
|
# remove_task :default
|
26
|
-
|
26
|
+
task :default => [:spec, :features, :redocs]
|
data/lib/scbi_blast/blast_hit.rb
CHANGED
@@ -117,6 +117,14 @@ class BlastHit
|
|
117
117
|
def get_subject
|
118
118
|
return @subject_id
|
119
119
|
end
|
120
|
+
|
121
|
+
def query_overlaps?(hit,threshold=0)
|
122
|
+
return ((@q_beg<=(hit.q_end+threshold)) and ((@q_end+threshold)>=hit.q_beg))
|
123
|
+
end
|
124
|
+
|
125
|
+
def size
|
126
|
+
return (@q_end-@q_beg+1)
|
127
|
+
end
|
120
128
|
|
121
129
|
# readers and accessor for properties
|
122
130
|
attr_accessor :q_beg, :q_end, :s_beg, :s_end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Copyright (c) 2010 Dario Guerrero & Almudena Bocinos
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
# a copy of this software and associated documentation files (the
|
5
5
|
# 'Software'), to deal in the Software without restriction, including
|
@@ -7,10 +7,10 @@
|
|
7
7
|
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
8
|
# permit persons to whom the Software is furnished to do so, subject to
|
9
9
|
# the following conditions:
|
10
|
-
#
|
10
|
+
#
|
11
11
|
# The above copyright notice and this permission notice shall be
|
12
12
|
# included in all copies or substantial portions of the Software.
|
13
|
-
#
|
13
|
+
#
|
14
14
|
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
15
15
|
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
16
|
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
@@ -34,7 +34,7 @@ class BlastQuery
|
|
34
34
|
@hits = []
|
35
35
|
# inspect
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
# add a hit to query
|
39
39
|
def add_hit(h)
|
40
40
|
@hits.push h
|
@@ -59,6 +59,49 @@ class BlastQuery
|
|
59
59
|
return @hits.sort(comand)
|
60
60
|
end
|
61
61
|
|
62
|
-
|
62
|
+
# merge overlapping hits
|
63
|
+
def merged_hits!(overlap_threshold=0, merged_ids=nil)
|
64
|
+
res = []
|
65
|
+
|
66
|
+
merge_hits(@hits,res,merged_ids)
|
67
|
+
|
68
|
+
begin
|
69
|
+
res2=res # iterate until no more overlaps
|
70
|
+
res = []
|
71
|
+
merge_hits(res2,res,merged_ids)
|
72
|
+
end until (res2.count == res.count)
|
73
|
+
|
74
|
+
|
75
|
+
return res
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
63
79
|
|
80
|
+
# do only one iteration of merge hits
|
81
|
+
def merge_hits(hits,merged_hits,merged_ids=nil)
|
82
|
+
# puts " merging ============"
|
83
|
+
hits.each do |hit|
|
64
84
|
|
85
|
+
# save definitions
|
86
|
+
merged_ids.push hit.definition if !merged_ids.nil? && (!merged_ids.include?(hit.definition))
|
87
|
+
|
88
|
+
# find overlapping hits
|
89
|
+
c=merged_hits.find{|c| hit.query_overlaps?(c)}
|
90
|
+
|
91
|
+
if (c.nil?)
|
92
|
+
# add new hit
|
93
|
+
merged_hits.push(hit.dup)
|
94
|
+
else
|
95
|
+
|
96
|
+
# merge with old hit
|
97
|
+
c.q_beg=[c.q_beg,hit.q_beg].min
|
98
|
+
c.q_end=[c.q_end,hit.q_end].max
|
99
|
+
|
100
|
+
c.subject_id += ' ' + hit.subject_id if (not c.subject_id.include?(hit.subject_id))
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
data/lib/scbi_blast.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: scbi_blast
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.32
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Dario Guerrero & Almudena Bocinos
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-06-01 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: hoe
|
@@ -61,7 +61,7 @@ files:
|
|
61
61
|
homepage: http://www.scbi.uma.es/downloads
|
62
62
|
licenses: []
|
63
63
|
|
64
|
-
post_install_message:
|
64
|
+
post_install_message:
|
65
65
|
rdoc_options:
|
66
66
|
- --main
|
67
67
|
- README.rdoc
|