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
data/lib/BioDSL/fork.rb
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
4
|
+
# #
|
|
5
|
+
# This program is free software; you can redistribute it and/or #
|
|
6
|
+
# modify it under the terms of the GNU General Public License #
|
|
7
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
8
|
+
# of the License, or (at your option) any later version. #
|
|
9
|
+
# #
|
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
13
|
+
# GNU General Public License for more details. #
|
|
14
|
+
# #
|
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
|
16
|
+
# along with this program; if not, write to the Free Software #
|
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, #
|
|
18
|
+
# USA. #
|
|
19
|
+
# #
|
|
20
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
21
|
+
# #
|
|
22
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
23
|
+
# #
|
|
24
|
+
# This software is part of BioDSL (www.github.com/maasha/BioDSL). #
|
|
25
|
+
# #
|
|
26
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
27
|
+
|
|
28
|
+
# BioDSL namespace.
|
|
29
|
+
module BioDSL
|
|
30
|
+
# Error class for all Fork errors.
|
|
31
|
+
ForkError = Class.new(StandardError)
|
|
32
|
+
|
|
33
|
+
# Class containing methods to fork in an objective oriented manner.
|
|
34
|
+
class Fork
|
|
35
|
+
attr_reader :input, :output
|
|
36
|
+
|
|
37
|
+
# Class method to execute a block in a seperate process.
|
|
38
|
+
#
|
|
39
|
+
# @param block [Proc] Block to execute.
|
|
40
|
+
#
|
|
41
|
+
# @return [Fork] Instance of Fork.
|
|
42
|
+
def self.execute(&block)
|
|
43
|
+
parent = new(&block)
|
|
44
|
+
parent.execute
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Constructor for Fork.
|
|
48
|
+
#
|
|
49
|
+
# @param block [Proc] Block to execute.
|
|
50
|
+
#
|
|
51
|
+
# @raise [ArgumentError] If no block given.
|
|
52
|
+
#
|
|
53
|
+
# @return [Fork] Instance of Fork.
|
|
54
|
+
def initialize(&block)
|
|
55
|
+
fail ArgumentError, 'No block given' unless block
|
|
56
|
+
|
|
57
|
+
@parent = true
|
|
58
|
+
@alive = false
|
|
59
|
+
@pid = nil
|
|
60
|
+
@input = nil
|
|
61
|
+
@output = nil
|
|
62
|
+
@block = block
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
# Execute the block in a separate process.
|
|
66
|
+
def execute
|
|
67
|
+
@alive = true
|
|
68
|
+
|
|
69
|
+
child_read, parent_write = BioDSL::Stream.pipe
|
|
70
|
+
parent_read, child_write = BioDSL::Stream.pipe
|
|
71
|
+
|
|
72
|
+
pid = fork_process(child_read, child_write, parent_read, parent_write)
|
|
73
|
+
|
|
74
|
+
child_write.close
|
|
75
|
+
child_read.close
|
|
76
|
+
|
|
77
|
+
@pid = pid
|
|
78
|
+
@input = parent_read
|
|
79
|
+
@output = parent_write
|
|
80
|
+
|
|
81
|
+
self
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# Determines if process is running.
|
|
85
|
+
#
|
|
86
|
+
# @return [Bool] True if running else nil.
|
|
87
|
+
def running?
|
|
88
|
+
@pid
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Read object from forked process.
|
|
92
|
+
#
|
|
93
|
+
# @raise [ForkError] unless process is running.
|
|
94
|
+
def read
|
|
95
|
+
fail BioDSL::ForkError, 'Not running' unless running?
|
|
96
|
+
|
|
97
|
+
@input.read
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# Write object to forked process.
|
|
101
|
+
#
|
|
102
|
+
# @raise [ForkError] unless process is running.
|
|
103
|
+
def write(obj)
|
|
104
|
+
fail BioDSL::ForkError, 'Not running' unless running?
|
|
105
|
+
|
|
106
|
+
@output.write(obj)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# Wait for forked process.
|
|
110
|
+
#
|
|
111
|
+
# @raise [ForkError] unless process is running.
|
|
112
|
+
def wait
|
|
113
|
+
fail BioDSL::ForkError, 'Not running' unless running?
|
|
114
|
+
|
|
115
|
+
@input.close unless @input.closed?
|
|
116
|
+
@output.close unless @output.closed?
|
|
117
|
+
|
|
118
|
+
Process.wait(@pid)
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
private
|
|
122
|
+
|
|
123
|
+
# Fork process with IPC.
|
|
124
|
+
#
|
|
125
|
+
# @param child_read [BioDSL::Stream] Child read IO.
|
|
126
|
+
# @param child_write [BioDSL::Stream] Child write IO.
|
|
127
|
+
# @param parent_read [BioDSL::Stream] Parent read IO.
|
|
128
|
+
# @param parent_write [BioDSL::Stream] Parent write IO.
|
|
129
|
+
#
|
|
130
|
+
# @return [FixNum] Process ID.
|
|
131
|
+
def fork_process(child_read, child_write, parent_read, parent_write)
|
|
132
|
+
Process.fork do
|
|
133
|
+
parent_write.close
|
|
134
|
+
parent_read.close
|
|
135
|
+
|
|
136
|
+
@parent = false
|
|
137
|
+
@pid = Process.pid
|
|
138
|
+
@input = child_read
|
|
139
|
+
@output = child_write
|
|
140
|
+
|
|
141
|
+
@block.call(self)
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|
|
145
|
+
end
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
4
|
+
# #
|
|
5
|
+
# This program is free software; you can redistribute it and/or #
|
|
6
|
+
# modify it under the terms of the GNU General Public License #
|
|
7
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
8
|
+
# of the License, or (at your option) any later version. #
|
|
9
|
+
# #
|
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
13
|
+
# GNU General Public License for more details. #
|
|
14
|
+
# #
|
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
|
16
|
+
# along with this program; if not, write to the Free Software #
|
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, #
|
|
18
|
+
# USA. #
|
|
19
|
+
# #
|
|
20
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
21
|
+
# #
|
|
22
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
23
|
+
# #
|
|
24
|
+
# This software is part of BioDSL (www.github.com/maasha/BioDSL). #
|
|
25
|
+
# #
|
|
26
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
27
|
+
|
|
28
|
+
# Namespace for BioDSL.
|
|
29
|
+
module BioDSL
|
|
30
|
+
# Error class for all exceptions to do with Hamming.
|
|
31
|
+
HammingError = Class.new(StandardError)
|
|
32
|
+
|
|
33
|
+
# Class for calculating Hamming distance.
|
|
34
|
+
class Hamming
|
|
35
|
+
extend Ambiguity
|
|
36
|
+
|
|
37
|
+
# Class method for calculating the Hamming distance between
|
|
38
|
+
# two given strings optionally allowing for IUPAC ambiguity codes.
|
|
39
|
+
#
|
|
40
|
+
# @param str1 [String] String 1.
|
|
41
|
+
# @param str2 [String] String 2.
|
|
42
|
+
# @param options [Hash] Options hash.
|
|
43
|
+
# @option options [Boolean] :ambiguity
|
|
44
|
+
def self.distance(str1, str2, options = {})
|
|
45
|
+
check_strings(str1, str2)
|
|
46
|
+
|
|
47
|
+
hd = new
|
|
48
|
+
|
|
49
|
+
if options[:ambiguity]
|
|
50
|
+
hd.hamming_distance_ambiguity_C(str1, str2, str1.length)
|
|
51
|
+
else
|
|
52
|
+
hd.hamming_distance_C(str1, str2, str1.length)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Check that string lengths are equal.
|
|
57
|
+
#
|
|
58
|
+
# @param str1 [String] String 1.
|
|
59
|
+
# @param str2 [String] String 2.
|
|
60
|
+
#
|
|
61
|
+
# @raise [HammingError] if string lengths mismatch.
|
|
62
|
+
def self.check_strings(str1, str2)
|
|
63
|
+
return if str1.length == str2.length
|
|
64
|
+
|
|
65
|
+
fail HammingError, "bad string lengths: #{str1.length} != #{str2.length}"
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# >>>>>>>>>>>>>>> RubyInline C code <<<<<<<<<<<<<<<
|
|
69
|
+
|
|
70
|
+
inline do |builder|
|
|
71
|
+
add_ambiguity_macro(builder)
|
|
72
|
+
|
|
73
|
+
# C method for calculating Hamming Distance.
|
|
74
|
+
builder.c %{
|
|
75
|
+
VALUE hamming_distance_C(
|
|
76
|
+
VALUE _str1, // String 1
|
|
77
|
+
VALUE _str2, // String 2
|
|
78
|
+
VALUE _len // String length
|
|
79
|
+
)
|
|
80
|
+
{
|
|
81
|
+
char *str1 = StringValuePtr(_str1);
|
|
82
|
+
char *str2 = StringValuePtr(_str2);
|
|
83
|
+
unsigned int len = FIX2UINT(_len);
|
|
84
|
+
|
|
85
|
+
unsigned int hamming_dist = 0;
|
|
86
|
+
unsigned int i = 0;
|
|
87
|
+
|
|
88
|
+
for (i = 0; i < len; i++)
|
|
89
|
+
{
|
|
90
|
+
if (str1[i] != str2[i])
|
|
91
|
+
{
|
|
92
|
+
hamming_dist++;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return UINT2NUM(hamming_dist);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# C method for calculating Hamming Distance.
|
|
101
|
+
builder.c %{
|
|
102
|
+
VALUE hamming_distance_ambiguity_C(
|
|
103
|
+
VALUE _str1, // String 1
|
|
104
|
+
VALUE _str2, // String 2
|
|
105
|
+
VALUE _len // String length
|
|
106
|
+
)
|
|
107
|
+
{
|
|
108
|
+
char *str1 = StringValuePtr(_str1);
|
|
109
|
+
char *str2 = StringValuePtr(_str2);
|
|
110
|
+
unsigned int len = FIX2UINT(_len);
|
|
111
|
+
|
|
112
|
+
unsigned int hamming_dist = 0;
|
|
113
|
+
unsigned int i = 0;
|
|
114
|
+
|
|
115
|
+
for (i = 0; i < len; i++)
|
|
116
|
+
{
|
|
117
|
+
if (! MATCH(str1[i], str2[i]))
|
|
118
|
+
{
|
|
119
|
+
hamming_dist++;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return UINT2NUM(hamming_dist);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
4
|
+
# #
|
|
5
|
+
# This program is free software; you can redistribute it and/or #
|
|
6
|
+
# modify it under the terms of the GNU General Public License #
|
|
7
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
8
|
+
# of the License, or (at your option) any later version. #
|
|
9
|
+
# #
|
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
13
|
+
# GNU General Public License for more details. #
|
|
14
|
+
# #
|
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
|
16
|
+
# along with this program; if not, write to the Free Software #
|
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, #
|
|
18
|
+
# USA. #
|
|
19
|
+
# #
|
|
20
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
21
|
+
# #
|
|
22
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
23
|
+
# #
|
|
24
|
+
# This software is part of BioDSL (www.github.com/maasha/BioDSL). #
|
|
25
|
+
# #
|
|
26
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
27
|
+
|
|
28
|
+
# Namespace for BioDSL.
|
|
29
|
+
module BioDSL
|
|
30
|
+
# Namespace for AuxHelper.
|
|
31
|
+
module AuxHelper
|
|
32
|
+
BioDSL::AuxiliaryError = Class.new(StandardError)
|
|
33
|
+
|
|
34
|
+
# Method that raises if the given command is not found on the system.
|
|
35
|
+
#
|
|
36
|
+
# @param command [String] Command that must exist.
|
|
37
|
+
#
|
|
38
|
+
# @raise [AuxiliaryError] if command is not found.
|
|
39
|
+
def aux_exist(command)
|
|
40
|
+
return if BioDSL::Filesys.which(command)
|
|
41
|
+
fail AuxiliaryError, "command: #{command} not found"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
4
|
+
# #
|
|
5
|
+
# This program is free software; you can redistribute it and/or #
|
|
6
|
+
# modify it under the terms of the GNU General Public License #
|
|
7
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
8
|
+
# of the License, or (at your option) any later version. #
|
|
9
|
+
# #
|
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
13
|
+
# GNU General Public License for more details. #
|
|
14
|
+
# #
|
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
|
16
|
+
# along with this program; if not, write to the Free Software #
|
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, #
|
|
18
|
+
# USA. #
|
|
19
|
+
# #
|
|
20
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
21
|
+
# #
|
|
22
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
23
|
+
# #
|
|
24
|
+
# This software is part of BioDSL (www.github.com/maasha/BioDSL). #
|
|
25
|
+
# #
|
|
26
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
27
|
+
|
|
28
|
+
module BioDSL
|
|
29
|
+
# Namespace for EmailHelper.
|
|
30
|
+
module EmailHelper
|
|
31
|
+
# Send email notification to email address specfied in @options[:email],
|
|
32
|
+
# including a optional subject specified in @options[:subject], that will
|
|
33
|
+
# otherwise default to self.to_s. The body of the email will be an HTML
|
|
34
|
+
# report.
|
|
35
|
+
#
|
|
36
|
+
# @param pipeline [BioDSL::Pipeline] Pipeline object
|
|
37
|
+
def send_email(pipeline)
|
|
38
|
+
return unless @options[:email]
|
|
39
|
+
|
|
40
|
+
html_part = Mail::Part.new do
|
|
41
|
+
content_type 'text/html; charset=UTF-8'
|
|
42
|
+
body BioDSL::HtmlReport.new(pipeline).to_html
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
compose_mail(html_part).deliver!
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Compose an email.
|
|
49
|
+
#
|
|
50
|
+
# @param html_part [Mail::Part] The email body.
|
|
51
|
+
#
|
|
52
|
+
# @return [Mail] Mail to be sent.
|
|
53
|
+
def compose_mail(html_part)
|
|
54
|
+
mail = Mail.new
|
|
55
|
+
mail[:from] = "do-not-reply@#{`hostname -f`.strip}"
|
|
56
|
+
mail[:to] = @options[:email]
|
|
57
|
+
mail[:subject] = @options[:subject] || to_s.first(30)
|
|
58
|
+
mail.html_part = html_part
|
|
59
|
+
mail.delivery_method :smtp,
|
|
60
|
+
address: 'localhost',
|
|
61
|
+
port: 25,
|
|
62
|
+
enable_starttls_auto: false
|
|
63
|
+
mail
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
4
|
+
# #
|
|
5
|
+
# This program is free software; you can redistribute it and/or #
|
|
6
|
+
# modify it under the terms of the GNU General Public License #
|
|
7
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
8
|
+
# of the License, or (at your option) any later version. #
|
|
9
|
+
# #
|
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
13
|
+
# GNU General Public License for more details. #
|
|
14
|
+
# #
|
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
|
16
|
+
# along with this program; if not, write to the Free Software #
|
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, #
|
|
18
|
+
# USA. #
|
|
19
|
+
# #
|
|
20
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
21
|
+
# #
|
|
22
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
23
|
+
# #
|
|
24
|
+
# This software is part of BioDSL (www.github.com/maasha/BioDSL). #
|
|
25
|
+
# #
|
|
26
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
27
|
+
|
|
28
|
+
module BioDSL
|
|
29
|
+
# Namespace for HistoryHelper.
|
|
30
|
+
module HistoryHelper
|
|
31
|
+
# Save pipeline to history file unless test is set.
|
|
32
|
+
def save_history
|
|
33
|
+
return if BioDSL.test
|
|
34
|
+
|
|
35
|
+
File.open(BioDSL::Config::HISTORY_FILE, 'a') do |ios|
|
|
36
|
+
ios.puts to_s
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
2
|
+
# #
|
|
3
|
+
# Copyright (C) 2007-2015 Martin Asser Hansen (mail@maasha.dk). #
|
|
4
|
+
# #
|
|
5
|
+
# This program is free software; you can redistribute it and/or #
|
|
6
|
+
# modify it under the terms of the GNU General Public License #
|
|
7
|
+
# as published by the Free Software Foundation; either version 2 #
|
|
8
|
+
# of the License, or (at your option) any later version. #
|
|
9
|
+
# #
|
|
10
|
+
# This program is distributed in the hope that it will be useful, #
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
13
|
+
# GNU General Public License for more details. #
|
|
14
|
+
# #
|
|
15
|
+
# You should have received a copy of the GNU General Public License #
|
|
16
|
+
# along with this program; if not, write to the Free Software #
|
|
17
|
+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, #
|
|
18
|
+
# USA. #
|
|
19
|
+
# #
|
|
20
|
+
# http://www.gnu.org/copyleft/gpl.html #
|
|
21
|
+
# #
|
|
22
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
23
|
+
# #
|
|
24
|
+
# This software is part of BioDSL (www.github.com/maasha/BioDSL). #
|
|
25
|
+
# #
|
|
26
|
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< #
|
|
27
|
+
|
|
28
|
+
module BioDSL
|
|
29
|
+
# Namespace for LogHelper.
|
|
30
|
+
module LogHelper
|
|
31
|
+
require 'yaml'
|
|
32
|
+
|
|
33
|
+
# Log an OK messge to the log file.
|
|
34
|
+
def log_ok
|
|
35
|
+
return if BioDSL.test
|
|
36
|
+
|
|
37
|
+
File.open(BioDSL::Config::LOG_FILE, 'a') do |ios|
|
|
38
|
+
ios.puts to_s
|
|
39
|
+
ios.puts status.to_yaml
|
|
40
|
+
ios.puts 'OK'
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Log an ERROR messge to the log file.
|
|
45
|
+
def log_error(exception)
|
|
46
|
+
File.open(BioDSL::Config::LOG_FILE, 'a') do |ios|
|
|
47
|
+
ios.puts to_s
|
|
48
|
+
ios.puts status.to_yaml if self.respond_to? :status
|
|
49
|
+
ios.puts 'ERROR'
|
|
50
|
+
ios.puts exception.message
|
|
51
|
+
ios.puts exception.backtrace
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|