npsearch 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,122 @@
1
+ #!/usr/bin/env ruby
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+
5
+ require 'bio'
6
+ require 'test/unit'
7
+
8
+ require 'npsearch'
9
+ require 'npsearch/arg_validator'
10
+
11
+ class InputChanged
12
+ # Changed to include the full entry definition rather than just the id. This
13
+ # was necessary for when testing individual parts since this is changed in
14
+ # pipeline
15
+ def read(input_file)
16
+ input_read = {}
17
+ biofastafile = Bio::FlatFile.open(Bio::FastaFormat, input_file)
18
+ biofastafile.each_entry do |entry|
19
+ # entry.definition used instead of entry.id
20
+ input_read[entry.definition] = entry.seq
21
+ end
22
+ input_read
23
+ end
24
+ end
25
+
26
+ class UnitTests < Test::Unit::TestCase
27
+ def setup # read all expected files
28
+ @dir = 'test/files'
29
+ @translation_test = NpSearch::Translation.new
30
+ @analysis_test = NpSearch::Analysis.new
31
+ @test_input1 = InputChanged.new
32
+ @test_arg_vldr = NpSearch::ArgValidators.new(:is_verbose)
33
+ @test_vldr = NpSearch::Validators.new
34
+ @test_input_read = NpSearch::Input.read("#{@dir}/genetic.fa")
35
+ @expected_translation = NpSearch::Input.read("#{@dir}/1_protein.fa")
36
+ @expected_orf = NpSearch::Input.read("#{@dir}/2_orf.fa")
37
+ @expected_sp_out_file = File.read("#{@dir}/3_signalp_out.txt")
38
+ @expected_secretome = @test_input1.read("#{@dir}/4_secretome.fa")
39
+ @expected_output = @test_input1.read("#{@dir}/5_output.fa")
40
+ @motif = 'KK|KR|RR|R..R|R....R|R......R|' \
41
+ 'H..R|H....R|H......R|K..R|K....R|K......R'
42
+ @motif_ar = %w(KR Kr kr)
43
+ @input_file_ar = ["#{@dir}/genetic.fa", "#{@dir}/protein.fa"]
44
+ @input_file_ar_neg = ["#{@dir}/empty_file.fa",
45
+ "#{@dir}/missing_input.fa", "#{@dir}/not_fasta.fa"]
46
+ @cut_off_ar = [622, 10, 2, 1]
47
+ @cut_off_ar_neg = [-10, 'hello', -5, 0]
48
+ end
49
+
50
+ def test_motif
51
+ (0..2).each do |i|
52
+ test_run = @test_arg_vldr.arg(@motif_ar[i], @input_file_ar[0], @dir,
53
+ @cut_off_ar[0], FALSE, nil, 'help_banner')
54
+ assert_equal('genetic', test_run)
55
+ end
56
+ end
57
+
58
+ def test_input_file
59
+ test_run = @test_arg_vldr.arg(@motif_ar[0], @input_file_ar[0], @dir,
60
+ @cut_off_ar[0], FALSE, nil, 'help_banner')
61
+ assert_equal('genetic', test_run)
62
+ test_run1 = @test_arg_vldr.arg(@motif_ar[0], @input_file_ar[1], @dir,
63
+ @cut_off_ar[0], FALSE, nil, 'help_banner')
64
+ assert_equal('protein', test_run1)
65
+ (0..2).each do |i|
66
+ test_run2 = lambda do
67
+ @test_arg_vldr.arg(@motif_ar[0], @input_file_ar_neg[i], @dir,
68
+ @cut_off_ar[0], FALSE, nil, 'help_banner')
69
+ end
70
+ assert_raise(ArgumentError) { test_run2 }
71
+ end
72
+ end
73
+
74
+ def test_orf_min_length
75
+ (0..3).each do |i|
76
+ test_run = @test_arg_vldr.arg(@motif_ar[0], @input_file_ar[0], @dir,
77
+ @cut_off_ar[i], FALSE, nil, 'help_banner')
78
+ assert_equal('genetic', test_run)
79
+ end
80
+ (0..3).each do |i|
81
+ test_run1 = lambda do
82
+ @test_arg_vldr.arg(@motif_ar[0], @input_file_ar[0], @dir,
83
+ @cut_off_ar_neg[i], FALSE, nil, 'help_banner')
84
+ end
85
+ assert_raise(ArgumentError) { test_run1 }
86
+ end
87
+ end
88
+
89
+ # => Test if the output directory validator works, in ensuring whether an
90
+ # output directory can be found.
91
+ def test_output_dir_validator
92
+ assert_equal(nil, @test_vldr.output_dir(@dir))
93
+ end
94
+
95
+ # => Test if the translation method works properly - assert that the produced
96
+ # translation is equal to the expected translation hash
97
+ def test_translate
98
+ translation_hash_test = NpSearch::Translation.translate(@test_input_read)
99
+ assert_equal(@expected_translation, translation_hash_test)
100
+ end
101
+
102
+ # => Test if the extract_orf method works properly - assert that the produced
103
+ # orf hash is equal to the expected orf hash.
104
+ # => In orf method, an array is produced while in the expected file read, an
105
+ # array isn't produced, thus it s necessary to remove "[ ]" from both end.
106
+ def test_extract_orf
107
+ orf_hash_test = NpSearch::Translation.extract_orf(@expected_translation, 10)
108
+ assert_equal(@expected_orf.to_s, orf_hash_test.to_s.gsub('["', '"')
109
+ .gsub('"]', '"'))
110
+ end
111
+
112
+ def test_parse
113
+ secretome = NpSearch::Analysis.parse("#{@dir}/3_signalp_out.txt",
114
+ @expected_orf, @motif)
115
+ assert_equal(@expected_secretome, secretome)
116
+ end
117
+
118
+ def test_flattener
119
+ flattened_output_test = NpSearch::Analysis.flattener(@expected_secretome)
120
+ assert_equal(@expected_output, flattened_output_test)
121
+ end
122
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: npsearch
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ismail Moghul
8
+ - Matthew Rowe
9
+ - Anurag Priyam
10
+ - Maurice Elphick
11
+ - Yannick Wurm
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2015-09-13 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: bundler
19
+ requirement: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - "~>"
22
+ - !ruby/object:Gem::Version
23
+ version: '1.6'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - "~>"
29
+ - !ruby/object:Gem::Version
30
+ version: '1.6'
31
+ - !ruby/object:Gem::Dependency
32
+ name: rake
33
+ requirement: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - "~>"
36
+ - !ruby/object:Gem::Version
37
+ version: '10.3'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - "~>"
43
+ - !ruby/object:Gem::Version
44
+ version: '10.3'
45
+ - !ruby/object:Gem::Dependency
46
+ name: coveralls
47
+ requirement: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ type: :development
53
+ prerelease: false
54
+ version_requirements: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ - !ruby/object:Gem::Dependency
60
+ name: bio
61
+ requirement: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - "~>"
64
+ - !ruby/object:Gem::Version
65
+ version: '1.4'
66
+ type: :runtime
67
+ prerelease: false
68
+ version_requirements: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - "~>"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.4'
73
+ - !ruby/object:Gem::Dependency
74
+ name: haml
75
+ requirement: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '4'
80
+ type: :runtime
81
+ prerelease: false
82
+ version_requirements: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - "~>"
85
+ - !ruby/object:Gem::Version
86
+ version: '4'
87
+ description: Search for Neuropeptides based solely on the common neuropeptide markers
88
+ (e.g. signal peptide, dibasic cleavage sites etc.) i.e. not based on homology to
89
+ known neuropeptides.
90
+ email:
91
+ - y.wurm@qmul.ac.uk
92
+ executables:
93
+ - npsearch
94
+ extensions: []
95
+ extra_rdoc_files: []
96
+ files:
97
+ - ".coveralls.yml"
98
+ - ".gitignore"
99
+ - ".travis.yml"
100
+ - Gemfile
101
+ - LICENSE.txt
102
+ - README.md
103
+ - Rakefile
104
+ - bin/npsearch
105
+ - lib/npsearch.rb
106
+ - lib/npsearch/arg_validator.rb
107
+ - lib/npsearch/logger.rb
108
+ - lib/npsearch/pool.rb
109
+ - lib/npsearch/sequence.rb
110
+ - lib/npsearch/signalp.rb
111
+ - lib/npsearch/version.rb
112
+ - npsearch.gemspec
113
+ - test/files/1_protein.fa
114
+ - test/files/2_orf.fa
115
+ - test/files/3_signalp_out.txt
116
+ - test/files/4_secretome.fa
117
+ - test/files/5_output.fa
118
+ - test/files/5_output.html
119
+ - test/files/empty_file.fa
120
+ - test/files/genetic.fa
121
+ - test/files/not_fasta.fa
122
+ - test/files/protein.fa
123
+ - test/files/signalp/signalp
124
+ - test/test_np_search.rb
125
+ homepage: https://github.com/IsmailM/NeuroPeptideSearch
126
+ licenses:
127
+ - AGPL
128
+ metadata: {}
129
+ post_install_message:
130
+ rdoc_options: []
131
+ require_paths:
132
+ - lib
133
+ required_ruby_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: 2.0.0
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 2.4.8
146
+ signing_key:
147
+ specification_version: 4
148
+ summary: Search for neuropeptides based on the common neuropeptides markers
149
+ test_files:
150
+ - test/files/1_protein.fa
151
+ - test/files/2_orf.fa
152
+ - test/files/3_signalp_out.txt
153
+ - test/files/4_secretome.fa
154
+ - test/files/5_output.fa
155
+ - test/files/5_output.html
156
+ - test/files/empty_file.fa
157
+ - test/files/genetic.fa
158
+ - test/files/not_fasta.fa
159
+ - test/files/protein.fa
160
+ - test/files/signalp/signalp
161
+ - test/test_np_search.rb
162
+ has_rdoc: