moved nonpb.pm
[PsN.git] / test / lib / cdd_test.pm
blob9b802ac4d9f2a9aa7d5666a0014d67f4375859b3
1 package cdd_test;
3 use Data::Dumper;
4 use strict;
5 use Test::More;
7 my @tests = ( 'pheno' );
9 sub test {
10 my $self = shift;
11 my %parms = @_;
12 my $verbose = $parms{'verbose'};
13 my $debug = $parms{'debug'};
14 my $debug_package = $parms{'debug_package'};
15 my $debug_subroutine = $parms{'debug_subroutine'};
16 my $directory = $parms{'directory'};
17 my $threads = $parms{'threads'};
19 foreach my $test( @tests ){
20 cdd_test -> $test( verbose => $verbose,
21 debug => $debug,
22 debug_package => $debug_package,
23 debug_subroutine => $debug_subroutine,
24 directory => $directory,
25 threads => $threads );
29 sub pheno {
30 my $self = shift;
31 my %parms = @_;
32 my $verbose = $parms{'verbose'};
33 my $debug = $parms{'debug'};
34 my $debug_package = $parms{'debug_package'};
35 my $debug_subroutine = $parms{'debug_subroutine'};
36 my $directory = $parms{'directory'};
37 my $threads = $parms{'threads'};
38 my $bin = "$directory/../bin/cdd.pl -directory=$directory/cdd_dir2 ";
39 my $options = "-mod=$directory/files/pheno.mod -case_column=ID -bins=10 -results_file=cdd_results.csv";
40 $options = $options." -seed=testing";
41 $options = $options." -debug=$debug" if defined $debug;
42 $options = $options." -debug_package=$debug_package" if defined $debug_package;
43 $options = $options." -debug_subroutine=$debug_subroutine" if defined $debug_subroutine;
44 $options = $options." -threads=$threads" if defined $threads;
45 system( $bin." ".$options );
46 ok( -e "$directory/cdd_results.csv", 'cdd results file exist' );
47 open( TESTRES, "$directory/cdd_results.csv" );
48 open( ORIGRES, "$directory/files/cdd_results.csv.test" );
49 my @test_array = <TESTRES>;
50 my @orig_array = <ORIGRES>;
51 close( TESTRES );
52 close( ORIGRES );
53 is_deeply( \@test_array,
54 \@orig_array,
55 'cdd results file has the correct content' );
56 # unlink( "$directory/cdd_results.csv" );
57 # system( 'rm -rf cdd_dir*' );
60 sub mox {
61 my $self = shift;
62 my %parms = @_;
63 my $verbose = $parms{'verbose'};
64 my $debug = $parms{'debug'};
65 my $debug_package = $parms{'debug_package'};
66 my $debug_subroutine = $parms{'debug_subroutine'};
67 my $directory = $parms{'directory'};
68 my $threads = $parms{'threads'};
69 my $bin = "$directory/../bin/cdd.pl";
70 my $options = "-mod=$directory/files/mox_basic.mod -case_column=ID -bins=5";
71 $options = $options." -seed=testing";
72 $options = $options." -debug=$debug" if defined $debug;
73 $options = $options." -debug_package=$debug_package" if defined $debug_package;
74 $options = $options." -debug_subroutine=$debug_subroutine" if defined $debug_subroutine;
75 $options = $options." -threads=$threads" if defined $threads;
76 system( $bin." ".$options );
77 ok( -e "$directory/cdd_results.csv", 'mox cdd results file exist' );
78 open( TESTRES, "$directory/cdd_results.csv" );
79 open( ORIGRES, "$directory/files/cdd_results.csv.test.mox" );
80 my @test_array = <TESTRES>;
81 my @orig_array = <ORIGRES>;
82 close( TESTRES );
83 close( ORIGRES );
84 is_deeply( \@test_array,
85 \@orig_array,
86 'mox cdd results file has the correct content' );
87 # unlink( "$directory/cdd_results.csv" );
88 system( 'rm -rf cdd_dir*' );
91 sub dof {
92 my $self = shift;
93 my %parms = @_;
94 my $verbose = $parms{'verbose'};
95 my $debug = $parms{'debug'};
96 my $debug_package = $parms{'debug_package'};
97 my $debug_subroutine = $parms{'debug_subroutine'};
98 my $directory = $parms{'directory'};
99 my $threads = $parms{'threads'};
100 my $bin = "$directory/../bin/cdd.pl";
101 my $options = "-mod=$directory/files/dof.run51.FO.mod ".
102 "-case_column=ID -bins=5";
103 $options = $options." -seed=testing";
104 $options = $options." -debug=$debug" if defined $debug;
105 $options = $options." -debug_package=$debug_package" if defined $debug_package;
106 $options = $options." -debug_subroutine=$debug_subroutine" if defined $debug_subroutine;
107 $options = $options." -threads=$threads" if defined $threads;
108 system( $bin." ".$options );
109 ok( -e "$directory/cdd_results.csv", 'dof cdd results file exist' );
110 open( TESTRES, "$directory/cdd_results.csv" );
111 open( ORIGRES, "$directory/files/cdd_results.csv.test.dof" );
112 my @test_array = <TESTRES>;
113 my @orig_array = <ORIGRES>;
114 close( TESTRES );
115 close( ORIGRES );
116 is_deeply( \@test_array,
117 \@orig_array,
118 'dof cdd results file has the correct content' );
119 # unlink( "$directory/cdd_results.csv" );
120 system( 'rm -rf cdd_dir*' );
123 sub war {
124 my $self = shift;
125 my %parms = @_;
126 my $verbose = $parms{'verbose'};
127 my $debug = $parms{'debug'};
128 my $debug_package = $parms{'debug_package'};
129 my $debug_subroutine = $parms{'debug_subroutine'};
130 my $directory = $parms{'directory'};
131 my $threads = $parms{'threads'};
132 my $bin = "$directory/../bin/cdd.pl";
133 my $options = "-mod=$directory/files/war.mod ".
134 "-bins=5 -case_column=ID -nm_version=6";
135 $options = $options." -seed=testing";
136 $options = $options." -debug=$debug" if defined $debug;
137 $options = $options." -debug_package=$debug_package" if defined $debug_package;
138 $options = $options." -debug_subroutine=$debug_subroutine" if defined $debug_subroutine;
139 $options = $options." -threads=$threads" if defined $threads;
140 system( $bin." ".$options );
141 ok( -e "$directory/cdd_results.csv", 'war cdd results file exist' );
142 open( TESTRES, "$directory/cdd_results.csv" );
143 open( ORIGRES, "$directory/files/cdd_results.csv.test.war" );
144 my @test_array = <TESTRES>;
145 my @orig_array = <ORIGRES>;
146 close( TESTRES );
147 close( ORIGRES );
148 is_deeply( \@test_array,
149 \@orig_array,
150 'war cdd results file has the correct content' );
151 # unlink( "$directory/cdd_results.csv" );
152 system( 'rm -rf cdd_dir*' );