seqtrimnext 2.0.33 → 2.0.35

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/History.txt CHANGED
@@ -1,3 +1,11 @@
1
+ === 2.0.35 2011-06-22
2
+
3
+ FarAdapters improvement
4
+
5
+ === 2.0.34 2011-06-21
6
+
7
+ Added some additional FAR AB_ADAPTER restrictions
8
+
1
9
  === 2.0.33 2011-06-17
2
10
 
3
11
  Added SEQTRIMNEXT_INIT environment variable
data/bin/create_graphs.rb CHANGED
@@ -1,14 +1,16 @@
1
+ #!/usr/bin/env ruby
1
2
  require 'stringio'
2
3
  # require 'test/unit'
4
+ require 'seqtrimnext'
3
5
  require 'json'
4
6
  require 'gnuplot'
5
7
 
6
- ROOT_PATH=File.dirname(File.dirname(__FILE__))
8
+ # ROOT_PATH=File.dirname(File.dirname(__FILE__))
7
9
 
8
10
  # $: << File.expand_path(File.join(ROOT_PATH,'test'))
9
- $: << File.expand_path(File.join(ROOT_PATH,'classes'))
10
- $: << File.expand_path(File.join(ROOT_PATH,'plugins'))
11
- $: << File.expand_path(File.join(ROOT_PATH,'utils'))
11
+ # $: << File.expand_path(File.join(ROOT_PATH,'classes'))
12
+ # $: << File.expand_path(File.join(ROOT_PATH,'plugins'))
13
+ # $: << File.expand_path(File.join(ROOT_PATH,'utils'))
12
14
 
13
15
  if ARGV.empty?
14
16
  puts "Usage: #{$0} stats.json initial_stats.json"
@@ -1,26 +1,29 @@
1
1
 
2
2
  #finds the classes that were in the folder 'classes'
3
3
 
4
- ROOT_PATH=File.dirname(File.dirname(File.dirname(__FILE__)))
5
-
6
- $: << File.expand_path(File.join(ROOT_PATH, 'classes'))
7
- $: << File.expand_path(File.join(ROOT_PATH, 'classes','blast'))
8
-
9
- #finds the classes that were in the folder 'plugins'
10
- $: << File.expand_path(File.join(ROOT_PATH, 'plugins'))
11
-
12
- #finds the classes that were in the folder 'plugins'
13
- $: << File.expand_path(File.join(ROOT_PATH, 'actions'))
14
-
15
- #finds the classes that were in the folder 'utils'
16
- $: << File.expand_path(File.join(ROOT_PATH, 'utils'))
17
-
18
- $: << File.expand_path(File.join(ROOT_PATH, 'classes','em_classes'))
4
+ # ROOT_PATH=File.dirname(File.dirname(File.dirname(__FILE__)))
5
+ #
6
+ # $: << File.expand_path(File.join(ROOT_PATH, 'classes'))
7
+ # $: << File.expand_path(File.join(ROOT_PATH, 'classes','blast'))
8
+ #
9
+ # #finds the classes that were in the folder 'plugins'
10
+ # $: << File.expand_path(File.join(ROOT_PATH, 'plugins'))
11
+ #
12
+ # #finds the classes that were in the folder 'plugins'
13
+ # $: << File.expand_path(File.join(ROOT_PATH, 'actions'))
14
+ #
15
+ # #finds the classes that were in the folder 'utils'
16
+ # $: << File.expand_path(File.join(ROOT_PATH, 'utils'))
17
+ #
18
+ # $: << File.expand_path(File.join(ROOT_PATH, 'classes','em_classes'))
19
+ #
20
+ # $: << File.expand_path(ROOT_PATH)
19
21
 
20
- $: << File.expand_path(ROOT_PATH)
22
+ require 'seqtrimnext'
21
23
 
22
24
  $SEQTRIM_PATH = ROOT_PATH
23
25
 
26
+
24
27
  if ENV['BLASTDB']# && Dir.exists?(ENV['BLASTDB'])
25
28
  $FORMATTED_DB_PATH = ENV['BLASTDB']
26
29
  $DB_PATH = File.dirname($FORMATTED_DB_PATH)
@@ -12,6 +12,7 @@ class Params
12
12
  @comments = {}
13
13
  # @param_order={}
14
14
  @mids = {}
15
+ @ab_adapters={}
15
16
  @linkers = {}
16
17
  @clusters = {}
17
18
 
@@ -54,28 +55,36 @@ class Params
54
55
  end
55
56
  end# end def
56
57
 
57
- # Load mid's file
58
- def load_mids(path_file)
58
+ def load_db_fastas(path_file)
59
+ res={}
59
60
  if File.exists?(path_file)
60
61
  ff = FastaFile.new(path_file)
61
62
  ff.each {|n,f|
62
63
  # @mid_sizes[n]=f.size
63
- @mids[n]=f
64
+ res[n]=f
64
65
  }
65
66
 
66
67
  ff.close
67
68
  end
69
+ return res
70
+ end
71
+
72
+ # Load mid's file
73
+ def load_mids(path_file)
74
+ @mids=load_db_fastas(path_file)
75
+ # puts @mids
76
+ end
77
+
78
+ # Load ab_adapters file
79
+ def load_ab_adapters(path_file)
80
+ @ab_adapters=load_db_fastas(path_file)
81
+ # puts @ab_adapters
68
82
  end
