• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NBISweden / AGAT / 19969880948

05 Dec 2025 04:53PM UTC coverage: 77.132% (-4.1%) from 81.2%
19969880948

Pull #549

github

Juke34
add IPC::ShareLite and remove IPC::Shareable and IPC::Open2
Pull Request #549: Parallel version of AGAT

1332 of 1519 new or added lines in 74 files covered. (87.69%)

647 existing lines in 9 files now uncovered.

12230 of 15856 relevant lines covered (77.13%)

2542.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.27
/bin/agat_sp_complement_annotations.pl
1
#!/usr/bin/env perl
2

3
use strict;
6✔
4
use warnings;
6✔
5
use Carp;
6✔
6
use Getopt::Long;
6✔
7
use Pod::Usage;
6✔
8
use List::MoreUtils qw(uniq);
6✔
9
use AGAT::AGAT;
6✔
10

11
my $header = get_agat_header();
6✔
12
my $config;
6✔
13
my $cpu;
14
my $start_run = time();
6✔
15
my $opt_output = undef;
6✔
16
my @opt_files;
6✔
17
my $ref = undef;
6✔
18
my $size_min = 0;
6✔
19
my $opt_help= undef;
6✔
20

21
# OPTION MANAGMENT
22
my @copyARGV=@ARGV;
6✔
23
if ( !GetOptions(
6✔
24
    'c|config=s'               => \$config,
25
    'thread|threads|cpu|cpus|core|cores|job|jobs=i' => \$cpu,
26
    "h|help"                   => \$opt_help,
27
    "ref|r|i=s"                => \$ref,
28
    "add|a=s"                  => \@opt_files,
29
    "size_min|s=i"             => \$size_min,
30
    "output|outfile|out|o=s"   => \$opt_output))
31

32
{
33
    pod2usage( { -message => 'Failed to parse command line',
×
34
                 -verbose => 1,
35
                 -exitval => 1 } );
36
}
37

38
# Print Help and exit
39
if ($opt_help) {
6✔
40
    pod2usage( { -verbose => 99,
×
41
                 -exitval => 0,
42
                 -message => "$header\n" } );
43
}
44

45
if (! $ref or ! @opt_files ){
6✔
46
    pod2usage( {
×
47
           -message => "$header\nAt least 2 files are mandatory:\n --ref file1 --add file2\n\n",
48
           -verbose => 0,
49
           -exitval => 2 } );
50
}
51

52
# --- Manage config ---
53
initialize_agat({ config_file_in => $config, input => $ref });
6✔
54
$CONFIG->{cpu} = $cpu if defined($cpu);
6✔
55

56
######################
57
# Manage output file #
58
my $gffout = prepare_gffout( $opt_output );
6✔
59

60
                #####################
61
                #     MAIN          #
62
                #####################
63

64
######################
65
### Parse GFF input #
66

67
my ($hash_omniscient) = slurp_gff3_file_JD({ input => $ref });
6✔
68

69
info_omniscient($hash_omniscient);
4✔
70

71
#Add the features of the other file in the first omniscient. It takes care of name to not have duplicates
72
foreach my $next_file (@opt_files){
4✔
73
  my ($hash_omniscient2) = slurp_gff3_file_JD({ input => $next_file });
4✔
UNCOV
74
  print ("$next_file GFF3 file parsed\n");
×
UNCOV
75
  info_omniscient($hash_omniscient2);
×
76

77
  # Quick stat hash before complement
UNCOV
78
  my %quick_stat1;
×
UNCOV
79
  foreach my $level ( ('level1', 'level2') ){
×
UNCOV
80
    foreach  my $tag (keys %{$hash_omniscient->{$level}}) {
×
UNCOV
81
      my $nb_tag = keys %{$hash_omniscient->{$level}{$tag}};
×
UNCOV
82
      $quick_stat1{$level}{$tag} = $nb_tag;
×
83
    }
84
  }
85
  
86
  ####### COMPLEMENT #######
NEW
87
  complement_omniscients($hash_omniscient, $hash_omniscient2, $size_min); # deal with identical ID by renaming them
×
UNCOV
88
  print ("\nComplement done !\n");
×
89

90

91
 #RESUME COMPLEMENT
UNCOV
92
  my $complemented=undef;
×
93
  # Quick stat hash after complement
UNCOV
94
  my %quick_stat2;
×
UNCOV
95
  foreach my $level ( ('level1', 'level2') ){
×
UNCOV
96
    foreach  my $tag (keys %{$hash_omniscient->{$level}}) {
×
UNCOV
97
      my $nb_tag = keys %{$hash_omniscient->{$level}{$tag}};
×
UNCOV
98
      $quick_stat2{$level}{$tag} = $nb_tag;
×
99
    }
100
  }
101

102
  #About tag from hash1 added which exist in hash2
UNCOV
103
  foreach my $level ( ('level1', 'level2') ){
×
UNCOV
104
    foreach my $tag (keys %{$quick_stat1{$level}}){
×
UNCOV
105
      if ($quick_stat1{$level}{$tag} != $quick_stat2{$level}{$tag} ){
×
UNCOV
106
        print "We added ".($quick_stat2{$level}{$tag}-$quick_stat1{$level}{$tag})." $tag(s)\n";
×
UNCOV
107
        $complemented=1;
×
108
      }
109
    }
110
  }
111
  #About tag from hash2 added which dont exist in hash1
UNCOV
112
  foreach my $level ( ('level1', 'level2') ){
×
UNCOV
113
    foreach my $tag (keys %{$quick_stat2{$level}}){
×
UNCOV
114
      if (! exists $quick_stat1{$level}{$tag} ){
×
UNCOV
115
        print "We added ".$quick_stat2{$level}{$tag}." $tag(s)\n";
×
UNCOV
116
        $complemented=1;
×
117
      }
118
    }
119
  }
120
  #If nothing added
UNCOV
121
  if(! $complemented){
×
UNCOV
122
    print "\nNothing has been added\n";
×
123
  }
124
  else{
UNCOV
125
    print "\nNow the data contains:\n";
×
UNCOV
126
    info_omniscient($hash_omniscient);
×
127
  }
128
}
129

