| Summary | Included libraries | Package variables | Synopsis | Description | General documentation | Methods |
use SubOpt;
&odyssey ($gb, -option=>"neat!", -file=>"fancy.txt", "oops");
sub odyssey{
opt_default(option => 'none', file => 'hoge.txt');
# Set default values. This is optional.
my @args = opt_get(@_);
# Parse options.
my $gb = opt_as_gb(shift @args);
# Get the input value as a G instance
my $last = shift @args;
print $gb->{SEQ} , "\n";
print "last: $last\n";
print "option: ", opt_val("option"), "\n";
print "file: ", opt_val("file"), "\n";
# Option values are accessed via opt_val().
}
SubOpt parses the arguments given to a subroutine in a similar manner as GetOpt module. Options are specified in the form: -option=>"hoge" The above will input the value "hoge" with a key "option". i.e. option with '-' is stored with the value pointed with '=>'. supported methods: opt_default(
| opt_as_gb | No description | Code |
| opt_default | No description | Code |
| opt_get | No description | Code |
| opt_val | No description | Code |
| opt_as_gb | description | prev | next | Top |
if ($#_ >= 1){
&msg_error("Error 1 in SubOpt::opt_as_gb():\n Given value is not a valid sequence.\n");
return '';
}elsif (length $_[0] < 1){
&msg_error("Error 2 in SubOpt::opt_as_gb():\n Given value is NULL.\n");
die;
}
my $unknown = shift @_;
my $ref =\$ unknown;
my $new_gb = new G::Skyline('blessed');
if ("$unknown" =~ /\=/){
if (defined $unknown->{SEQ}){
return $unknown;
}else{
&msg_error("Error 3 in SubOpt::opt_as_gb():\n Given value is not a valid sequence.\n");
return '';
}
} elsif (ref $unknown eq 'SCALAR') {
$new_gb->{SEQ} = $$unknown;
return $new_gb;
} elsif (ref $unknown eq 'REF') {
$new_gb->{SEQ} = $$unknown;
return $new_gb;
} elsif (ref $ref eq 'SCALAR'){
$new_gb->{SEQ} = $unknown;
return $new_gb;
}else{
&msg_error("Error 4 in SubOpt::opt_as_gb():\n Given value is not a valid sequence.\n");
return '';
}}| opt_default | description | prev | next | Top |
%data = (@_);}
| opt_get | description | prev | next | Top |
my @args = @_; my @new_args = (); my $i = 0; my @bparray = (); while(defined $args[$i]){ if (substr($args[$i], 0, 1) eq '-' && substr($args[$i], 1, 1) !~ /[0-9]/){ $data{substr($args[$i],1)} = $args[$i + 1]; $i += 2; }else{ if (ref $args[$i] =~ /Bio::Seq/){ push(@new_args, G::IO::Bioperl::convert($args[$i])); }else{ push(@new_args, $args[$i]); } $i ++; } } return @new_args;}
| opt_val | description | prev | next | Top |
my $key = shift; return $data{$key};}
| AUTHOR | Top |
Kazuharu Arakawa, gaou@sfc.keio.ac.jp
| SEE ALSO | Top |