BioDSL 1.0.0
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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/BioDSL.gemspec +64 -0
- data/LICENSE +339 -0
- data/README.md +205 -0
- data/Rakefile +94 -0
- data/examples/fastq_to_fasta.rb +8 -0
- data/lib/BioDSL/cary.rb +242 -0
- data/lib/BioDSL/command.rb +133 -0
- data/lib/BioDSL/commands/add_key.rb +110 -0
- data/lib/BioDSL/commands/align_seq_mothur.rb +194 -0
- data/lib/BioDSL/commands/analyze_residue_distribution.rb +222 -0
- data/lib/BioDSL/commands/assemble_pairs.rb +336 -0
- data/lib/BioDSL/commands/assemble_seq_idba.rb +230 -0
- data/lib/BioDSL/commands/assemble_seq_ray.rb +345 -0
- data/lib/BioDSL/commands/assemble_seq_spades.rb +252 -0
- data/lib/BioDSL/commands/classify_seq.rb +217 -0
- data/lib/BioDSL/commands/classify_seq_mothur.rb +226 -0
- data/lib/BioDSL/commands/clip_primer.rb +318 -0
- data/lib/BioDSL/commands/cluster_otus.rb +181 -0
- data/lib/BioDSL/commands/collapse_otus.rb +170 -0
- data/lib/BioDSL/commands/collect_otus.rb +150 -0
- data/lib/BioDSL/commands/complement_seq.rb +117 -0
- data/lib/BioDSL/commands/count.rb +135 -0
- data/lib/BioDSL/commands/count_values.rb +149 -0
- data/lib/BioDSL/commands/degap_seq.rb +253 -0
- data/lib/BioDSL/commands/dereplicate_seq.rb +168 -0
- data/lib/BioDSL/commands/dump.rb +157 -0
- data/lib/BioDSL/commands/filter_rrna.rb +239 -0
- data/lib/BioDSL/commands/genecall.rb +237 -0
- data/lib/BioDSL/commands/grab.rb +535 -0
- data/lib/BioDSL/commands/index_taxonomy.rb +226 -0
- data/lib/BioDSL/commands/mask_seq.rb +175 -0
- data/lib/BioDSL/commands/mean_scores.rb +168 -0
- data/lib/BioDSL/commands/merge_pair_seq.rb +175 -0
- data/lib/BioDSL/commands/merge_table.rb +225 -0
- data/lib/BioDSL/commands/merge_values.rb +113 -0
- data/lib/BioDSL/commands/plot_heatmap.rb +233 -0
- data/lib/BioDSL/commands/plot_histogram.rb +306 -0
- data/lib/BioDSL/commands/plot_matches.rb +282 -0
- data/lib/BioDSL/commands/plot_residue_distribution.rb +278 -0
- data/lib/BioDSL/commands/plot_scores.rb +285 -0
- data/lib/BioDSL/commands/random.rb +153 -0
- data/lib/BioDSL/commands/read_fasta.rb +222 -0
- data/lib/BioDSL/commands/read_fastq.rb +414 -0
- data/lib/BioDSL/commands/read_table.rb +329 -0
- data/lib/BioDSL/commands/reverse_seq.rb +113 -0
- data/lib/BioDSL/commands/slice_align.rb +400 -0
- data/lib/BioDSL/commands/slice_seq.rb +151 -0
- data/lib/BioDSL/commands/sort.rb +223 -0
- data/lib/BioDSL/commands/split_pair_seq.rb +220 -0
- data/lib/BioDSL/commands/split_values.rb +165 -0
- data/lib/BioDSL/commands/trim_primer.rb +314 -0
- data/lib/BioDSL/commands/trim_seq.rb +192 -0
- data/lib/BioDSL/commands/uchime_ref.rb +170 -0
- data/lib/BioDSL/commands/uclust.rb +286 -0
- data/lib/BioDSL/commands/unique_values.rb +145 -0
- data/lib/BioDSL/commands/usearch_global.rb +171 -0
- data/lib/BioDSL/commands/usearch_local.rb +171 -0
- data/lib/BioDSL/commands/write_fasta.rb +207 -0
- data/lib/BioDSL/commands/write_fastq.rb +191 -0
- data/lib/BioDSL/commands/write_table.rb +419 -0
- data/lib/BioDSL/commands/write_tree.rb +167 -0
- data/lib/BioDSL/commands.rb +31 -0
- data/lib/BioDSL/config.rb +55 -0
- data/lib/BioDSL/csv.rb +307 -0
- data/lib/BioDSL/debug.rb +42 -0
- data/lib/BioDSL/fasta.rb +133 -0
- data/lib/BioDSL/fastq.rb +77 -0
- data/lib/BioDSL/filesys.rb +137 -0
- data/lib/BioDSL/fork.rb +145 -0
- data/lib/BioDSL/hamming.rb +128 -0
- data/lib/BioDSL/helpers/aux_helper.rb +44 -0
- data/lib/BioDSL/helpers/email_helper.rb +66 -0
- data/lib/BioDSL/helpers/history_helper.rb +40 -0
- data/lib/BioDSL/helpers/log_helper.rb +55 -0
- data/lib/BioDSL/helpers/options_helper.rb +405 -0
- data/lib/BioDSL/helpers/status_helper.rb +132 -0
- data/lib/BioDSL/helpers.rb +35 -0
- data/lib/BioDSL/html_report.rb +200 -0
- data/lib/BioDSL/math.rb +55 -0
- data/lib/BioDSL/mummer.rb +216 -0
- data/lib/BioDSL/pipeline.rb +354 -0
- data/lib/BioDSL/seq/ambiguity.rb +66 -0
- data/lib/BioDSL/seq/assemble.rb +240 -0
- data/lib/BioDSL/seq/backtrack.rb +252 -0
- data/lib/BioDSL/seq/digest.rb +99 -0
- data/lib/BioDSL/seq/dynamic.rb +263 -0
- data/lib/BioDSL/seq/homopolymer.rb +59 -0
- data/lib/BioDSL/seq/kmer.rb +293 -0
- data/lib/BioDSL/seq/levenshtein.rb +113 -0
- data/lib/BioDSL/seq/translate.rb +109 -0
- data/lib/BioDSL/seq/trim.rb +188 -0
- data/lib/BioDSL/seq.rb +742 -0
- data/lib/BioDSL/serializer.rb +98 -0
- data/lib/BioDSL/stream.rb +113 -0
- data/lib/BioDSL/taxonomy.rb +691 -0
- data/lib/BioDSL/test.rb +42 -0
- data/lib/BioDSL/tmp_dir.rb +68 -0
- data/lib/BioDSL/usearch.rb +301 -0
- data/lib/BioDSL/verbose.rb +42 -0
- data/lib/BioDSL/version.rb +31 -0
- data/lib/BioDSL.rb +81 -0
- data/test/BioDSL/commands/test_add_key.rb +105 -0
- data/test/BioDSL/commands/test_align_seq_mothur.rb +99 -0
- data/test/BioDSL/commands/test_analyze_residue_distribution.rb +134 -0
- data/test/BioDSL/commands/test_assemble_pairs.rb +459 -0
- data/test/BioDSL/commands/test_assemble_seq_idba.rb +50 -0
- data/test/BioDSL/commands/test_assemble_seq_ray.rb +51 -0
- data/test/BioDSL/commands/test_assemble_seq_spades.rb +50 -0
- data/test/BioDSL/commands/test_classify_seq.rb +50 -0
- data/test/BioDSL/commands/test_classify_seq_mothur.rb +59 -0
- data/test/BioDSL/commands/test_clip_primer.rb +377 -0
- data/test/BioDSL/commands/test_cluster_otus.rb +128 -0
- data/test/BioDSL/commands/test_collapse_otus.rb +81 -0
- data/test/BioDSL/commands/test_collect_otus.rb +82 -0
- data/test/BioDSL/commands/test_complement_seq.rb +78 -0
- data/test/BioDSL/commands/test_count.rb +103 -0
- data/test/BioDSL/commands/test_count_values.rb +85 -0
- data/test/BioDSL/commands/test_degap_seq.rb +96 -0
- data/test/BioDSL/commands/test_dereplicate_seq.rb +92 -0
- data/test/BioDSL/commands/test_dump.rb +109 -0
- data/test/BioDSL/commands/test_filter_rrna.rb +128 -0
- data/test/BioDSL/commands/test_genecall.rb +50 -0
- data/test/BioDSL/commands/test_grab.rb +398 -0
- data/test/BioDSL/commands/test_index_taxonomy.rb +62 -0
- data/test/BioDSL/commands/test_mask_seq.rb +98 -0
- data/test/BioDSL/commands/test_mean_scores.rb +111 -0
- data/test/BioDSL/commands/test_merge_pair_seq.rb +115 -0
- data/test/BioDSL/commands/test_merge_table.rb +131 -0
- data/test/BioDSL/commands/test_merge_values.rb +83 -0
- data/test/BioDSL/commands/test_plot_heatmap.rb +185 -0
- data/test/BioDSL/commands/test_plot_histogram.rb +194 -0
- data/test/BioDSL/commands/test_plot_matches.rb +157 -0
- data/test/BioDSL/commands/test_plot_residue_distribution.rb +309 -0
- data/test/BioDSL/commands/test_plot_scores.rb +308 -0
- data/test/BioDSL/commands/test_random.rb +88 -0
- data/test/BioDSL/commands/test_read_fasta.rb +229 -0
- data/test/BioDSL/commands/test_read_fastq.rb +552 -0
- data/test/BioDSL/commands/test_read_table.rb +327 -0
- data/test/BioDSL/commands/test_reverse_seq.rb +79 -0
- data/test/BioDSL/commands/test_slice_align.rb +218 -0
- data/test/BioDSL/commands/test_slice_seq.rb +131 -0
- data/test/BioDSL/commands/test_sort.rb +128 -0
- data/test/BioDSL/commands/test_split_pair_seq.rb +164 -0
- data/test/BioDSL/commands/test_split_values.rb +95 -0
- data/test/BioDSL/commands/test_trim_primer.rb +329 -0
- data/test/BioDSL/commands/test_trim_seq.rb +150 -0
- data/test/BioDSL/commands/test_uchime_ref.rb +113 -0
- data/test/BioDSL/commands/test_uclust.rb +139 -0
- data/test/BioDSL/commands/test_unique_values.rb +98 -0
- data/test/BioDSL/commands/test_usearch_global.rb +123 -0
- data/test/BioDSL/commands/test_usearch_local.rb +125 -0
- data/test/BioDSL/commands/test_write_fasta.rb +159 -0
- data/test/BioDSL/commands/test_write_fastq.rb +166 -0
- data/test/BioDSL/commands/test_write_table.rb +411 -0
- data/test/BioDSL/commands/test_write_tree.rb +122 -0
- data/test/BioDSL/helpers/test_options_helper.rb +272 -0
- data/test/BioDSL/seq/test_assemble.rb +98 -0
- data/test/BioDSL/seq/test_backtrack.rb +176 -0
- data/test/BioDSL/seq/test_digest.rb +71 -0
- data/test/BioDSL/seq/test_dynamic.rb +133 -0
- data/test/BioDSL/seq/test_homopolymer.rb +58 -0
- data/test/BioDSL/seq/test_kmer.rb +134 -0
- data/test/BioDSL/seq/test_translate.rb +75 -0
- data/test/BioDSL/seq/test_trim.rb +101 -0
- data/test/BioDSL/test_cary.rb +176 -0
- data/test/BioDSL/test_command.rb +45 -0
- data/test/BioDSL/test_csv.rb +514 -0
- data/test/BioDSL/test_debug.rb +42 -0
- data/test/BioDSL/test_fasta.rb +154 -0
- data/test/BioDSL/test_fastq.rb +46 -0
- data/test/BioDSL/test_filesys.rb +145 -0
- data/test/BioDSL/test_fork.rb +85 -0
- data/test/BioDSL/test_math.rb +41 -0
- data/test/BioDSL/test_mummer.rb +79 -0
- data/test/BioDSL/test_pipeline.rb +187 -0
- data/test/BioDSL/test_seq.rb +790 -0
- data/test/BioDSL/test_serializer.rb +72 -0
- data/test/BioDSL/test_stream.rb +55 -0
- data/test/BioDSL/test_taxonomy.rb +336 -0
- data/test/BioDSL/test_test.rb +42 -0
- data/test/BioDSL/test_tmp_dir.rb +58 -0
- data/test/BioDSL/test_usearch.rb +33 -0
- data/test/BioDSL/test_verbose.rb +42 -0
- data/test/helper.rb +82 -0
- data/www/command.html.haml +14 -0
- data/www/css.html.haml +55 -0
- data/www/input_files.html.haml +3 -0
- data/www/layout.html.haml +12 -0
- data/www/output_files.html.haml +3 -0
- data/www/overview.html.haml +15 -0
- data/www/pipeline.html.haml +4 -0
- data/www/png.html.haml +2 -0
- data/www/status.html.haml +9 -0
- data/www/time.html.haml +11 -0
- metadata +503 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..')
|
|
3
|
+
|
|
4
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
7
|
+
# #
|
|
8
|
+
# This program is free software; you can redistribute it and/or #
|
|
9
|
+
# modify it under the terms of the GNU General Public License #
|
|
10
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
11
|
+
# of the License, or (at your option) any later version. #
|
|
12
|
+
# #
|
|
13
|
+
# This program is distributed in the hope that it will be useful, #
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
16
|
+
# GNU General Public License for more details. #
|
|
17
|
+
# #
|
|
18
|
+
# You should have received a copy of the GNU General Public License #
|
|
19
|
+
# along with this program; if not, write to the Free Software #
|
|
20
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
|
|
21
|
+
# #
|
|
22
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
23
|
+
# #
|
|
24
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
25
|
+
# #
|
|
26
|
+
# This software is part of BioDSL (www.BioDSL.org). #
|
|
27
|
+
# #
|
|
28
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
29
|
+
|
|
30
|
+
require 'test/helper'
|
|
31
|
+
|
|
32
|
+
class FastaTest < Test::Unit::TestCase
|
|
33
|
+
def setup
|
|
34
|
+
@file = Tempfile.new("fasta")
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def teardown
|
|
38
|
+
File.unlink("#{@file.path}.gz") if File.exist? "#{@file.path}.gz"
|
|
39
|
+
File.unlink("#{@file.path}.bz2") if File.exist? "#{@file.path}.bz2"
|
|
40
|
+
@file.close
|
|
41
|
+
@file.unlink
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
test "BioDSL::Fasta#read with non-existing file raises" do
|
|
45
|
+
assert_raise(Errno::ENOENT) { BioDSL::Fasta.read("dasf") }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test "BioDSL::Fasta#read with empty files return empty" do
|
|
49
|
+
assert_equal([], BioDSL::Fasta.read(@file))
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
test "BioDSL::Fasta#read with two entries return correctly" do
|
|
53
|
+
File.open(@file, 'w') do |ios|
|
|
54
|
+
ios.puts <<EOD
|
|
55
|
+
>test1
|
|
56
|
+
atcg
|
|
57
|
+
>test2
|
|
58
|
+
gtT
|
|
59
|
+
EOD
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
@file.close
|
|
63
|
+
|
|
64
|
+
assert_equal([">test1\natcg\n", ">test2\ngtT\n"], BioDSL::Fasta.read(@file).map { |e| e.to_fasta } )
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
test "BioDSL::Fasta#read from gzip with two entries return correctly" do
|
|
68
|
+
File.open(@file, 'w') do |ios|
|
|
69
|
+
ios.puts <<EOD
|
|
70
|
+
>test1
|
|
71
|
+
atcg
|
|
72
|
+
>test2
|
|
73
|
+
gtT
|
|
74
|
+
EOD
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
@file.close
|
|
78
|
+
|
|
79
|
+
`gzip #{@file.path}`
|
|
80
|
+
|
|
81
|
+
assert_equal([">test1\natcg\n", ">test2\ngtT\n"], BioDSL::Fasta.read("#{@file.path}.gz").map { |e| e.to_fasta } )
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
test "BioDSL::Fasta#read from bzip2 with two entries return correctly" do
|
|
85
|
+
File.open(@file, 'w') do |ios|
|
|
86
|
+
ios.puts <<EOD
|
|
87
|
+
>test1
|
|
88
|
+
atcg
|
|
89
|
+
>test2
|
|
90
|
+
gtT
|
|
91
|
+
EOD
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
@file.close
|
|
95
|
+
|
|
96
|
+
`bzip2 #{@file.path}`
|
|
97
|
+
|
|
98
|
+
assert_equal([">test1\natcg\n", ">test2\ngtT\n"], BioDSL::Fasta.read("#{@file.path}.bz2").map { |e| e.to_fasta } )
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
test "BioDSL::Fasta#read with two entries and white space return correctly" do
|
|
102
|
+
File.open(@file, 'w') do |ios|
|
|
103
|
+
ios.puts <<EOD
|
|
104
|
+
|
|
105
|
+
>test1
|
|
106
|
+
|
|
107
|
+
at
|
|
108
|
+
|
|
109
|
+
cg
|
|
110
|
+
|
|
111
|
+
>test2
|
|
112
|
+
|
|
113
|
+
gt
|
|
114
|
+
|
|
115
|
+
T
|
|
116
|
+
|
|
117
|
+
EOD
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
@file.close
|
|
121
|
+
|
|
122
|
+
assert_equal([">test1\natcg\n", ">test2\ngtT\n"], BioDSL::Fasta.read(@file).map { |e| e.to_fasta } )
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
test "BioDSL::Fasta#read with content and missing seq_name raises" do
|
|
126
|
+
File.open(@file, 'w') do |ios|
|
|
127
|
+
ios.puts "tyt"
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
@file.close
|
|
131
|
+
|
|
132
|
+
assert_raise(BioDSL::FastaError) { BioDSL::Fasta.read(@file) }
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
test "BioDSL::Fasta#read with content before first entry raises" do
|
|
136
|
+
File.open(@file, 'w') do |ios|
|
|
137
|
+
ios.puts "foo\n>bar\natcg"
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
@file.close
|
|
141
|
+
|
|
142
|
+
assert_raise(BioDSL::FastaError) { BioDSL::Fasta.read(@file) }
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
test "BioDSL::Fasta#read with content and truncated seq_name raises" do
|
|
146
|
+
File.open(@file, 'w') do |ios|
|
|
147
|
+
ios.puts ">\ntyt"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
@file.close
|
|
151
|
+
|
|
152
|
+
assert_raise(BioDSL::FastaError) { BioDSL::Fasta.read(@file) }
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..')
|
|
3
|
+
|
|
4
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
7
|
+
# #
|
|
8
|
+
# This program is free software; you can redistribute it and/or #
|
|
9
|
+
# modify it under the terms of the GNU General Public License #
|
|
10
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
11
|
+
# of the License, or (at your option) any later version. #
|
|
12
|
+
# #
|
|
13
|
+
# This program is distributed in the hope that it will be useful, #
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
16
|
+
# GNU General Public License for more details. #
|
|
17
|
+
# #
|
|
18
|
+
# You should have received a copy of the GNU General Public License #
|
|
19
|
+
# along with this program; if not, write to the Free Software #
|
|
20
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
|
|
21
|
+
# #
|
|
22
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
23
|
+
# #
|
|
24
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
25
|
+
# #
|
|
26
|
+
# This software is part of BioDSL (www.BioDSL.org). #
|
|
27
|
+
# #
|
|
28
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
29
|
+
|
|
30
|
+
require 'test/helper'
|
|
31
|
+
|
|
32
|
+
class FastqTest < Test::Unit::TestCase
|
|
33
|
+
def setup
|
|
34
|
+
@io = StringIO.new("@test1\nATCG\n+\nABCD\n@test2\natcg\n+test2\n@ABG\n")
|
|
35
|
+
@fastq = BioDSL::Fastq.new(@io)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
test "#next_entry obtains the correct seq_name" do
|
|
39
|
+
assert_equal("test1", @fastq.next_entry.seq_name)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
test "#next_entry with two entries obtain correct sequences" do
|
|
43
|
+
assert_equal("ATCG", @fastq.next_entry.seq)
|
|
44
|
+
assert_equal("atcg", @fastq.next_entry.seq)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..')
|
|
3
|
+
|
|
4
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
7
|
+
# #
|
|
8
|
+
# This program is free software; you can redistribute it and/or #
|
|
9
|
+
# modify it under the terms of the GNU General Public License #
|
|
10
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
11
|
+
# of the License, or (at your option) any later version. #
|
|
12
|
+
# #
|
|
13
|
+
# This program is distributed in the hope that it will be useful, #
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
16
|
+
# GNU General Public License for more details. #
|
|
17
|
+
# #
|
|
18
|
+
# You should have received a copy of the GNU General Public License #
|
|
19
|
+
# along with this program; if not, write to the Free Software #
|
|
20
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
|
|
21
|
+
# #
|
|
22
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
23
|
+
# #
|
|
24
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
25
|
+
# #
|
|
26
|
+
# This software is part of BioDSL (www.BioDSL.org). #
|
|
27
|
+
# #
|
|
28
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
29
|
+
|
|
30
|
+
require 'test/helper'
|
|
31
|
+
|
|
32
|
+
class FilesysTest < Test::Unit::TestCase
|
|
33
|
+
def setup
|
|
34
|
+
@zcat = BioDSL::Filesys::which('gzcat') || BioDSL::Filesys::which('zcat')
|
|
35
|
+
|
|
36
|
+
@tmpdir = Dir.mktmpdir("BioDSL")
|
|
37
|
+
@file = File.join(@tmpdir, 'test.txt')
|
|
38
|
+
file_gzip = File.join(@tmpdir, 'test_gzip.txt')
|
|
39
|
+
file_bzip2 = File.join(@tmpdir, 'test_bzip2.txt')
|
|
40
|
+
@file_gzip = File.join(@tmpdir, 'test_gzip.txt.gz')
|
|
41
|
+
@file_bzip2 = File.join(@tmpdir, 'test_bzip2.txt.bz2')
|
|
42
|
+
|
|
43
|
+
File.open(@file, 'w') { |ios| ios << "foobar" }
|
|
44
|
+
File.open(file_gzip, 'w') { |ios| ios << "foobar" }
|
|
45
|
+
File.open(file_bzip2, 'w') { |ios| ios << "foobar" }
|
|
46
|
+
|
|
47
|
+
`gzip #{file_gzip}`
|
|
48
|
+
`bzip2 #{file_bzip2}`
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def teardown
|
|
52
|
+
FileUtils.rm_r @tmpdir
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
test "#which with non-existing executable returns nil" do
|
|
57
|
+
assert_nil(BioDSL::Filesys.which("__env__"))
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
test "#which with existing executable returns correctly" do
|
|
61
|
+
assert_equal("/usr/bin/env", BioDSL::Filesys.which("env"))
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
test "#tmpfile returns correctly" do
|
|
65
|
+
assert_equal(@tmpdir, BioDSL::Filesys.tmpfile(@tmpdir).match(/^#{@tmpdir}/).to_s)
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
test "#open in read mode returns correctly" do
|
|
69
|
+
ios = BioDSL::Filesys.open(@file)
|
|
70
|
+
assert_equal("foobar", ios.read)
|
|
71
|
+
ios.close
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
test "#open in read mode with block context returns correctly" do
|
|
75
|
+
BioDSL::Filesys.open(@file) { |ios| assert_equal("foobar", ios.read) }
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
test "#open in write mode outputs correctly" do
|
|
79
|
+
ios = BioDSL::Filesys.open(@file, 'w')
|
|
80
|
+
ios.write "foobar"
|
|
81
|
+
ios.close
|
|
82
|
+
File.open(@file) { |ios2| assert_equal("foobar", ios2.read) }
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
test "#open in write mode with block context outputs correctly" do
|
|
86
|
+
BioDSL::Filesys.open(@file, 'w') { |ios| ios.write "foobar" }
|
|
87
|
+
File.open(@file) { |ios| assert_equal("foobar", ios.read) }
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
test "#open gzip in read mode returns correctly" do
|
|
91
|
+
ios = BioDSL::Filesys.open(@file_gzip)
|
|
92
|
+
assert_equal("foobar", ios.read)
|
|
93
|
+
ios.close
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
test "#open gzip in read mode with block context returns correctly" do
|
|
97
|
+
BioDSL::Filesys.open(@file_gzip) { |ios| assert_equal("foobar", ios.read) }
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
test "#open gzip in write mode outputs correctly" do
|
|
101
|
+
ios = BioDSL::Filesys.open(@file, 'w', compress: :gzip)
|
|
102
|
+
ios.write "foobar"
|
|
103
|
+
ios.close
|
|
104
|
+
result = `#{@zcat} #{@file}`
|
|
105
|
+
assert_equal("foobar", result)
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
test "#open gzip in write mode with block context outputs correctly" do
|
|
109
|
+
BioDSL::Filesys.open(@file, 'w', compress: :gzip) { |ios| ios.write "foobar" }
|
|
110
|
+
result = `#{@zcat} #{@file}`
|
|
111
|
+
assert_equal("foobar", result)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
test "#open bzip2 in read mode returns correctly" do
|
|
115
|
+
ios = BioDSL::Filesys.open(@file_bzip2)
|
|
116
|
+
assert_equal("foobar", ios.read)
|
|
117
|
+
ios.close
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
test "#open bzip2 in read mode with block context returns correctly" do
|
|
121
|
+
BioDSL::Filesys.open(@file_bzip2) { |ios| assert_equal("foobar", ios.read) }
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
test "#open bzip2 in write mode outputs correctly" do
|
|
125
|
+
ios = BioDSL::Filesys.open(@file, 'w', compress: :bzip2)
|
|
126
|
+
ios.write "foobar"
|
|
127
|
+
ios.close
|
|
128
|
+
result = `bzcat #{@file}`
|
|
129
|
+
assert_equal("foobar", result)
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
test "#open bzip2 in write mode with block context outputs correctly" do
|
|
133
|
+
BioDSL::Filesys.open(@file, 'w', compress: :bzip2) { |ios| ios.write "foobar" }
|
|
134
|
+
result = `bzcat #{@file}`
|
|
135
|
+
assert_equal("foobar", result)
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
test "#open if eof? returns correctly" do
|
|
139
|
+
ios = BioDSL::Filesys.open(@file)
|
|
140
|
+
assert_equal(false, ios.eof?)
|
|
141
|
+
ios.read
|
|
142
|
+
assert_equal(true, ios.eof?)
|
|
143
|
+
ios.close
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..')
|
|
3
|
+
|
|
4
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
7
|
+
# #
|
|
8
|
+
# This program is free software; you can redistribute it and/or #
|
|
9
|
+
# modify it under the terms of the GNU General Public License #
|
|
10
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
11
|
+
# of the License, or (at your option) any later version. #
|
|
12
|
+
# #
|
|
13
|
+
# This program is distributed in the hope that it will be useful, #
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
16
|
+
# GNU General Public License for more details. #
|
|
17
|
+
# #
|
|
18
|
+
# You should have received a copy of the GNU General Public License #
|
|
19
|
+
# along with this program; if not, write to the Free Software #
|
|
20
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
|
|
21
|
+
# #
|
|
22
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
23
|
+
# #
|
|
24
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
25
|
+
# #
|
|
26
|
+
# This software is part of BioDSL (www.BioDSL.org). #
|
|
27
|
+
# #
|
|
28
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
29
|
+
|
|
30
|
+
require 'test/helper'
|
|
31
|
+
|
|
32
|
+
class TestFork < Test::Unit::TestCase
|
|
33
|
+
def setup
|
|
34
|
+
@obj = {foo: "bar"}
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "BioDSL::Fork.new without block raises" do
|
|
38
|
+
assert_raise(ArgumentError) { BioDSL::Fork.new }
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test "BioDSL::Fork.read with no running fork raises" do
|
|
42
|
+
parent = BioDSL::Fork.new do |child|
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
assert_raise(BioDSL::ForkError) { parent.read }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
test "BioDSL::Fork.write with no running fork raises" do
|
|
49
|
+
parent = BioDSL::Fork.new do |child|
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
assert_raise(BioDSL::ForkError) { parent.write @obj }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
test "BioDSL::Fork.wait with no running fork raises" do
|
|
56
|
+
parent = BioDSL::Fork.new do |child|
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
assert_raise(BioDSL::ForkError) { parent.wait }
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
test "BioDSL::Fork.wait with running fork don't raise" do
|
|
63
|
+
parent = BioDSL::Fork.execute do |child|
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
assert_nothing_raised { parent.wait }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
test "BioDSL::Fork IPC returns correctly" do
|
|
70
|
+
parent = BioDSL::Fork.execute do |child|
|
|
71
|
+
obj = child.read
|
|
72
|
+
obj[:child] = true
|
|
73
|
+
child.write obj
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
parent.write @obj
|
|
77
|
+
parent.output.close
|
|
78
|
+
|
|
79
|
+
result = parent.read
|
|
80
|
+
|
|
81
|
+
parent.wait
|
|
82
|
+
|
|
83
|
+
assert_equal({foo: "bar", child: true}, result)
|
|
84
|
+
end
|
|
85
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', '..')
|
|
3
|
+
|
|
4
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
5
|
+
# #
|
|
6
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
7
|
+
# #
|
|
8
|
+
# This program is free software; you can redistribute it and/or #
|
|
9
|
+
# modify it under the terms of the GNU General Public License #
|
|
10
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
11
|
+
# of the License, or (at your option) any later version. #
|
|
12
|
+
# #
|
|
13
|
+
# This program is distributed in the hope that it will be useful, #
|
|
14
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
15
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
16
|
+
# GNU General Public License for more details. #
|
|
17
|
+
# #
|
|
18
|
+
# You should have received a copy of the GNU General Public License #
|
|
19
|
+
# along with this program; if not, write to the Free Software #
|
|
20
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #
|
|
21
|
+
# #
|
|
22
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
23
|
+
# #
|
|
24
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
25
|
+
# #
|
|
26
|
+
# This software is part of BioDSL (www.BioDSL.org). #
|
|
27
|
+
# #
|
|
28
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
29
|
+
|
|
30
|
+
require 'test/helper'
|
|
31
|
+
|
|
32
|
+
class MathTest < Test::Unit::TestCase
|
|
33
|
+
test "BioDSL::Math#dist_point2point returns correctly" do
|
|
34
|
+
assert_equal(1.5, BioDSL::Math.dist_point2point(1.0, 1.0, 1.0, 2.5))
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
test "BioDSL::Math#dist_point2line returns correctly" do
|
|
38
|
+
assert_equal(1.5, BioDSL::Math.dist_point2line( 3, 3, 0, 4.5, 5, 4.5))
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', '..')
|
|
3
|
+
|
|
4
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
5
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
6
|
+
# #
|
|
7
|
+
# This program is free software; you can redistribute it and/or #
|
|
8
|
+
# modify it under the terms of the GNU General Public License #
|
|
9
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
10
|
+
# of the License, or (at your option) any later version. #
|
|
11
|
+
# #
|
|
12
|
+
# This program is distributed in the hope that it will be useful, #
|
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
15
|
+
# GNU General Public License for more details. #
|
|
16
|
+
# #
|
|
17
|
+
# You should have received a copy of the GNU General Public License #
|
|
18
|
+
# along with this program; if not, write to the Free Software #
|
|
19
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, #
|
|
20
|
+
# USA. #
|
|
21
|
+
# #
|
|
22
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
23
|
+
# #
|
|
24
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
25
|
+
# #
|
|
26
|
+
# This software is part of BioDSL (www.github.com/maasha/BioDSL). #
|
|
27
|
+
# #
|
|
28
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
29
|
+
|
|
30
|
+
require 'test/helper'
|
|
31
|
+
|
|
32
|
+
# Test class for Mummer.
|
|
33
|
+
class TestMummer < Test::Unit::TestCase
|
|
34
|
+
def setup
|
|
35
|
+
omit('mummer not found') unless BioDSL::Filesys.which('mummer')
|
|
36
|
+
|
|
37
|
+
@entry1 = BioDSL::Seq.new(seq_name: 'test1', seq: 'ctagcttcaacctagctag')
|
|
38
|
+
@entry2 = BioDSL::Seq.new(seq_name: 'test2', seq: 'ctagcttcaGacctagctag')
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
test 'Mummer.each_mem with bad :length_min fails' do
|
|
42
|
+
assert_raise(BioDSL::MummerError) do
|
|
43
|
+
BioDSL::Mummer.each_mem(@entry1, @entry2, length_min: 0)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
assert_raise(BioDSL::MummerError) do
|
|
47
|
+
BioDSL::Mummer.each_mem(@entry1, @entry2, length_min: 5.5)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
test 'Mummer.each_mem with bad :direction fails' do
|
|
52
|
+
assert_raise(BioDSL::MummerError) do
|
|
53
|
+
BioDSL::Mummer.each_mem(@entry1, @entry2, direction: 'up')
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
test 'Mummer#each_mem returns OK' do
|
|
58
|
+
mems = BioDSL::Mummer.each_mem(@entry1, @entry2, length_min: 9)
|
|
59
|
+
expected = <<-END.gsub(/^\s+\|/, '')
|
|
60
|
+
|[#<struct BioDSL::Mummer::Match
|
|
61
|
+
| q_id="test2",
|
|
62
|
+
| s_id="test1",
|
|
63
|
+
| dir="forward",
|
|
64
|
+
| s_beg=0,
|
|
65
|
+
| q_beg=0,
|
|
66
|
+
| hit_len=9>,
|
|
67
|
+
| #<struct BioDSL::Mummer::Match
|
|
68
|
+
| q_id="test2",
|
|
69
|
+
| s_id="test1",
|
|
70
|
+
| dir="forward",
|
|
71
|
+
| s_beg=9,
|
|
72
|
+
| q_beg=10,
|
|
73
|
+
| hit_len=10>]
|
|
74
|
+
END
|
|
75
|
+
|
|
76
|
+
assert_equal(Enumerator, mems.class)
|
|
77
|
+
assert_equal(expected.gsub("\n", '').gsub(' ', ' '), mems.to_a.to_s)
|
|
78
|
+
end
|
|
79
|
+
end
|