script/makeMicroarrayDataset.pl untested

filter: Statementstmt 0.0% 0 / 37 Branchbran 0.0% 0 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 56 CC 1 SCAR 6.9
CC
1
Cov
0%
Usage
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 #!/usr/local/bin/perl
2  
3 # License information (the MIT license)
4  
5 # Copyright (c) 2003 Christian Rees, Janos Demeter, John Matese, Gavin
6 # Sherlock; Stanford University
7  
8 # Permission is hereby granted, free of charge, to any person
9 # obtaining a copy of this software and associated documentation files
10 # (the "Software"), to deal in the Software without restriction,
11 # including without limitation the rights to use, copy, modify, merge,
12 # publish, distribute, sublicense, and/or sell copies of the Software,
13 # and to permit persons to whom the Software is furnished to do so,
14 # subject to the following conditions:
15  
16 # The above copyright notice and this permission notice shall be
17 # included in all copies or substantial portions of the Software.
18  
19 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 # BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 # ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 # SOFTWARE.
27  
28  
29 # Description: makeMicroarrayDataset.pl is an example client script of
30 # Microarray::CdtDataset. It takes a input a microarray project
31 # datafile (currently .cdt format, although in the future other known
32 # formats(e.g. MAGE-ML/XML) might be included.
33  
34 use strict;
35 use Getopt::Long;
36  
37  
38 use Microarray::Config;
39 use Microarray::CdtDataset;
40 use Microarray::Utilities::Filesystem qw(DirectoryIsValid EnsureTrailingSlash);
41  
42 #########################################################################
43 #
44 # MAIN
45 #
46 #########################################################################
47  
48 # First we simply deal with getting and checking command line arguments
49  
50 if (!@ARGV) { &Usage }
51  
52 # the following are the default options for making a dataset that will
53 # be utilized by getopts and then passed to the CdtDataset constructor
54  
55 my ($filepath, $name, $verbose, $rootpath, $help); # undef by default
56  
57 # defaults for this client
58 my $contrast = 4;
59 my $colorscheme = 'yellow/blue';
60 my $corrcutoff = 0.5;
61  
62 my %args = (contrast => \$contrast,
63 colorscheme => \$colorscheme,
64 corrcutoff => \$corrcutoff,
65 name => \$name,
66 rootpath => \$rootpath,
67 verbose => \$verbose,
68 file => \$filepath,
69 help => \$help);
70  
71  
72 unless(&GetOptions( \%args, "name=s", "file=s", "rootpath=s", "contrast=f", "colorscheme=s", "corrcutoff=f", "verbose", "help")){
73 &Usage;
74 }
75  
76 if ($verbose) {
77 print "Creating new dataset, $name, from file $filepath...\n";
78 }
79  
80 &Usage if($help);
81  
82 die "Requested <rootpath> path, $rootpath doesn't exist." if (!&DirectoryIsValid($rootpath));
83  
84 # if we get here, we have everything we need to try and create a dataset
85  
86 # first create a Microarray::Config object
87  
88 # we just pass it a dummy root url, as we know it's not needed during
89 # dataset construction - not a really good solution, but this is what
90 # I'm reduced to when hacking other people's code...
91  
92 my $config = Microarray::Config->new(rootpath => $rootpath,
93 rooturl => 'blah');
94  
95 # now create a Microarray::CdtDataset, which will take care of all the
96 # details to actuallt create the files that underlie a dataset
97  
98 my $ds = Microarray::CdtDataset->new(name => $name,
99 contrast => $contrast,
100 colorscheme => $colorscheme,
101 corrcutoff => $corrcutoff,
102 datapath => $rootpath.'/data/explorer/',
103 imagepath => $rootpath.'/html/explorer/',
104 initialize => $filepath,
105 verbose => $verbose,
106 config => $config);
107  
108 if ($args{verbose}) {
109 print "Successfully created new dataset object ".$ds->name."\n";
110 print "Data are created in ".$ds->datapath."\n";
111 print "Images are created in ".$ds->imagepath."\n";
112 }
113  
114 exit;
115  
116 #########################################################################
117 sub Usage {
118 #########################################################################
119  
120 print STDOUT <<EOF;
121  
122 Usage:
123  
124 $0 -file <file/name> -name <intended/dataset/name> [-dataout <repository_directory> -imageout <image directory> -contrast <float> -colorscheme <rg|yb> -corrcutoff <float> -verbose]
125  
126 -----------------------------------------------------------------------------
127  
128 -file = required input file (currently only '.cdt' files supported)
129  
130 -name = required dataset name to be created
131 (may be delimited by slashes(/) to imply hierarchy)
132  
133 -rootpath = required root directory, under which must exist html
134 and data directories
135  
136 -contrast = optional contrast value for the generated images
137 (defaults to 4, As the data are expected to be in
138 log base 2, this corresponds to a 16-fold change as
139 the maximum color in any image)
140  
141 -colorscheme = optional color scheme used for generating the images
142 (rg = red/green, yb = yellow/blue ; defaults to yellow/blue)
143  
144 -corrcutoff = optional value for correlation cutoff during dataset creation
145 (defaults to 0.5 if not specified; allowed range: 0.2 - 1.0)
146  
147 -verbose = show feedback messages during run
148  
149 EOF
150  
151 exit;
152  
153 }
154  
155