Fixed $PRIOR support and bugfix in shrinkage results handling
[PsN.git] / bin / create_extra_data_model
blob408ce125cf33b9ae5812f5b835f81edd395c4d28
1 #!/usr/bin/perl
3 use FindBin qw($Bin);
4 use lib "$Bin/../lib";
6 # Don't edit the line below, it must look exactly like this.
7 # Everything above this line will be replaced #
9 use PsN;
10 use model;
11 use strict;
13 use Getopt::Long;
14 use vars qw/ $opt_help /;
15 use vars qw/ $opt_model
16 $opt_new_model_name
17 $opt_extra_data
18 $opt_header
19 $opt_debug
20 $opt_debug_package
21 $opt_debug_subroutine /;
23 ## Configure the command line parsing
24 Getopt::Long::config("auto_abbrev");
26 ## Declare the options
27 my $res = GetOptions("help", # Display help message
28 "model:s",
29 "new_model_name:s",
30 "extra_data:s",
31 "header:s",
32 "debug:0",
33 "debug_package:s",
34 "debug_subroutine:s");
36 exit unless $res;
38 if($opt_help or not defined $opt_model) {
39 print <<'ENDHELP';
41 create_extra_data_model.pl
43 Perl script that creates and adds the necessary code for extra data
44 files (useful when the number of columns exceeds 20)
46 Usage:
48 create_extra_data_model -model=filename
49 -extra_data=extra_data_filename
50 -header='ID,WGT,APGR'
51 [-new_model_name=new_filename]
54 Example:
56 ./create_extra_data_model -mod=pheno.mod -extra=cov.dta -header='ID,WGT,APGR'
57 -new=pheno_extra.mod
59 ENDHELP
60 exit;
63 ## Check that we do have a model file
64 unless ( $opt_model ) {
65 exit "A model file must be specified\n";
68 ui -> category( 'model' );
70 debug -> level( $opt_debug );
71 debug -> package( $opt_debug_package );
72 debug -> subroutine( $opt_debug_subroutine );
74 my @header = split(',',$opt_header);
76 my $model = model -> new ( filename => $opt_model,
77 target => 'disk' );
78 my $mcopy = $model -> copy( filename => $opt_new_model_name,
79 copy_data => 0 );
80 $mcopy -> extra_data_files( [$opt_extra_data] );
81 $mcopy -> extra_data_headers( [\@header] );
83 $mcopy -> add_extra_data_code;
84 $mcopy -> write_get_subs;
85 $mcopy -> write_readers;
86 $mcopy -> _write;