File: gt_splitfasta_include.rb

package info (click to toggle)
genometools 1.6.2%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 50,504 kB
  • sloc: ansic: 271,868; ruby: 30,327; python: 4,942; sh: 3,230; makefile: 1,214; perl: 219; pascal: 159; haskell: 37; sed: 5
file content (181 lines) | stat: -rw-r--r-- 5,395 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
require 'fileutils'

Name "gt splitfasta (default)"
Keywords "gt_splitfasta"
Test do
  run "cp #{$testdata}U89959_genomic.fas ."
  run_test "#{$bin}gt splitfasta U89959_genomic.fas"
  if not File.exists?("U89959_genomic.fas.1") then
    raise TestFailed, "file 'U89959_genomic.fas.1' does not exist"
  end
end

Name "gt splitfasta (compressed file)"
Keywords "gt_splitfasta"
Test do
  run "cp #{$testdata}U89959_genomic.fas ."
  run "gzip U89959_genomic.fas"
  run_test "#{$bin}gt splitfasta U89959_genomic.fas.gz"
  if not File.exists?("U89959_genomic.fas.1.gz") then
    raise TestFailed, "file 'U89959_genomic.fas.1.gz' does not exist"
  end
end

Name "gt splitfasta (-numfiles)"
Keywords "gt_splitfasta"
Test do
  run "cp #{$testdata}U89959_ests.fas ."
  run_test "#{$bin}gt splitfasta -numfiles 8 U89959_ests.fas"
  if not File.exists?("U89959_ests.fas.1") then
    raise TestFailed, "file 'U89959_ests.fas.1' does not exist"
  end
  if not File.exists?("U89959_ests.fas.8") then
    raise TestFailed, "file 'U89959_ests.fas.8' does not exist"
  end
  if File.exists?("U89959_ests.fas.9") then
    raise TestFailed, "file 'U89959_ests.fas.9' does exist"
  end
end

Name "gt splitfasta (file exists)"
Keywords "gt_splitfasta"
Test do
  run "cp #{$testdata}U89959_genomic.fas ."
  run "touch U89959_genomic.fas.1"
  run_test("#{$bin}gt splitfasta U89959_genomic.fas", :retval => 1)
  grep last_stderr, /exists already/
end

Name "gt splitfasta (-force)"
Keywords "gt_splitfasta"
Test do
  run "cp #{$testdata}U89959_genomic.fas ."
  run "touch U89959_genomic.fas.1"
  run_test "#{$bin}gt splitfasta -force U89959_genomic.fas"
  if not File.exists?("U89959_genomic.fas.1") then
    raise TestFailed, "file 'U89959_genomic.fas.1' does not exist"
  end
end

Name "gt splitfasta (-targetsize)"
Keywords "gt_splitfasta"
Test do
  run "cp #{$testdata}U89959_genomic.fas ."
  run_test "#{$bin}gt splitfasta -targetsize 1 U89959_genomic.fas"
  if not File.exists?("U89959_genomic.fas.1") then
    raise TestFailed, "file 'U89959_genomic.fas.1' does not exist"
  end
end

Name "gt splitfasta (-splitdesc, nonexistent file)"
Keywords "gt_splitfasta"
Test do
  run_test("#{$bin}gt splitfasta -splitdesc . #{$testdata}nonexistent_file",
           :retval => 1)
  grep last_stderr, /does not exist or is not readable/
end

Name "gt splitfasta (empty file)"
Keywords "gt_splitfasta"
Test do
  run_test("#{$bin}gt splitfasta #{$testdata}empty_file", :retval => 1)
  grep last_stderr, /is empty/
end


Name "gt splitfasta (corrupt file)"
Keywords "gt_splitfasta"
Test do
  run_test("#{$bin}gt splitfasta #{$testdata}gt_bioseq_fail_2.fas",
           :retval => 1)
  grep last_stderr, /file is not in FASTA format/
end

Name "gt splitfasta (-splitdesc)"
Keywords "gt_splitfasta"
Test do
  FileUtils.copy "#{$testdata}foobar.fas", "."
  run_test "#{$bin}gt splitfasta -splitdesc . foobar.fas"
  if not File.exists?("foo.fas") then
    raise TestFailed, "file 'foo.fas' does not exist"
  end
  if not File.exists?("bar.fas") then
    raise TestFailed, "file 'bar.fas' does not exist"
  end
end

Name "gt splitfasta (-splitdesc, file exists)"
Keywords "gt_splitfasta"
Test do
  FileUtils.copy "#{$testdata}foobar.fas", "."
  run "touch foo.fas"
  run_test("#{$bin}gt splitfasta -splitdesc . foobar.fas",
           :retval => 1)
  grep last_stderr, /exists already/
end

Name "gt splitfasta (-splitdesc -force)"
Keywords "gt_splitfasta"
Test do
  FileUtils.copy "#{$testdata}foobar.fas", "."
  run "touch foo.fas"
  run_test "#{$bin}gt splitfasta -force -splitdesc . foobar.fas"
  if not File.exists?("foo.fas") then
    raise TestFailed, "file 'foo.fas' does not exist"
  end
  if not File.exists?("bar.fas") then
    raise TestFailed, "file 'bar.fas' does not exist"
  end
end

Name "gt splitfasta (-splitdesc, compressed file)"
Keywords "gt_splitfasta"
Test do
  run "cp #{$testdata}foobar.fas ."
  run "gzip foobar.fas"
  run_test "#{$bin}gt splitfasta -splitdesc . foobar.fas.gz"
  if not File.exists?("foo.fas.gz") then
    raise TestFailed, "file 'foo.fas.gz' does not exist"
  end
  if not File.exists?("bar.fas.gz") then
    raise TestFailed, "file 'bar.fas.gz' does not exist"
  end
end

if $gttestdata then
  Name "gt splitfasta (large data, compressed)"
  Keywords "gt_splitfasta"
  Test do
    run "cp #{$gttestdata}ltrharvest/s_cer/chrAll_before-1997-10-01.fsa.gz " +
        "test.fas.gz"
    run_test("#{$bin}gt splitfasta -targetsize 2 test.fas.gz", :maxtime => 160)
    # check sample
    if not File.exists?("test.fas.2.gz") then
      raise TestFailed, "file 'test.fas.2.gz' does not exist"
    end
  end

  Name "gt splitfasta (large data, uncompressed)"
  Keywords "gt_splitfasta"
  Test do
    run "cp #{$gttestdata}ltrharvest/s_cer/chrAll_before-1997-10-01.fsa.gz " +
        "test.fas.gz"
    run "gunzip test.fas.gz"
    run_test "#{$bin}gt splitfasta -targetsize 2 test.fas"
    # check sample
    if not File.exists?("test.fas.2") then
      raise TestFailed, "file 'test.fas.2' does not exist"
    end
  end

  Name "gt splitfasta (large data, file exists)"
  Keywords "gt_splitfasta"
  Test do
    run "cp #{$gttestdata}ltrharvest/s_cer/chrAll_before-1997-10-01.fsa.gz " +
        "test.fas.gz"
    run "touch test.fas.2.gz"
    run_test("#{$bin}gt splitfasta -targetsize 1 test.fas.gz",
             :retval => 1, :maxtime => 120)
    grep last_stderr, /exists already/
  end
end