130
########
131
# Print results
UNCOV
132
print_omniscient( {omniscient => $hash_omniscient, output => $gffout} );
×
133
#END
UNCOV
134
print "usage: $0 @copyARGV\n";
×
UNCOV
135
my $end_run = time();
×
UNCOV
136
my $run_time = $end_run - $start_run;
×
UNCOV
137
print "Job done in $run_time seconds\n";
×
138
__END__
139

140
=head1 NAME
141

142
agat_sp_complement_annotations.pl
143

144
=head1 DESCRIPTION
145

146
The script allows to complement a reference annotation with other annotations.
147
A l1 feature from the addfile.gff that does not overlap a l1 feature from the reference annotation will be added.
148
A l1 feature from the addfile.gff without a CDS that overlaps a l1 feature with a CDS from the reference annotation will be added.
149
A l1 feature from the addfile.gff with a CDS that overlaps a l1 feature without a CDS from the reference annotation will be added.
150
A l1 feature from the addfile.gff with a CDS that overlaps a l1 feature with a CDS from the reference annotation will be added only if the CDSs don't overlap.
151
A l1 feature from the addfile.gff without a CDS that overlaps a l1 feature without a CDS from the reference annotation will be added only if none of the l3 features overlap.
152
/!\ It is sufficiant that only one isoform is overlapping to prevent the whole gene (l1 feature) from the addfile.gff to be added in the output.
153

154
=head1 SYNOPSIS
155

156
    agat_sp_complement_annotations.pl --ref annotation_ref.gff --add addfile1.gff --add addfile2.gff --out outFile
157
    agat_sp_complement_annotations.pl --help
158

159
=head1 OPTIONS
160

161
=over 8
162

163
=item B<--ref>,  B<-r> or B<-i>
164

165
Input GTF/GFF file used as reference.
166

167
=item B<--add> or B<-a>
168

169
Annotation(s) file you would like to use to complement the reference annotation. You can specify as much file you want like so: -a addfile1 -a addfile2 -a addfile3
170
/!\ The order you provide these files matter. Once the reference file has been complemented by file1, this new annotation becomes the new reference that will be complemented by file2 etc.
171
/!\ The result with -a addfile1 -a addfile2 will differ to the result from -a addfile2 -a addfile1. So, be aware of what you want if you use several addfiles.
172

173
=item  B<--size_min> or B<-s>
174

175
Option to keep the non-overlping gene only if the CDS size (in nucleotide) is over the minimum size defined. Default = 0 that means all of them are kept.
176

177
=item  B<--out>, B<--output>, B<--outfile> or B<-o>
178

179
Output gff3 containing the reference annotation with all the non-overlapping newly added genes from addfiles.gff.
180

181
=item B<-thread>, B<threads>, B<cpu>, B<cpus>, B<core>, B<cores>, B<job> or B<jobs>
182

183
Integer - Number of parallel processes to use for file input parsing (via forking).
184

185
=item B<-c> or B<--config>
186

187
String - Input agat config file. By default AGAT takes as input agat_config.yaml file from the working directory if any, 
188
otherwise it takes the orignal agat_config.yaml shipped with AGAT. To get the agat_config.yaml locally type: "agat config --expose".
189
The --config option gives you the possibility to use your own AGAT config file (located elsewhere or named differently).
190

191
=item B<--help> or B<-h>
192

193
Display this helpful text.
194

195
=back
196

197
=head1 FEEDBACK
198

199
=head2 Did you find a bug?
200

201
Do not hesitate to report bugs to help us keep track of the bugs and their
202
resolution. Please use the GitHub issue tracking system available at this
203
address:
204

205
            https://github.com/NBISweden/AGAT/issues
206

207
 Ensure that the bug was not already reported by searching under Issues.
208
 If you're unable to find an (open) issue addressing the problem, open a new one.
209
 Try as much as possible to include in the issue when relevant:
210
 - a clear description,
211
 - as much relevant information as possible,
212
 - the command used,
213
 - a data sample,
214
 - an explanation of the expected behaviour that is not occurring.
215

216
=head2 Do you want to contribute?
217

218
You are very welcome, visit this address for the Contributing guidelines:
219
https://github.com/NBISweden/AGAT/blob/master/CONTRIBUTING.md
220

221
=cut
222

223
AUTHOR - Jacques Dainat
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc