Mercurial > repos > fgiacomoni > massbank_ws_searchspectrum
annotate lib/conf.pm @ 0:023c380900ef draft default tip
Init repository with last massbank_ws_searchspectrum master version
author | fgiacomoni |
---|---|
date | Wed, 19 Apr 2017 11:31:58 -0400 |
parents | |
children |
rev | line source |
---|---|
0
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
1 package lib::conf ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
2 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
3 use strict; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
4 use warnings ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
5 use Exporter ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
6 use Carp ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
7 use Data::Dumper ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
8 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
9 use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS); |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
10 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
11 our $VERSION = "1.0" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
12 our @ISA = qw(Exporter) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
13 our @EXPORT = qw( as_conf get_value_from_conf check_path_and_file ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
14 our %EXPORT_TAGS = ( ALL => [qw( as_conf get_value_from_conf )] ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
15 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
16 =head1 NAME |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
17 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
18 conf - A module for manage pfem conf file |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
19 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
20 =head1 SYNOPSIS |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
21 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
22 use conf ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
23 my $object = conf->new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
24 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
25 =head1 DESCRIPTION |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
26 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
27 This module does manage conf file (extract all or selected fields) |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
28 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
29 =head1 METHODS |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
30 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
31 Methods are : |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
32 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
33 =head2 METHOD new |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
34 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
35 ## Description : new |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
36 ## Input : $self |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
37 ## Ouput : bless $self ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
38 ## Usage : new() ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
39 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
40 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
41 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
42 sub new { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
43 ## Variables |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
44 my $self={}; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
45 bless($self) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
46 return $self ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
47 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
48 ### END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
49 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
50 =head2 METHOD as_conf |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
51 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
52 ## Description : permet de creer l'object conf a partir d'un fichier de conf de type KEY=VALUE |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
53 ## Input : $file |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
54 ## Ouput : $oConf (a hash) |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
55 ## Usage : my ( $oConf ) = as_conf( $file ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
56 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
57 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
58 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
59 sub as_conf { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
60 ## Retrieve Values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
61 my $self = shift ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
62 my ( $file, $separator ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
63 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
64 # if (!defined $separator) { $separator = ';' } ## set separator to ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
65 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
66 if ( !defined $file ) { croak "Can't create object with an none defined file\n" ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
67 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
68 my %Conf = () ; ## Hash devant contenir l'ensemble des parametres locaux |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
69 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
70 if (-e $file) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
71 open (CFG, "<$file") or die "Can't open $file\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
72 while (<CFG>) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
73 chomp $_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
74 if ( $_ =~ /^#(.*)/) { next ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
75 elsif ($_ =~/^(\w+?)=(.*)/) { ## ALPHANUMERIC OR UNDERSCORE ONLY FOR THE KEY AND ANYTHING ELSE FOR VALUE |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
76 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
77 my ($key, $value) = ($1, $2) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
78 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
79 if (defined $separator) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
80 if ( $value=~/$separator/ ) { ## is a list to split |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
81 my @tmp = split(/$separator/ , $value) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
82 $Conf{$key} = \@tmp ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
83 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
84 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
85 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
86 $Conf{$key} = $value ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
87 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
88 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
89 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
90 close(CFG) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
91 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
92 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
93 croak "Can't create object with an none existing file\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
94 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
95 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
96 return ( \%Conf ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
97 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
98 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
99 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
100 =head2 METHOD as_conf_list |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
101 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
102 ## Description : permet de charger une liste txt en array |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
103 ## Input : $file |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
104 ## Output : elements |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
105 ## Usage : my ( elements ) = as_conf_list( $conf_file ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
106 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
107 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
108 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
109 sub as_conf_list { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
110 ## Retrieve Values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
111 my $self = shift ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
112 my ( $file ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
113 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
114 my @elements = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
115 if ( !defined $file ) { croak "Can't create object with an none defined file\n" ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
116 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
117 if (-e $file) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
118 open (CFG, "<$file") or die "Can't open $file\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
119 while (<CFG>) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
120 chomp $_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
121 if ( $_ =~ /^#(.*)/) { next ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
122 elsif ($_ =~/^(.*)/) { if (defined $1) { push (@elements, $1) ; } } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
123 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
124 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
125 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
126 croak "Can't create object with an none existing file\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
127 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
128 return(\@elements) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
129 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
130 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
131 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
132 =head2 METHOD get_value_from_conf |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
133 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
134 ## Description : permet de retourner une valeur du hash de conf a partir d'une key |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
135 ## Input : $oConf, $Key |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
136 ## Ouput : $Value |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
137 ## Usage : my ( $Value ) = get_value_from_conf( $oConf, $Key ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
138 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
139 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
140 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
141 sub get_value_from_conf { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
142 ## Retrieve Values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
143 my $self = shift ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
144 my ( $oConf, $Key ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
145 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
146 my $Value = undef ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
147 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
148 if ( defined $oConf ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
149 if ( defined $oConf->{$Key} ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
150 $Value = $oConf->{$Key} ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
151 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
152 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
153 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
154 croak "Can't manage value with undefined object\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
155 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
156 return($Value) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
157 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
158 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
159 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
160 =head2 METHOD get_value_from_conf |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
161 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
162 ## Description : permet de retourner une valeur du hash de conf a partir d'une key |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
163 ## Input : $oConf, $Key |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
164 ## Ouput : $Value |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
165 ## Usage : my ( $Value ) = get_value_from_conf( $oConf, $Key ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
166 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
167 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
168 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
169 sub split_value_from_conf { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
170 ## Retrieve Values |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
171 my $self = shift ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
172 my ( $oConf, $Key, $sep ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
173 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
174 my $value = undef ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
175 my @values = () ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
176 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
177 if ( defined $oConf ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
178 if ( defined $oConf->{$Key} ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
179 $value = $oConf->{$Key} ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
180 @values = split ( /$sep/, $value) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
181 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
182 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
183 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
184 croak "Can't manage value with undefined object\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
185 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
186 return(\@values) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
187 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
188 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
189 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
190 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
191 =head2 METHOD check_path_and_file |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
192 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
193 ## Description : permet de verifier les path et la presence des exe decrits dans le file conf. Bloque le script en cas de probleme |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
194 ## Input : $oConfs |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
195 ## Ouput : NA |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
196 ## Usage : &get_value_from_conf( $oConf ) ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
197 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
198 =cut |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
199 ## START of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
200 sub check_path_and_file { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
201 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
202 my $self = shift ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
203 my ( $oConfs ) = @_ ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
204 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
205 foreach my $conf ( keys %{ $oConfs } ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
206 if ( $conf =~ /^FILE/ ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
207 if ( -e $oConfs->{$conf} ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
208 if ( -s $oConfs->{$conf} ) { next ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
209 else { carp "[Warning] : The size of file $oConfs->{$conf} is null\n" ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
210 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
211 else { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
212 carp "[Warning] : The file $oConfs->{$conf} doesn't exist\n" ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
213 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
214 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
215 elsif ( $conf =~ /^PATH/ ) { |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
216 if ( -d $oConfs->{$conf} ) { next ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
217 else { carp "[Warning] : The dir $oConfs->{$conf} doesn't exist\n" ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
218 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
219 else { next ; } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
220 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
221 return ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
222 } |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
223 ## END of SUB |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
224 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
225 1 ; |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
226 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
227 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
228 __END__ |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
229 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
230 =head1 SUPPORT |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
231 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
232 You can find documentation for this module with the perldoc command. |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
233 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
234 perldoc conf.pm |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
235 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
236 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
237 =head1 Exports |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
238 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
239 =over 4 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
240 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
241 =item :ALL is as_conf get_value_from_conf |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
242 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
243 =back |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
244 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
245 =head1 AUTHOR |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
246 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
247 Franck Giacomoni E<lt>franck.giacomoni@clermont.inra.frE<gt> |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
248 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
249 =head1 LICENSE |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
250 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
251 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
252 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
253 =head1 VERSION |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
254 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
255 version 1 : 10 / 02 / 2013 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
256 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
257 version 2 : ?? |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
258 |
023c380900ef
Init repository with last massbank_ws_searchspectrum master version
fgiacomoni
parents:
diff
changeset
|
259 =cut |