69
83
 
70
84
  # Load mid's file
71
85
  def load_linkers(path_file)
72
- if File.exists?(path_file)
73
- ff = FastaFile.new(path_file)
74
- ff.each {|n,f|
75
- @linkers[n]=f
76
- }
77
- ff.close
78
- end
86
+ @linkers=load_db_fastas(path_file)
87
+ # puts @linkers
79
88
  end
80
89
 
81
90
  def load_repeated_seqs(file_path)
@@ -90,7 +99,7 @@ class Params
90
99
  #if (line[0]!=62) && (line[0]!=48)
91
100
  if (line[0]!='>'[0]) && (line[0]!='0'[0])
92
101
  #puts line
93
- #puts line,line[0]
102
+ # puts line,line[0]
94
103
  if line =~ />([^\.]+)\.\.\.\s/
95
104
  #puts 'ok'
96
105
  @clusters[$1]=1
@@ -157,6 +166,12 @@ class Params
157
166
  return @linkers[linker]
158
167
  end
159
168
 
169
+ # Return the ab of param
170
+ def get_ab_adapter(adapter)
171
+ return @ab_adapters[adapter]
172
+ end
173
+
174
+
160
175
  def get_plugin
161
176
  plugin='General'
162
177
  # puts caller(2)[1]
@@ -223,6 +223,7 @@ class Seqtrim
223
223
 
224
224
  # leer mids
225
225
  params.load_mids(File.join($FORMATTED_DB_PATH,'mids.fasta'))
226
+ params.load_ab_adapters(File.join($FORMATTED_DB_PATH,'adapters_ab.fasta'))
226
227
  params.load_linkers(File.join($FORMATTED_DB_PATH,'linkers.fasta'))
227
228
 
228
229
 
@@ -66,7 +66,7 @@ class Plugin
66
66
  # puts r2_end.class
67
67
  # puts "-------"
68
68
  #puts "overlap? (#{r1_start}<=#{r2_end}) and (#{r1_end}>=#{r2_start})"
69
- return ((r1_start<=r2_end) and (r1_end>=r2_start) )
69
+ return ((r1_start<=r2_end+1) and (r1_end>=r2_start-1) )
70
70
  end
71
71
 
72
72
  def merge_hits(hits,merged_hits,merged_ids=nil)
@@ -43,6 +43,18 @@ class PluginAbAdapters < Plugin
43
43
  return blast_table_results
44
44
  end
45
45
 
46
+ # filter hits that are far the extreme and do not have a valid length
47
+ def filter_hits(hits,end_pos)
48
+ hits.reverse_each do |hit|
49
+ if (hit.q_end < (end_pos-40)) && ((hit.q_end-hit.q_beg+1)<(@params.get_ab_adapter(hit.subject_id).length*0.80).to_i)
50
+ hits.delete(hit)
51
+ # puts "DELETE #{hit.inspect}"
52
+ # else
53
+ # puts "ACCEPTED #{hit.inspect}, >= #{(@params.get_ab_adapter(hit.subject_id).length*0.2).to_i}"
54
+ end
55
+ end
56
+
57
+ end
46
58
 
47
59
  def exec_seq(seq,blast_query)
48
60
  if blast_query.query_id != seq.seq_name
@@ -62,8 +74,10 @@ class PluginAbAdapters < Plugin
62
74
  # blast_table_results = blast.do_blast(seq.seq_fasta) #rise seq to adapterss executing over blast
63
75
 
64
76
  #BlastTableResult.new(res)
65
- # puts blast.get_blast_cmd
77
+ # puts blast_query.inspect
66
78
  # puts blast_table_results.inspect
79
+
80
+ filter_hits(blast_query.hits, seq.seq_fasta.length)
67
81
 
68
82
  adapters=[]
69
83
  # blast_table_results.querys.each do |query| # first round to save adapters without overlap
@@ -76,6 +90,10 @@ class PluginAbAdapters < Plugin
76
90
  merge_hits(adapters2,adapters)
77
91
  end until (adapters2.count == adapters.count)
78
92
 
93
+ # puts "MERGED"
94
+ # puts "="*50
95
+ # adapters.each {|a| puts a.inspect}
96
+
79
97
  max_to_end=@params.get_param('max_ab_to_end').to_i
80
98
  # type = 'ActionAbAdapter'
81
99
  actions=[]
data/lib/seqtrimnext.rb CHANGED
@@ -30,7 +30,7 @@ module Seqtrimnext
30
30
  # SEQTRIM_VERSION_STAGE = 'b'
31
31
  # SEQTRIM_VERSION = "2.0.0#{SEQTRIM_VERSION_STAGE}#{SEQTRIM_VERSION_REVISION}"
32
32
 
33
- VERSION = '2.0.33'
33
+ VERSION = '2.0.35'
34
34
 
35
35
  SEQTRIM_VERSION = VERSION
36
36
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: seqtrimnext
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.33
5
+ version: 2.0.35
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-06-17 00:00:00 Z
13
+ date: 2011-06-22 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: narray