This file is indexed.

/usr/share/perl5/Bio/Assembly/IO.pm is in libbio-perl-perl 1.6.923-1.

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

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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# $Id: IO.pm 16690 2010-01-14 07:27:29Z kortsch $
#
# BioPerl module for Bio::Assembly::IO
#
#   based on the Bio::SeqIO module
#       by Ewan Birney <birney@ebi.ac.uk>
#       and Lincoln Stein  <lstein@cshl.org>
#
# Copyright Robson Francisco de Souza
#
# You may distribute this module under the same terms as perl itself
#
# _history

# POD documentation - main docs before the code

=head1 NAME

Bio::Assembly::IO - Handler for Assembly::IO Formats

=head1 SYNOPSIS

    use Bio::Assembly::IO;

    $in  = Bio::Assembly::IO->new(-file=>"<inputfilename",
                                  -format=>'phrap');
    $out = Bio::Assembly::IO->new(-file=>">outputfilename",
                                  -format=>'phrap');

    while ( my $scaffold = $in->next_assembly() ) {
       # do something with Bio::Assembly::Scaffold instance
       # ...
       $out->write_assembly(-scaffold => $scaffold);
    }

    $in->close;
    $out->close;

=head1 DESCRIPTION

Bio::Assembly::IO is a handler module for formats in the Assembly::IO set
(e.g. Bio::Assembly::IO::phrap).

=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 lists  Your participation is much appreciated.

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

=head2 Support 

Please direct usage questions or support issues to the mailing list:

I<bioperl-l@bioperl.org>

rather than to the module maintainer directly. Many experienced and 
reponsive experts will be able look at the problem and quickly 
address it. Please include a thorough description of the problem 
with code and data examples if at all possible.

=head2 Reporting Bugs

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

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

=head1 AUTHOR

Robson Francisco de Souza

E-mail: rfsouza@citri.iq.usp.br

=head1 CONTRIBUTORS

#

=head1 APPENDIX

The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _

=cut

package Bio::Assembly::IO;


use strict;

use base qw(Bio::Root::Root Bio::Root::IO);

=head2 new

 Title   : new
 Usage   : $stream = Bio::Assembly::IO->new( -file   => $filename,
                                             -format =>'format'    )
 Function: Returns a new assembly stream
 Returns : A Bio::Assembly::IO::Handler initialised
           with the appropriate format
 Args    : -file   => $filename
           -format => format

=cut

sub new {
    my ($caller,@args) = @_;
    my $class = ref($caller) || $caller;

    # or do we want to call SUPER on an object if $caller is an
    # object?
    if( $class =~ /Bio::Assembly::IO::(\S+)/ ) {
        my ($self) = $class->SUPER::new(@args);
        $self->_initialize(@args);
        return $self;
    } else {

        my %param = @args;
        @param{ map { lc $_ } keys %param } = values %param; # lowercase keys

        $class->throw("Need at least a file name to proceed!")
            unless (defined $param{'-file'} || defined $ARGV[0]);

        my $format = $param{'-format'} ||
        $class->_guess_format( $param{-file} || $ARGV[0] );
        $format = "\L$format";	# normalize capitalization to lower case

        if ($format =~ /-/) {
            ($format, my $variant) = split('-', $format, 2);
            push @args, (-variant => $variant);
        }

        return unless( $class->_load_format_module($format) );
        return "Bio::Assembly::IO::$format"->new(@args);
    }
}


=head2 format

 Title   : format
 Usage   : $format = $stream->format()
 Function: Get the assembly format
 Returns : assembly format
 Args    : none

=cut

# format() method inherited from Bio::Root::IO


# _initialize is chained for all SeqIO classes
sub _initialize {
    my($self, @args) = @_;
    # initialize the IO part
    $self->_initialize_io(@args);
}


=head2 next_assembly

 Title   : next_assembly
 Usage   : $scaffold = $stream->next_assembly()
 Function: Reads the next assembly object from the stream and returns it.
 Returns : a Bio::Assembly::ScaffoldI compliant object
 Args    : none

=cut

sub next_assembly {
   my ($self) = @_;
   $self->throw("Cannot read from a generic Bio::Assembly::IO object.");
}


=head2 next_contig

 Title   : next_contig
 Usage   : $contig = $stream->next_contig()
 Function: Reads the next contig or singlet from the stream and returns it.
 Returns : a Bio::Assembly::Contig or Bio::Contig::Assembly::Singlet
 Args    : none

=cut

sub next_contig {
   my ($self) = @_;
   $self->throw("Cannot read from a generic Bio::Assembly::IO object.");
}


=head2 write_assembly

  Title   : write_assembly
  Usage   : $stream->write_assembly($assembly)
  Function: Write the assembly object in desired format. This method calls
            write_header(), write_contigs() and write_footer() internally.
  Returns : 1 on success, 0 for error
  Args    : A Bio::Assembly::Scaffold object

=cut

