Skip to content

Commit bbbf875

Browse files
committed
clean options order
1 parent 21e7a05 commit bbbf875

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

bin/agat_sp_extract_sequences.pl

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,39 @@
1414
my $config;
1515
my $opt_plus_strand = undef;
1616
my $start_run = time();
17-
my $codonTable=1;
1817

19-
my $opt_gfffile;
20-
my $opt_fastafile;
21-
my $opt_output;
18+
2219
my $opt_AA=undef;
23-
my $opt_help = 0;
20+
my $opt_alternative_start_codon = undef;
21+
my $opt_fastafile;
22+
my $opt_cdna=undef;
23+
my $opt_cleanFinalStop=undef;
24+
my $opt_cleanInternalStop=undef;
25+
my $opt_codonTable=1;
26+
my $opt_downRegion=undef;
27+
my $opt_extremity_only=undef;
2428
my $opt_full=undef;
25-
my $opt_split=undef;
29+
my $opt_gfffile;
30+
my $opt_help = 0;
31+
my $opt_keep_attributes = undef;
32+
my $opt_keep_parent_attributes = undef;
2633
my $opt_merge=undef;
27-
my $opt_extremity_only=undef;
28-
my $opt_upstreamRegion=undef;
29-
my $opt_downRegion=undef;
30-
my $opt_cdna=undef;
3134
my $opt_mrna=undef;
3235
my $opt_OFS=undef;
33-
my $opt_type = 'cds';
34-
my $opt_keep_attributes = undef;
35-
my $opt_keep_parent_attributes = undef;
36-
my $opt_cleanFinalStop=undef;
37-
my $opt_cleanInternalStop=undef;
38-
my $opt_remove_orf_offset = undef;
39-
my $opt_quiet = undef;
36+
my $opt_output;
4037
my $opt_plus_strand_only = undef;
38+
my $opt_quiet = undef;
39+
my $opt_remove_orf_offset = undef;
4140
my $opt_revcomp=undef;
41+
my $opt_split=undef;
42+
my $opt_type = 'cds';
43+
my $opt_upstreamRegion=undef;
4244
my $opt_verbose=undef;
43-
my $opt_alternative_start_codon = undef;
4445

4546
# OPTION MANAGMENT
4647
my @copyARGV=@ARGV;
4748
if ( !GetOptions( 'alternative_start_codon|asc!' => \$opt_alternative_start_codon,
49+
'c|config=s' => \$config,
4850
'cdna!' => \$opt_cdna,
4951
'cfs|clean_final_stop!' => \$opt_cleanFinalStop,
5052
'cis|clean_internal_stop!' => \$opt_cleanInternalStop,
@@ -53,8 +55,9 @@
5355
'f|fa|fasta=s' => \$opt_fastafile,
5456
'full!' => \$opt_full,
5557
'g|gff=s' => \$opt_gfffile,
56-
'c|config=s' => \$config,
5758
'h|help!' => \$opt_help,
59+
'keep_attributes!' => \$opt_keep_attributes,
60+
'keep_parent_attributes!' => \$opt_keep_parent_attributes,
5861
'merge!' => \$opt_merge,
5962
'mrna|transcript!' => \$opt_mrna,
6063
'ofs=s' => \$opt_OFS,
@@ -65,9 +68,7 @@
6568
'remove_orf_offset|roo!' => \$opt_remove_orf_offset,
6669
'revcomp!' => \$opt_revcomp,
6770
'split!' => \$opt_split,
68-
'keep_attributes!' => \$opt_keep_attributes,
69-
'keep_parent_attributes!' => \$opt_keep_parent_attributes,
70-
'table|codon|ct=i' => \$codonTable,
71+
'table|codon|ct=i' => \$opt_codonTable,
7172
't|type=s' => \$opt_type,
7273
'up|5|five|upstream=i' => \$opt_upstreamRegion,
7374
'verbose|v!' => \$opt_verbose ) )
@@ -97,7 +98,7 @@
9798
$config = get_agat_config({config_file_in => $config});
9899

99100
# --- Check codon table
100-
$codonTable = get_proper_codon_table($codonTable);
101+
$opt_codonTable = get_proper_codon_table($opt_codonTable);
101102

102103
# activate warnings limit
103104
my %warnings;
@@ -431,7 +432,7 @@ sub extract_sequences{
431432
# create object
432433
my $seqObj = create_seqObj($sequence, $id_seq, $description, $minus, $info);
433434
# print object
434-
print_seqObj($ostream, $seqObj, $opt_AA, $codonTable, $phase);
435+
print_seqObj($ostream, $seqObj, $opt_AA, $opt_codonTable, $phase);
435436
}
436437
# --------------------------------------
437438

@@ -497,7 +498,7 @@ sub extract_sequences{
497498
}
498499

499500
#print object
500-
print_seqObj($ostream, $seqObj, $opt_AA, $codonTable, $phase);
501+
print_seqObj($ostream, $seqObj, $opt_AA, $opt_codonTable, $phase);
501502
}
502503
}
503504
# --------------------------------------
@@ -577,7 +578,7 @@ sub extract_sequences{
577578
#create object
578579
my $seqObj = create_seqObj($sequence, $id_seq, $description, $minus, $info);
579580
#print object
580-
print_seqObj($ostream, $seqObj, $opt_AA, $codonTable, $phase);
581+
print_seqObj($ostream, $seqObj, $opt_AA, $opt_codonTable, $phase);
581582
}
582583

583584
# ---- Non spreaded feature extract them one by one
@@ -626,7 +627,7 @@ sub extract_sequences{
626627
}
627628

628629
#print object
629-
print_seqObj($ostream, $seqObj, $opt_AA, $codonTable, $phase);
630+
print_seqObj($ostream, $seqObj, $opt_AA, $opt_codonTable, $phase);
630631
}
631632
}
632633
}
@@ -767,18 +768,18 @@ sub create_seqObj{
767768

768769
# Print the sequence object
769770
sub print_seqObj{
770-
my($ostream, $seqObj, $opt_AA, $codonTable, $phase) = @_;
771+
my($ostream, $seqObj, $opt_AA, $opt_codonTable, $phase) = @_;
771772

772773

773774
if($opt_AA){ #translate if asked
774775

775776
if ( length($seqObj->seq()) < 3 ){warn "Sequence to translate for ".$seqObj->id()." < 3 nucleotides! Skipped...\n"; return; }
776777

777-
my $transObj = $seqObj->translate(-CODONTABLE_ID => $codonTable);
778+
my $transObj = $seqObj->translate(-CODONTABLE_ID => $opt_codonTable);
778779

779780
# translate alternative start codon by a M
780781
my $start_codon = substr($seqObj->seq(),0,3); # get start codon
781-
my $myCodonTable = Bio::Tools::CodonTable->new( -id => $codonTable );
782+
my $myCodonTable = Bio::Tools::CodonTable->new( -id => $opt_codonTable );
782783
my $first_AA = substr($transObj->seq(),0,1);
783784
if ($phase == 0 and $opt_alternative_start_codon and $myCodonTable->is_start_codon($start_codon)){
784785
if($first_AA ne "M"){ # if the start codon was not a M while it is a valid start codon we have to replace it by a methionine

0 commit comments

Comments
 (0)