This file is indexed.

/usr/bin/bp_unflatten_seq is in bioperl 1.6.923-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#!/usr/bin/perl 

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell
use strict;
use warnings;
# Author Chris Mungall <cjm-at-bioperl.org>

=head1 NAME

bp_unflatten_seq - unflatten a genbank or genbank-style feature file into
a nested SeqFeature hierarchy

=head1 SYNOPSIS

  bp_unflatten_seq.PLS -e 3 -gff ~/cvs/bioperl-live/t/data/AE003644_Adh-genomic.gb

  bp_unflatten_seq.PLS --detail ~/cvs/bioperl-live/t/data/AE003644_Adh-genomic.gb

  bp_unflatten_seq.PLS -i foo.embl --from embl --to chadoxml -o out.chado.xml

  bp_unflatten_seq.PLS --notypemap --detail --to asciitree -ethresh 2 AE003644_Adh-genomic.gb

=head1 DESCRIPTION 

This script will B<unflatten> a genbank or genbank-style file of
SeqFeatures into a nested hierarchy.

See L<Bio::SeqFeature::Tools::Unflattener>

In a GenBank/EMBL representation, features are 'flat' - for example,
there is no link between an mRNA and a CDS, other than implicit links
(eg via tags or via splice site coordinates) which may be hard to code
for.

This is most easily illustrated with the default output format,
B<asciitree>

An unflattened genbank feature set may look like this (AB077698)

  Seq: AB077698
    databank_entry                                   1..2701[+]
    gene                                             
      mRNA                                           
        CDS hCHCR-G                                  80..1144[+]
        exon                                         80..1144[+]
      five_prime_UTR                                 1..79[+]
      located_sequence_feature                       137..196[+]
      located_sequence_feature                       239..292[+]
      located_sequence_feature                       617..676[+]
      located_sequence_feature                       725..778[+]
      three_prime_UTR                                1145..2659[+]
      polyA_site                                     1606..1606[+]
      polyA_site                                     2660..2660[+]

Or like this (portion of AE003734)


  gene                                             
    mRNA CG3320-RA                                 
      CDS CG3320-PA                                53126..54971[-]
      exon                                         52204..53323[-]
      exon                                         53404..53631[-]
      exon                                         53688..53735[-]
      exon                                         53798..53918[-]
      exon                                         54949..55287[-]
    mRNA CG3320-RB                                 
      CDS CG3320-PB                                53383..54971[-]
      exon                                         52204..53631[-]
      exon                                         53688..53735[-]
      exon                                         53798..53918[-]
      exon                                         54949..55287[-]

The unflattening will also 'normalize' the containment hierarchy (in
the sense of standardising it - e.g. making sure there is always a
transcript record, even if genbank just specifies CDS and gene)

By default, the GenBank types will be mapped to SO types

See L<Bio::SeqFeature::Tools::TypeMapper>

=head1 COMMAND LINE ARGUMENTS

=over

=item -i|input FILE

input file (can also be specified as last argument)

=item -from FORMAT

input format (defaults to genbank)

probably doesnt make so much sense to use this for non-flat formats;
ie other than embl/genbank

=item -to FORMAT

output format (defaults to asciitree)

should really be a format that is nested SeqFeature aware; I think
this is only asciitree, chadoxml and gff3

=item -gff

with export to GFF3 format (pre-3 GFFs make no sense with unflattened
sequences, as they have no set way of representing feature graphs)

=item -o|output FILE

outfile defaults to STDOUT

=item -detail

show extra detail on features (asciitree mode only)

=item -e|ethresh INT

sets the error threshold on unflattening

by default this script will throw a wobbly if it encounters weird
stuff in the genbank file - raise the error threshold to signal these
to be ignored (and reported on STDERR)

=item -nomagic

suppress use_magic in unflattening (see
L<Bio::SeqFeature::Tools::Unflattener>

=item -notypemap

suppress type mapping (see
L<Bio::SeqFeature::Tools::TypeMapper>


=back

=head1 TODO

L<Bio::SeqFeature::Tools::Unflattener> allows fine-grained control
over the unflattening process - need to add more options to allow this
control at the command line


=head1 FEEDBACK

=head2 Mailing Lists

User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list.  Your participation is much appreciated.

  bioperl-l@bioperl.org                  - General discussion
  http://bioperl.org/wiki/Mailing_lists  - About the mailing lists

=head2 Reporting Bugs

Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
email or the web:

  https://redmine.open-bio.org/projects/bioperl/

=head1 AUTHOR

 Chris Mungall E<lt>cjm-at-bioperl.orgE<gt>

=cut

use Bio::SeqIO;
use Bio::SeqFeature::Tools::Unflattener;
use Bio::SeqFeature::Tools::TypeMapper;
use Bio::SeqFeature::Tools::IDHandler;
use Bio::Tools::GFF;

use Getopt::Long;

my ($input,$from,$to,$output,$verbosity,$ethresh,$nomagic,$group_tag,$detail,
    $notypemap);
$from = 'genbank';
$to = 'asciitree';
$ethresh = 3;
my $gff;
my @remove_types = ();

GetOptions(
	   'i|input:s' => \$input,
	   'from:s'  => \$from,
	   'to:s'  => \$to,
	   'o|output:s'=> \$output,
	   "verbosity|v=s"=>\$verbosity,
	   "ethresh|e=s"=>\$ethresh,
	   "remove_type=s@"=>\@remove_types,
	   "nomagic"=>\$nomagic,
	   "notypemap"=>\$notypemap,
	   "group_tag"=>\$group_tag,
	   "detail"=>\$detail,
           "gff"=>\$gff,
	   "h|help"=>sub {
	       system("perldoc $0");
	       exit 0;
	   },
	  );
                       
                       
if ($to =~ /^gff/i) {
    $gff = 1;
}

$input = $input || shift if @ARGV;

my $in = new Bio::SeqIO(-file => $input,
			-format => $from);
my $out;
my @out_opt = $output ? (-file => ">$output") : ();
unless ($gff) {
    $out = new Bio::SeqIO(-format=>$to, @out_opt);
    $out->show_detail($detail) if $out->can("show_detail") && $detail;
}

my $unflattener = Bio::SeqFeature::Tools::Unflattener->new;
$unflattener->verbose($verbosity);
$unflattener->error_threshold($ethresh);
my $tm = Bio::SeqFeature::Tools::TypeMapper->new;
my $idhandler = Bio::SeqFeature::Tools::IDHandler->new;

while( my $seq = $in->next_seq ) {    
    $unflattener->remove_types(-seq=>$seq,
                               -types=>\@remove_types)
      if @remove_types;

    $unflattener->unflatten_seq(-seq=>$seq,
				-use_magic=>!$nomagic,
				-group_tag=>$group_tag,
			       );
    $unflattener->report_problems(\*STDERR);
    $tm->map_types_to_SO(-seq=>$seq) unless $notypemap;

    my @seq_args = ($seq);
    if ($to eq 'chadoxml') {
	@seq_args = (-seq=>$seq, -nounflatten=>1)
    }
    if ($gff) {
        my $gffio = Bio::Tools::GFF->new(@out_opt, -noparse=>1, -gff_version => 3);
        $idhandler->set_ParentIDs_from_hierarchy($seq);
        foreach my $feature ($seq->get_all_SeqFeatures) {
            $gffio->write_feature($feature);
        }
        $gffio->close();
    }
    else {
        $out->write_seq(@seq_args);
    }

}

__END__