seqtrimnext_report 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 0.0.3 2011-06-16
2
+
3
+ Corrected errors with empty plugins
4
+
1
5
  === 0.0.2 2011-06-15
2
6
 
3
7
  Some small fixes
data/README.rdoc CHANGED
@@ -27,7 +27,7 @@ gem install seqtrimnext_report
27
27
 
28
28
  (The MIT License)
29
29
 
30
- Copyright (c) 2011 FIXME full name
30
+ Copyright (c) 2011 Noe Fernandez & Dario Guerrero
31
31
 
32
32
  Permission is hereby granted, free of charge, to any person obtaining
33
33
  a copy of this software and associated documentation files (the
@@ -3,8 +3,10 @@
3
3
  # Noe Fdez Pozo 2011-05-11. To build a PDF with latex parsing SeqTrimNext output files
4
4
 
5
5
  #---------------------------------------------- para indicar donde estan las clases
6
- ROOT_PATH=File.dirname(__FILE__)
7
- # $: << File.expand_path(File.join(ROOT_PATH, "classes"))
6
+ ROOT_PATH=File.dirname(File.dirname(__FILE__))
7
+ # $: << File.expand_path(File.join(ROOT_PATH, 'lib','seqtrimnext_report','classes'))
8
+ # $: << File.expand_path(File.join(ROOT_PATH, 'lib'))
9
+
8
10
  # $: << '/Users/dariogf/progs/ruby/gems/seqtrimnext/lib'
9
11
 
10
12
  #---------------------------------------------- gems
@@ -51,13 +53,13 @@ if !Dir.exists?(output_files)
51
53
  end
52
54
 
53
55
  if !File.exist?(File.join(output_files,'used_params.txt'))
54
- puts "File used_params.txt not found.\n"
56
+ puts "used_params.txt file not found.\n"
55
57
  exit(-1)
56
58
  elsif !File.exist?(File.join(output_files,'initial_stats.json'))
57
- puts "File initial_stats.json not found.\n"
59
+ puts "initial_stats.json file not found.\n"
58
60
  exit(-1)
59
61
  elsif !File.exist?(File.join(output_files,'stats.json'))
60
- puts "File stats.json not found.\n"
62
+ puts "stats.json file not found.\n"
61
63
  exit(-1)
62
64
  end
63
65
 
@@ -76,6 +78,16 @@ begin
76
78
  initial_stats = get_json_data(File.join(output_files,'initial_stats.json'))
77
79
  stats = get_json_data(File.join(output_files,'stats.json'))
78
80
 
81
+ if (initial_stats.nil?)
82
+ puts "initial_stats.json info does not exist\n"
83
+ exit(-1)
84
+ end
85
+
86
+ if (stats.nil?)
87
+ puts "stats.json info does not exist\n"
88
+ exit(-1)
89
+ end
90
+
79
91
  # load json configuration
80
92
  plugin_fix_hash = get_json_data(File.join(File.dirname(__FILE__),'..','lib','seqtrimnext_report','config','plugin_seqs.json'))
81
93
  plugin_nts_hash = get_json_data(File.join(File.dirname(__FILE__),'..','lib','seqtrimnext_report','config','plugin_nts.json'))
@@ -110,9 +122,9 @@ begin
110
122
  `rm -r #{output_latex}`
111
123
  end
112
124
 
113
- rescue
125
+ # rescue
114
126
 
115
- puts "output PDF couldn't be created for this dataset"
127
+ # puts "Output PDF couldn't be created for this dataset"
116
128
 
117
129
  end
118
130
  # system(cmd)
@@ -8,5 +8,5 @@ ROOT_PATH=File.join(File.dirname(__FILE__),'seqtrimnext_report')
8
8
  $: << File.expand_path(File.join(ROOT_PATH, 'classes'))
9
9
 
10
10
  module SeqtrimnextReport
11
- VERSION = '0.0.2'
11
+ VERSION = '0.0.3'
12
12
  end
@@ -5,13 +5,19 @@ class StatsReport
5
5
  output2=File.open(File.join(output_latex,'stats.tex'), 'w')
6
6
  output2.puts "%!TEX root = FinalReport.tex"
7
7
 
8
+ if (stats['sequences'].nil?) || (stats['sequences']['count'].nil?)
9
+ puts "sequences info does not exist in stats.json\n"
10
+ exit(-1)
11
+ end
12
+
8
13
  input_seqs = stats['sequences']['count']['input_count'].to_i
9
14
  rejected_seqs = stats['sequences']['count']['rejected'].to_i
10
15
  output_seqs = stats['sequences']['count']['output_seqs'].to_i
11
16
 
17
+ #------------------------------------------------------------------------------------------ solo cuando hay pareadas
12
18
  output_seqs_paired = 0
13
19
  total_output_seqs = 0
14
- #------------------------------------------------------------------------------------------ solo cuando hay pareadas
20
+
15
21
  if (!stats['sequences']['count']['output_seqs_paired'].nil?)
16
22
  output_seqs_paired = stats['sequences']['count']['output_seqs_paired'].to_i
17
23
  total_output_seqs = output_seqs_paired+output_seqs
@@ -44,9 +50,15 @@ class StatsReport
44
50
  output2.puts '\begin{center}'
45
51
  output2.puts '\begin{tabular}{l r r}'
46
52
  output2.puts " \\hline"
47
- output2.puts "Input reads: & total & #{input_seqs} \\\\"
48
- output2.puts " & Smallest read (bp) & #{initial_stats['smallest_sequence_size'].to_i} \\\\"
49
- output2.puts " & Largest read (bp)& #{initial_stats['biggest_sequence_size'].to_i} \\\\"
53
+ if (!input_seqs.nil?)
54
+ output2.puts "Input reads: & total & #{input_seqs} \\\\"
55
+ end
56
+ if (!initial_stats['smallest_sequence_size'].nil?)
57
+ output2.puts " & Smallest read (bp) & #{initial_stats['smallest_sequence_size'].to_i} \\\\"
58
+ end
59
+ if (!initial_stats['biggest_sequence_size'].nil?)
60
+ output2.puts " & Largest read (bp)& #{initial_stats['biggest_sequence_size'].to_i} \\\\"
61
+ end
50
62
  output2.puts " & Mode (bp) & #{input_mode} \\\\"
51
63
  output2.puts " & Mean (bp)& #{input_mean} \\\\"
52
64
 
@@ -93,12 +105,10 @@ class StatsReport
93
105
  end
94
106
  end
95
107
  end
96
- #-----------------------------------------------------------------------------
108
+ #--------------------------------------------------- end pareadas
97
109
 
98
110
  output2.puts "\\hline"
99
111
 
100
-
101
-
102
112
  output2.puts '\end{tabular}'
103
113
  output2.puts '\label{table:nonlin}'
104
114
  output2.puts '\end{center}'
@@ -141,10 +151,12 @@ class StatsReport
141
151
 
142
152
  # en las pareadas añadimos el inserto de izq y derecha ------------------------------------- solo cuando hay pareadas
143
153
  paired_nts=0
144
- if (stats['PluginExtractInserts']['left_insert_size']) || (stats['PluginExtractInserts']['right_insert_size'])
154
+ if (stats['PluginExtractInserts']['left_insert_size'])
145
155
  stats['PluginExtractInserts']['left_insert_size'].each do |element|
146
156
  paired_nts += element[0].to_i*element[1].to_i
147
157
  end
158
+ end
159
+ if (stats['PluginExtractInserts']['right_insert_size'])
148
160
  stats['PluginExtractInserts']['right_insert_size'].each do |element|
149
161
  paired_nts += element[0].to_i*element[1].to_i
150
162
  end
@@ -163,18 +175,27 @@ class StatsReport
163
175
  def get_mode(initial_stats,stats)
164
176
  output_mode = 0
165
177
  mode_array = []
178
+
166
179
  # take the mode from initial_stats.json
167
- input_mode = initial_stats['mode_of_sizes']
180
+ if (!initial_stats.nil? and !initial_stats.empty?)
181
+ input_mode = initial_stats['mode_of_sizes']
182
+ else
183
+ input_mode = 0
184
+ end
168
185
 
169
186
  # calculate the mode using data from stats.json
170
- stats['PluginExtractInserts']['insert_size'].each do |key,value|
171
- mode_array[key.to_i]=value
172
- end
187
+ if (!stats['PluginExtractInserts']['insert_size'].nil?)
188
+ stats['PluginExtractInserts']['insert_size'].each do |key,value|
189
+ mode_array[key.to_i]=value
190
+ end
173
191
 
174
- mode_array.map!{|e| e || 0}
175
- s=ScbiStats.new(mode_array)
192
+ mode_array.map!{|e| e || 0}
193
+ s=ScbiStats.new(mode_array)
176
194
 
177
- output_mode = s.fat_mode
195
+ output_mode = s.fat_mode
196
+ else
197
+ output_mode = 0
198
+ end
178
199
 
179
200
  return [input_mode, output_mode]
180
201
  end
@@ -183,21 +204,29 @@ class StatsReport
183
204
  output_mean = 0
184
205
 
185
206
  # take the mean from initial_stats.json
186
- input_mean = sprintf("%0.1f", (initial_stats['mean_of_sequence_sizes']))
187
- # input_mean = sprintf("%0.2f", (initial_stats['mean_of_sequence_sizes']))
188
-
207
+ if (!initial_stats.nil? and !initial_stats.empty?)
208
+ input_mean = sprintf("%0.1f", (initial_stats['mean_of_sequence_sizes']))
209
+ else
210
+ input_mean = 0
211
+ end
212
+
189
213
  # calculate the mean using data from stats.json
190
214
  nts_count = 0
191
215
  seqs_count = 0
192
- stats['PluginExtractInserts']['insert_size'].each do |key,value|
193
- seqs_count += value.to_i
194
- nts_count += (key.to_f*value)
195
- # nts_count += (key.to_f*value.to_f)
196
- end
197
-
216
+ if (!stats['PluginExtractInserts']['insert_size'].nil?)
217
+ stats['PluginExtractInserts']['insert_size'].each do |key,value|
218
+ seqs_count += value.to_i
219
+ nts_count += (key.to_f*value)
220
+ end
198
221
 
199
- output_mean = sprintf("%0.1f", (nts_count/seqs_count))
200
- # output_mean = sprintf("%0.2f", (nts_count/seqs_count))
222
+ if (nts_count == 0 || seqs_count == 0)
223
+ output_mean = 0
224
+ else
225
+ output_mean = sprintf("%0.1f", (nts_count/seqs_count))
226
+ end
227
+ else
228
+ output_mean = 0
229
+ end
201
230
 
202
231
  return [input_mean, output_mean]
203
232
  end
@@ -236,7 +265,7 @@ class StatsReport
236
265
  nts_table_hash = {}
237
266
  insert_array = []
238
267
  warning_array = []
239
-
268
+
240
269
  plugin_nts_hash.each do |plugin|
241
270
 
242
271
  my_name = plugin[0]
@@ -302,7 +331,9 @@ class StatsReport
302
331
  end
303
332
 
304
333
  output2.puts '\hline'
305
- output2.puts nts_table_hash['insert_size'][0]
334
+ if (!nts_table_hash['insert_size'].nil?)
335
+ output2.puts nts_table_hash['insert_size'][0]
336
+ end
306
337
  output2.puts '\hline'
307
338
  output2.puts '\end{tabular}'
308
339
  output2.puts '\label{table:nonlin}'
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: seqtrimnext_report
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.2
5
+ version: 0.0.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Noe Fernandez & Dario Guerrero
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-06-15 00:00:00 Z
13
+ date: 2011-06-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: seqtrimnext