-
Notifications
You must be signed in to change notification settings - Fork 0
/
CorrSieve-1.7-0.rb
764 lines (758 loc) · 21.4 KB
/
CorrSieve-1.7-0.rb
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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
#-----------------------------------------------------------------------------------------------
# CorrSieve 1.7-0: software to summarise and evaluate output from STRUCTURE
# Noted code improvements by Michael G. Campana (2019) are in the public domain
# as a US government work.
#
# Original source code is from:
# CorrSieve 1.6-5: software to summarise and evaluate output from STRUCTURE
# Copyright (C) 2010-2011 Michael G. Campana
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#-----------------------------------------------------------------------------------------------
class Array
#-----------------------------------------------------------------------------------------------
# Method each_permutation removed in CorrSieve 1.7-0 update
def inexact
a = []
b = []
q = self.size - 1
for count in 0 .. q
ran = rand(q)
while b.include?(count)
ran += 1
ran = 0 if ran > q
end
b.push(count)
a.push(self[ran])
end
return a
end
end
#------------------------------------------------
# Universal Variables
#------------------------------------------------
$k = 1 # maximum K value
$numK = [] # iterations of K
$save = "" # save file path
$corr = false # calculate matrix correlations
$r2 = 0.7 # minimum r for filter
$usep = false # determines whether to use permutation test for p
$p = 0.05 # minimum p for filter
$maxcorr = false
$input_arrays = [] # input data array
$print = false # option to print correlations matrices
$inexact = false # use inexact p
$iterat = 1 # number of iterations to estimate p
$deltaK = false # whether to calculate deltaK
$dKarray = [] # array to store LnPD data
$Fst = false # calculate mean Fsts
$Fstarray = [] # array to store Fst data
$Fstopt = 1 #method for Fst statistics optimisation
#-------------------------------------------------
# Additional Methods
#-------------------------------------------------
def mean(val = [])
mean = 0.0
for i in 0.. val.size-1
mean += val[i]
end
mean /= val.size
return mean
end
#-------------------------------------------------
def stdev(val = [])
me = mean(val)
st = 0.0
for stval in val
add = (stval - me) * (stval - me)
st += add
end
de = (val.size - 1).to_f
st /= de
st2 = Math.sqrt(st)
return st2
end
#-------------------------------------------------
def calc_dK
dk = "K\tMean lnP(D)\tL'(K)\tL''(K)\tdelta K\n"
means = []
stdevs = []
first = []
second = []
dKs = []
for i in 1 .. $k
if $numK[i-1] > 1
me = mean($dKarray[i-1])
means.push(me)
stdevs.push(stdev($dKarray[i-1]))
else
means.push("NA")
stdevs.push("NA")
end
end
for i in 0 .. $k - 1
if (means[i] != "NA" and means[i-1] != "NA" and i != 0)
val = means[i]-means[i-1]
first.push(val)
else
first.push("NA")
end
end
for i in 0 .. $k - 1
if (first[i+1] != "NA" and first[i] != "NA" and stdevs[i] != "NA" and i != $k - 1)
val = first[i+1] - first[i]
second.push(val.abs)
dKs.push(val.abs/stdevs[i])
else
second.push("NA")
dKs.push("NA")
end
end
for i in 1 .. $k
add = i.to_s + "\t" + means[i-1].to_s + "\t" + first[i-1].to_s + "\t" + second[i-1].to_s + "\t" + dKs[i-1].to_s + "\n"
dk+= add
end
return dk
end
#-------------------------------------------------
def deltaF(df = [])
first = []
dFs = []
means = []
stdevs = []
for i in 1 .. $k
if $numK[i-1] > 1
means.push(mean(df[i-1]))
stdevs.push(stdev(df[i-1]))
else
means.push("NA")
stdevs.push("NA")
end
end
for i in 0 .. $k - 1
if (means[i] != "NA" and means[i-1] != "NA" and i != 0)
first.push(means[i] - means[i -1])
else
first.push("NA")
end
end
for i in 0 .. $k - 1
if (first[i+1] != "NA" and first[i] != "NA" and stdevs[i] != "NA" and i != $k - 1)
dFs.push((first[i+1] - first[i]).abs/stdevs[i])
else
dFs.push("NA")
end
end
return dFs
end
#-------------------------------------------------
def pvalue(roar, alpha = [], beta = [])
greater = 0.0
total = 0.0
perm = alpha.permutation.to_a # Improvement of permutation code in public domain [line 164]
for i in 0 .. perm.size-1
greater += 1.0 if corr(perm[i], beta).abs >= roar
total += 1.0
end
p = greater/total
return p
end
#-------------------------------------------------
def corr(alpha = [], beta =[])
meanx = mean(alpha)
meany = mean(beta)
numer = 0.0
denomx = 0.0
denomy = 0.0
for i in 0..alpha.size-1
numer += ((alpha[i]-meanx) * (beta[i]-meany))
denomx += ((alpha[i]-meanx)*(alpha[i]-meanx))
denomy += ((beta[i]-meany) * (beta[i]-meany))
end
r = numer/(Math.sqrt(denomx)*Math.sqrt(denomy))
return r
end
#-------------------------------------------------
def import_data(file)
kbreak = false
start = false
data = []
count = 0
fstopt = []
File.open(file, 'r') do |imp|
while line = imp.gets
break if kbreak
if line.include?("populations assumed")
line2 = line.delete " populations assumed"
@kvalue = line2.to_i
$numK[@kvalue - 1] += 1
kbreak = true
elsif line.include?("Population number assumed=")
line2 = line.delete "Population number assumed="
@kvalue = line2.to_i
$numK[@kvalue - 1] += 1
kbreak = true
end
end
end
for i in 1 .. @kvalue
data.push([])
end
File.open(file, 'r') do |imp|
while line = imp.gets
break if start and line == "\n"
if $Fst
if line.include?("Mean value of Fst_")
if $Fstopt == 2
fstopt.push(line[29+(count+1).to_s.length,6].to_f)
else
$Fstarray[@kvalue - 1][count].push(line[29+(count+1).to_s.length,6].to_f)
end
count += 1
end
end
if $deltaK
if line.include?("Estimated Ln Prob of Data")
line2 = line.delete "Estimated Ln Prob of Data = "
$dKarray[@kvalue - 1].push line2.to_f
elsif line.include?("Posterior Mean = ")
line2 = line.delete "Posterior Mean = "
$dKarray[@kvalue - 1].push line2.to_f
end
end
if (start and ($corr or $Fstopt == 3))
while line.include?(":")
line[0,1] = ""
end
line.gsub!("\t"," ") if line.include?("\t")
line[0,2] = ""
for i in 0 .. @kvalue - 1
val = line[i * 6,5]
data[i].push val.to_f
end
end
start = true if line.include?("Label (%Miss)")
start = true if line.include?("Label\t(Miss)")
end
end
if $Fstopt == 2
fstopt.sort!
for x in 0 .. count - 1
$Fstarray[@kvalue - 1][x].push(fstopt[x])
end
end
$input_arrays[@kvalue - 1].push(data)
end
#-------------------------------------------------
def valid(val = "")
while (val.upcase != "Y" and val.upcase != "YES" and val.upcase != "N" and val.upcase != "NO")
puts "Invalid response. Please re-enter (Y/N)."
val = gets.chomp
end
return val
end
#-------------------------------------------------
# Processing Block: Calculations begin here.
#-------------------------------------------------
def process_data # Conversion to method in CorrSieve 1.7-0 update (Lines 269-270 is public domain)
puts "Please enter the path to the file folder."
@folder = gets.chomp
while !FileTest.directory?(@folder)
print "Folder not found. Please re-enter the path carefully.\n"
@folder = gets.chomp
end
puts "Please enter path for the saved files.\nPressing ENTER will keep the current directory."
$save = gets.chomp
$save = File.expand_path("") if $save == ""
Dir.mkdir($save) if !FileTest.directory?($save)
@run = ""
while @run == ""
puts "Please enter the run name."
@run = gets.chomp
end
$save += "/"
$save += @run
puts "Calculate Q matrix correlations? (Y/N)"
tmp = gets.chomp
tmp = valid(tmp)
if tmp.upcase == "Y" or tmp.upcase == "YES"
$corr = true
end
if $corr
puts "Please enter minimum r value.\n"
$r2 = gets.chomp.to_f
while $r2.abs > 1.0
print "Invalid r value. Please re-enter.\n"
$r2 = gets.chomp.to_f
end
puts "Use p-value cut-off? (Y/N)"
tmp = gets.chomp
tmp = valid(tmp)
if tmp.upcase == "Y" or tmp.upcase == "YES"
$usep = true
puts "Estimate p? (Y/N). If no, CorrSieve will calculate an\nexact p. This will be very slow."
tmp = gets.chomp
tmp = valid(tmp)
if tmp.upcase == "Y" or tmp.upcase == "YES"
$inexact = true
puts "Please enter the number of permutations to estimate p values."
$iterat = gets.chomp.to_i
while $iterat < 1
print "Invalid number of permutations. Please re-enter.\n"
$iterat = gets.chomp.to_i
end
end
puts "Please enter maximum p value.\n"
$p = gets.chomp.to_f
while $p < 0.0 or $p > 1.0
print "Invalid p value. Please re-enter.\n"
$p = gets.chomp.to_f
end
end
puts "Use average max correlation criterion? (Y/N). If no\nCorrSieve will use column and row criterion."
tmp = gets.chomp
tmp = valid(tmp)
if tmp.upcase == "Y" or tmp.upcase == "YES"
$maxcorr = true
end
puts "Output unfiltered correlation matrices? (Y/N)"
tmp = gets.chomp
tmp = valid(tmp)
if tmp.upcase == "Y" or tmp.upcase == "YES"
$print = true
end
end
puts "Summarise Ln P(D) and calculate delta K? (Y/N)"
tmp = gets.chomp
tmp = valid(tmp)
if tmp.upcase == "Y" or tmp.upcase == "YES"
$deltaK = true
end
puts "Calculate Fst statistics? (Y/N)"
tmp = gets.chomp
tmp = valid(tmp)
if tmp.upcase == "Y" or tmp.upcase == "YES"
$Fst = true
puts "Select Fst statistics optimisation method:\n1. No optimisation\n2. Order Fst data by value\n3. Use matrix correlations"
$Fstopt = gets.chomp.to_i
while $Fstopt != 1 and $Fstopt !=2 and $Fstopt !=3
puts "Invalid selection. Select Fst statistics optimisation method:\n1. No optimisation\n2. Order Fst data by value\n3. Use matrix correlations"
$Fstopt = gets.chomp.to_i
end
end
#-------------------------------------------------------
# Data import block
#-------------------------------------------------------
puts "Processing...This may take a while. Tea break?"
Dir.foreach(@folder + "/") do |imp|
if imp[-2,2] == "_f"
kbreak = false
File.open(@folder + "/" + imp, 'r') do |kcheck|
while line = kcheck.gets
break if kbreak
if line.include?("populations assumed")
line2 = line.delete " populations assumed"
$k = line2.to_i if $k < line2.to_i
kbreak = true
elsif line.include?("Population number assumed=")
line2 = line.delete "Population number assumed="
$k = line2.to_i if $k <line2.to_i
kbreak = true
end
end
end
end
end
for i in 1 .. $k
$numK.push(0)
$input_arrays.push([])
$dKarray.push [] if $deltaK
if $Fst
$Fstarray.push []
for j in 1 .. $k - ($k - i)
$Fstarray[i-1].push []
end
end
end
Dir.foreach(@folder + "/") do |imp|
import_data(@folder + "/" + imp) if imp[-2,2] == "_f"
end
GC.start
#-------------------------------------------------------
# Data processing block
# Vars:
# i: determines the K value. This needs to iterate once for each K and will not permute
# j: determines the run number of matrix 1. Needs to COMBINE
# k: determines the col. of matrix 1. Needs to permute
# l: determines the run number of matrix 2. Needs to COMBINE
# m: determines the col. of matrix 2. Needs to permute
#-----------------------------------------------------
if $corr
out = ""
filter = ""
if $maxcorr
mcorr = 0
mcarr = []
mcfilt = "\n"
else
filtx = false
filty = true
end
for i in 0 .. $k - 1
if $numK[i] > 1
add = "K = " + (i+1).to_s + "\n"
out += add
filter += add
if $maxcorr
filter += "Average Max Correlation = "
else
filter += " "
for a in 2 .. $numK[i]
add = "\t" + a.to_s
filter += add
end
filter += "\n"
end
for j in 0 .. $numK[i] - 2
la = j
if !$maxcorr
filter += (j+1).to_s
if j > 0
for f in 1 .. $k - ($k - j)
filter += "\t"
end
end
end
for l in 1 .. $numK[i] - (j + 1)
la += 1
add = "Run " + (j+1).to_s + " versus Run " + (la+1).to_s + "\n"
out += add
mat = []
matp = []
for k in $input_arrays[i][j]
x = []
xp = []
for m in $input_arrays[i][la]
r = corr(k, m)
x.push(r)
out += r.to_s
filtx = true if (r.abs >= $r2.abs and !$maxcorr)
if $usep
if $inexact
greater = 0.0
total = 0.0
for u in 1 .. $iterat
k1 = k.inexact
m1 = m.inexact
total += 1.0
greater += 1.0 if corr(k1, m1).abs >= r
end
p = greater/total
xp.push(p)
else
p = pvalue(r.abs,k,m)
xp.push(p)
end
add = "(" + p.to_s + ")"
out += add
if $maxcorr
mcorr = r.abs if (r.abs > mcorr and p <= $p)
else
filtx = false unless (r.abs >= $r2.abs and p <= $p)
end
elsif $maxcorr
mcorr = r.abs if (r.abs > mcorr)
end
out += " "
mat.push(x)
matp.push(xp)
end
testy = []
out += "\n"
if $maxcorr
mcarr.push mcorr
mcorr = 0
else
for z in 0 .. mat.size - 1
tempy = false
for y in 0 .. mat[z].size - 1
tempy = true if mat[z][y].abs >= $r2.abs
if $usep
tempy = false unless (mat[z][y].abs >= $r2.abs and matp[z][y].abs <= $p)
end
end
testy.push(tempy)
end
end
end
if !$maxcorr
filty = false if testy.include?(false)
if filtx and filty
filter += "\tY"
else
filter += "\tN"
end
filtx = false
filty = true
end
out += "\n"
end
if !$maxcorr
filter += "\n"
end
end
out += "\n"
if $maxcorr
filter += mean(mcarr).to_s
if mean(mcarr) >= $r2
mcfilt += "\tY"
else
mcfilt += "\tN"
end
end
mcarr = []
filter += "\n\n"
end
end
if $maxcorr
filter += "Significant Correlations\nK = "
for i in 1 .. $k
if $numK[i-1] > 1
filter += "\t"
filter += i.to_s
end
end
filter += mcfilt
end
if $print
filename = $save + "-matrix_correlations.txt"
File.open(filename, 'w') do |f2|
f2.puts out
end
end
filename = $save +"-filtered.txt"
File.open(filename, 'w') do |f2|
f2.puts filter
end
end
if $deltaK
filename = $save + "-deltaK.txt"
File.open(filename, 'w') do |f2|
f2.puts calc_dK
end
end
if $Fst
test = ""
df = []
dats = "\nK\tOverall Mean Fst\tOverall St. Dev.\tSt. Dev. of Means\tMean St. Dev.\tSt. Dev. of St. Devs.\tdelta Fst\n"
datsarr = []
for i in 1 .. $k
tmp = []
tmp2 = []
tmp3 = []
if $Fstopt == 3 and i > 1
for j in 1 .. $numK[i-1] - 1
xmat = []
xtmp = []
fstarr = []
for k in $input_arrays[i-1][0]
x = []
for m in $input_arrays[i-1][j]
r = corr(k, m)
x.push(r)
end
xmat.push(x)
end
for f in 0 .. i - 1
fstarr.push($Fstarray[i-1][f][j])
end
for f in 0 .. i -1
rv = -1.0
sp = 1
for g in 0 .. i -1
if xmat[f][g] > rv
rv = xmat[f][g]
sp = g
end
end
xtmp.push(fstarr[sp])
for h in xmat
h[sp] = - 2
end
end
for f in 0 .. i - 1
$Fstarray[i-1][f][j] = xtmp[f]
end
end
end
if $numK[i-1] > 0
add = "K = " + i.to_s + "\nCluster\tMean Fst\tSt. Dev.\n"
test += add
for j in 1 .. $k - ($k - i)
if $numK[i-1] > 1
add = j.to_s + "\t" + mean($Fstarray[i-1][j-1]).to_s + "\t" + stdev($Fstarray[i-1][j-1]).to_s + "\n"
tmp2.push(stdev($Fstarray[i-1][j-1]))
else
add = j.to_s + "\t" + $Fstarray[i-1][j-1].to_s + "\tNA\n"
tmp2.push("NA")
end
for dat in $Fstarray[i-1][j-1]
tmp3.push(dat)
end
tmp.push(mean($Fstarray[i-1][j-1]))
test += add
end
else
tmp.push("NA")
tmp2.push("NA")
tmp3.push("NA")
end
df.push(tmp3)
if tmp.include?("NA")
metmp = "NA"
sdtmp = "NA"
else
metmp = mean(tmp).to_s
if tmp.size > 1
sdtmp = stdev(tmp).to_s
else
sdtmp = "NA"
end
end
if tmp2.include?("NA")
metmp2 = "NA"
sdtmp2 = "NA"
else
metmp2 = mean(tmp2).to_s
if tmp2.size > 1
sdtmp2 = stdev(tmp2).to_s
else
sdtmp2 = "NA"
end
end
if tmp3.include?("NA")
metmp3 = "NA"
sdtmp3 = "NA"
else
metmp3 = mean(tmp3).to_s
if tmp3.size > 1
sdtmp3 = stdev(tmp3).to_s
else
sdtmp3 = "NA"
end
end
add = i.to_s + "\t" + metmp3 + "\t" + sdtmp3 + "\t" + sdtmp + "\t" + metmp2 + "\t" + sdtmp2 + "\t"
datsarr.push(add)
end
delFst = deltaF(df)
for i in 1 .. datsarr.size
add = datsarr[i-1] + delFst[i-1].to_s + "\n"
dats += add
end
test += dats
filename = $save +"-Fst.txt"
File.open(filename, 'w') do |f2|
f2.puts test
end
end
end
# Methods show_license [lines 671-695, 709-722], gnu_license [lines 724-737], and splash_screen [lines 741-763] are in the public domain. GNU General Public License header [lines 696-707] copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
#-------------------------------------------------
# License Information
#-------------------------------------------------
def show_license
if RUBY_PLATFORM =~ /win32/
system('cls')
else
system("clear")
end
puts <<BASIC_LICENSE
CorrSieve 1.7-0.
Public domain updates by Michael G. Campana, 2019
Original CorrSieve 1.6-5 source code copyright (c) Michael G. Campana, 2010-2011
Code improvements by Michael G. Campana (2019) are US government works
and are therefore in the public domain. Affected lines of source code
are annotated that they are in the public domain.
Improvements include:
* Removal of the method 'each_permutation' from the Array class.
* Improvement of the 'pvalue' method.
* Conversion of the main processing section to the method 'process_data'.
* Revisions to the splash screen for updated licensing information.
* Addition of method 'splash_screen' to control revised program.
* Addition of methods 'show_license' and 'gnu_license' to detail licensing information.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Enter 'L' to see full GNU General Public License or 'R' to return to the splash screen.
BASIC_LICENSE
choice = gets.chomp.upcase
while choice != "R" && choice != "L"
puts "\Enter 'L' to see full GNU General Public License or 'R' to return to the splash screen."
choice = gets.chomp.upcase
end
case choice
when 'L'
gnu_license
when 'R'
splash_screen
end
end
#-------------------------------------------------
def gnu_license
if FileTest.exist?(File.absolute_path(__dir__) + "/LICENSE")
File.open(File.absolute_path(__dir__) + "/LICENSE") do |f1|
while line = f1.gets
puts line
end
end
else
puts "LICENSE file not found in CorrSieve executable's directory"
end
puts "\nPress Enter to return to the splash screen."
cont = gets.chomp
splash_screen
end
#-------------------------------------------------
# Options Block: Program begins here
#-------------------------------------------------
def splash_screen
if RUBY_PLATFORM =~ /win32/
system('cls')
else
system("clear")
end
print "Welcome to CorrSieve 1.7-0\n\nPublic domain updates by Michael G. Campana, 2019 (Smithsonian Conservation Biology Institute)\nOriginal CorrSieve source code copyright (c) Michael G. Campana, 2010-2011\n\nThis software is licensed under the GNU General Public License (version 3 or later)\nFor details, see the license provided with this code or at <http://www.gnu.org/licenses/>.\nThis program comes with absolutely no warranty.\n\n"
puts "Enter 'C' to continue, 'L' to see license, or 'X' to exit"
choice = gets.chomp.upcase
while choice != "C" && choice != "L" && choice != "X"
puts "Enter 'C' to continue, 'L' to see license details, or 'X' to exit"
choice = gets.chomp.upcase
end
case choice
when 'C'
process_data
when 'L'
show_license
when 'X'
exit
end
end
splash_screen