sub write_assembly {
    my ($self, @args) = @_;
    my ($scaf, $write_singlets) = $self->_rearrange([qw(SCAFFOLD SINGLETS)], @args);

    # Sanity check
    if ( !$scaf || !$scaf->isa('Bio::Assembly::ScaffoldI') ) {
        $self->throw("Must provide a Bio::Assembly::Scaffold object when calling write_assembly");
    }

    # Write header
    $self->write_header($scaf);

    # ID-sorted contig and read entries
    my @contig_ids  = $scaf->get_contig_ids;
    if ($write_singlets) {
        push @contig_ids, $scaf->get_singlet_ids;
    }
    @contig_ids = _sort(@contig_ids);

    # Write contigs
    for my $contig_id ( @contig_ids ) {
        my $contig = $scaf->get_contig_by_id($contig_id) ||
                     $scaf->get_singlet_by_id($contig_id);
        $self->write_contig($contig);
    }

    # Write footer
    $self->write_footer($scaf);

    return 1;      
}


=head2 write_header

  Title   : write_header
  Usage   : $stream->write_header($assembly)
  Function: Write the start of the assembly file. It can be called at any time,
            not when starting to write the assembly file. 
  Returns : 1 on success, 0 for error
  Args    : A Bio::Assembly::Scaffold object or ... (check the specific format
            driver for more details)

=cut

sub write_header {
   my ($self) = @_;
   $self->throw("Cannot write from a generic Bio::Assembly::IO object.");
}


=head2 write_contig

  Title   : write_contig
  Usage   : $stream->write_contig($contig)
  Function: Write a contig object in the desired format.
  Returns : 1 on success, 0 for error
  Args    : A Bio::Assembly::Contig object

=cut

sub write_contig {
   my ($self) = @_;
   $self->throw("Cannot write from a generic Bio::Assembly::IO object.");
}


=head2 write_footer

  Title   : write_footer
  Usage   : $stream->write_footer($assembly)
  Function: Write the start of the assembly file.
  Returns : 1 on success, 0 for error
  Args    : A Bio::Assembly::Scaffold object or ... (check the specific format
            driver for more details)

=cut

sub write_footer {
   my ($self) = @_;
   $self->throw("Cannot write from a generic Bio::Assembly::IO object.");
}


=head2 _load_format_module

 Title   : _load_format_module
 Usage   : *INTERNAL Assembly::IO stuff*
 Function: Loads up (like use) a module at run time on demand
 Example :
 Returns :
 Args    :

=cut

sub _load_format_module {
  my ($self,$format) = @_;
  my $module = "Bio::Assembly::IO::" . $format;
  my $ok;

  eval {
      $ok = $self->_load_module($module);
  };
  if ( $@ ) {
    print STDERR <<END;
$self: could not load $format - for more details on supported formats please see the Assembly::IO docs
Exception $@
END
  ;
  }
  return $ok;
}

=head2 _guess_format

 Title   : _guess_format
 Usage   : $obj->_guess_format($filename)
 Function: guess format based on file suffix
 Example :
 Returns : guessed format of filename (lower case)
 Args    :
 Notes   : formats that _filehandle() will guess includes
           ace, phrap and tigr at the moment

=cut

sub _guess_format {
   my $class = shift;
   my $arg   = shift;

   return unless defined($arg);
   return 'ace'    if ($arg =~ /\.ace/i);
   return 'phrap'  if ($arg =~ /\.phrap/i);
   return 'tigr'   if ($arg =~ /\.tigr/i);
   return 'maq'    if ($arg =~ /\.maq/i);
   return 'sam'    if ($arg =~ /\.[bs]am/i);
   return 'bowtie' if ($arg =~ /\.bowtie/i);

}


=head2 _sort

    Title   : _sort
    Usage   : @sorted_values = $ass_io->_sort(@values)
    Function: Sort a list of values naturally if Sort::Naturally is installed
              (nicer), lexically otherwise (not as nice, but safe)
    Returns : array of sorted values
    Args    : array of values to sort

=cut

sub _sort {
    my @arr = @_;
    my @sorted_arr;
    if (eval { require Sort::Naturally }) {
        @sorted_arr = Sort::Naturally::nsort( @arr ); # natural sort (better)
    } else {
        @sorted_arr = sort @arr; # lexical sort (safe)
    }
    return @sorted_arr;
}


sub DESTROY {
    my $self = shift;

    $self->close();
}

# I need some direction on these!! The module works so I haven't fiddled with them!
# Me neither! (rfsouza)

sub TIEHANDLE {
    my ($class,$val) = @_;
    return bless {'seqio' => $val}, $class;
}

sub READLINE {
    my $self = shift;
    return $self->{'seqio'}->next_seq() unless wantarray;
    my (@list, $obj);
    push @list, $obj while $obj = $self->{'seqio'}->next_seq();
    return @list;
}

sub PRINT {
    my $self = shift;
    $self->{'seqio'}->write_seq(@_);
}

1;