Skip to content

Commit

Permalink
polish parameter call
Browse files Browse the repository at this point in the history
  • Loading branch information
Juke34 committed May 20, 2020
1 parent f212f5f commit 804d9e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
13 changes: 8 additions & 5 deletions annotation/tools/fasta/gaas_fasta_splitter.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
my $start_run = time();

my $opt_fastafile;
my $opt_output;
my $opt_output="split_result";
my $opt_help = undef;
my $opt_nb_chunk;
my $opt_leftover="attach";
Expand Down Expand Up @@ -48,10 +48,10 @@
}

# ---- check options ----
if (! ( $opt_fastafile or $opt_output ) ) {
if (! ( $opt_fastafile and ($opt_nb_chunk or $opt_nb_seq_by_chunk)) ) {
pod2usage( {
-message => "\nAt least 2 parameters are mandatory:\nInput reference fasta file (-f)".
"Output folder (-o)\n\n".
"\nnumber of chuncks (--nb_chunks) or/and number of sequences by chunk (--nb_seq_by_chunk)\n\n".
"Look at the help documentation to know more.\n",
-verbose => 0,
-exitval => 2 } );
Expand Down Expand Up @@ -92,6 +92,10 @@
print "=> <leftover> option is $opt_leftover\n";
}
}

if(! -f $opt_fastafile){
print "$opt_fastafile is not a file\n."; exit;
}
# ----- output -------

my ($inputname,$path,$ext) = fileparse($opt_fastafile,qr/\.[^.]*/);
Expand Down Expand Up @@ -460,8 +464,7 @@ =head1 OPTIONS
=item B<-o> or B<--output>
Output fasta file. If no output file is specified, the output will be
written to STDOUT.
Output folder. Default split_result
=item B<-h> or B<--help>
Expand Down
13 changes: 8 additions & 5 deletions bin/gaas_fasta_splitter.pl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
my $start_run = time();

my $opt_fastafile;
my $opt_output;
my $opt_output="split_result";
my $opt_help = undef;
my $opt_nb_chunk;
my $opt_leftover="attach";
Expand Down Expand Up @@ -48,10 +48,10 @@
}

# ---- check options ----
if (! ( $opt_fastafile or $opt_output ) ) {
if (! ( $opt_fastafile and ($opt_nb_chunk or $opt_nb_seq_by_chunk)) ) {
pod2usage( {
-message => "\nAt least 2 parameters are mandatory:\nInput reference fasta file (-f)".
"Output folder (-o)\n\n".
"\nnumber of chuncks (--nb_chunks) or/and number of sequences by chunk (--nb_seq_by_chunk)\n\n".
"Look at the help documentation to know more.\n",
-verbose => 0,
-exitval => 2 } );
Expand Down Expand Up @@ -92,6 +92,10 @@
print "=> <leftover> option is $opt_leftover\n";
}
}

if(! -f $opt_fastafile){
print "$opt_fastafile is not a file\n."; exit;
}
# ----- output -------

my ($inputname,$path,$ext) = fileparse($opt_fastafile,qr/\.[^.]*/);
Expand Down Expand Up @@ -460,8 +464,7 @@ =head1 OPTIONS
=item B<-o> or B<--output>
Output fasta file. If no output file is specified, the output will be
written to STDOUT.
Output folder. Default split_result
=item B<-h> or B<--help>
Expand Down

0 comments on commit 804d9e8

Please sign in to comment.