This file is indexed.

/usr/share/perl5/Bio/Tools/Genewise.pm is in libbio-perl-perl 1.6.924-3.

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
#
# BioPerl module for Bio::Tools::Genewise
#
# Copyright Fugu Team 
#
# You may distribute this module under the same terms as perl itself

# POD documentation - main docs before the code

=head1 NAME

Bio::Tools::Genewise - Results of one Genewise run

=head1 SYNOPSIS

  use Bio::Tools::Genewise;
  my $gw = Bio::Tools::Genewise(-file=>"genewise.out");

  while (my $gene = $gw->next_prediction){
    my @transcripts = $gene->transcripts;
      foreach my $t(@transcripts){
        my @exons =  $t->exons;
        foreach my $e(@exons){
            print $e->start." ".$e->end."\n";
        }
      }
  }

=head1 DESCRIPTION

This is the parser for the output of Genewise. It takes either a file
handle or a file name and returns a 
Bio::SeqFeature::Gene::GeneStructure object.

=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 one
of 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://github.com/bioperl/bioperl-live/issues

=head1 AUTHOR - Fugu Team, Jason Stajich 

 Email: fugui@worf.fugu-sg.org
 Email: jason-at-bioperl.org

=head1 APPENDIX

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

=cut


# Let the code begin...


package Bio::Tools::Genewise;
use vars qw($Srctag);
use strict;
use Symbol;

use Bio::Tools::AnalysisResult;
use Bio::SeqFeature::Generic;
use Bio::SeqFeature::Gene::Exon;
use Bio::SeqFeature::FeaturePair;
use Bio::SeqFeature::Gene::Transcript;
use Bio::SeqFeature::Gene::GeneStructure;

use base qw(Bio::Root::Root Bio::Root::IO);
$Srctag = 'genewise';

=head2 new

 Title   : new
 Usage   : $obj->new(-file=>"genewise.out");
           $obj->new(-fh=>\*GW);
 Function: Constructor for genewise wrapper. Takes either a file or filehandle
 Example :
 Returns : Bio::Tools::Genewise object

See L<Bio::Tools::Genewise>

=cut

sub new {
  my($class,@args) = @_;
  my $self = $class->SUPER::new(@args);
  $self->_initialize_io(@args);
  return $self;
}

=head2 _get_strand

 Title   : _get_strand
 Usage   : $obj->_get_strand
 Function: takes start and end values, swap them if start>end and 
           returns end
 Example :
 Returns :$start,$end,$strand

=cut

sub _get_strand {
  my ($self,$start,$end) = @_;
  defined($start) || $self->throw("Need a start");
  defined($end)   || $self->throw("Need an end");
  my $strand;
  if ($start > $end) {
    my $tmp = $start;
    $start = $end;
    $end = $tmp;
    $strand = -1;
  }
  else {
    $strand = 1;
  }
  return ($start,$end,$strand);
}

=head2 _score

 Title   : _score
 Usage   : $obj->_score
 Function: get/set for score info
 Returns : a score value

=cut

sub _score {
    my $self = shift;
    return $self->{'_score'} = shift if @_;
    return $self->{'_score'};
}

=head2 _prot_id

 Title   : _prot_id
 Usage   : $obj->_prot_id
 Function: get/set for protein id 
 Returns :a protein id

=cut

sub _prot_id {
    my $self = shift;
    return $self->{'_prot_id'} = shift if @_;
    return $self->{'_prot_id'};
}

=head2 _target_id

 Title   : _target_id
 Usage   : $obj->_target_id
 Function: get/set for genomic sequence id
 Example :
 Returns :a target id

=cut

sub _target_id {
    my $self = shift;
    return $self->{'_target_id'} = shift if @_;
    return $self->{'_target_id'};
}


=head2 next_prediction

 Title   : next_prediction
 Usage   : while($gene = $genewise->next_prediction()) {
                  # do something
           }
 Function: Returns the gene structure prediction of the Genewise result
           file. Call this method repeatedly until FALSE is returned.

 Example :
 Returns : a Bio::SeqFeature::Gene::GeneStructure object
 Args    :

See L<Bio::SeqFeature::Gene::GeneStructure>

=cut


sub next_prediction {
    my ($self) = @_;

    unless ( $self->parsed ){
	$self->_parse_genes;
	$self->parsed(1);
    }
    return shift @{$self->{'_genes'}};
}

sub parsed {
    my $self = shift;
    return $self->{'_parsed'} = 1 if @_ && $_[0]; 
    return $self->{'_parsed'};
}
  
sub _parse_genes {
    my ($self) = @_;
    my (@alignments,@genes);
    local ($/) = "//";

    while ( defined($_ = $self->_readline) ) {
	$self->debug( $_ );
	while( /Alignment\s+(\d+)\s+Score\s+(\S+)\s+\(Bits\)/g ) {
	    $alignments[$1] = $2;
	}
	if( /Score\s+(\-?\d+(\.\d+)?)/ ) {
	    $self->_score($1);# unless defined $self->_score;    
	}

	if( /Query\s+(?:protein|model)\:\s+(\S+)/ ) {
	    $self->_prot_id($1); #unless defined $self->_prot_id;
	} 

	if( /Target Sequence\s+(\S+)/ ) {	
	    $self->_target_id($1);# unless defined $self->_target_id;
	}	
	
	next unless /Gene\s+\d+\n/;
	my @genes_txt = split(/Gene\s+\d+\n/,$_);
	shift @genes_txt;	#remove first empty entry
	my $gene_num = 1;
	foreach my $gene_txt (@genes_txt) {
	    my $score = $alignments[$gene_num];
	    # If genewise has assigned a strand to the gene as a whole
	    # overall gene start and end
	    my ($g_start, $g_end, $type) = 
		$gene_txt =~ m/Gene\s+
		(\d+)[\s-]+	# start (1-based)
		(\d+)\s+	# end
		(?:\[(\w+)\])?	# 
		/x;
	    my $g_strand;
	    my $source_tag = $type ? "$Srctag". "_$type" : $Srctag;
	    my $genes = Bio::SeqFeature::Gene::GeneStructure->new
		(-source => $source_tag,
		 -score  => $self->_score,
		 );
	    $genes->add_tag_value('ID', $self->_prot_id.".gene");
	    my $transcript = Bio::SeqFeature::Gene::Transcript->new
		(-source => $source_tag,
		 -score  => $score);
	    ($g_start, $g_end, $g_strand) = $self->_get_strand($g_start,$g_end);
	    $genes->strand($g_strand);

	    # grab exon + supporting feature info
	    my @exons;
	    unless ( @exons = $gene_txt =~ m/(Exon .+\s+Supporting .+)/g ) {
		@exons = $gene_txt =~ m/(Exon .+\s+)/g;
	    }
	    my $nbr = 1;

	    # loop through each exon-supporting feature pair
	    foreach my $e (@exons){
		my ($e_start,$e_end,$phase) = 
		    $e =~ m/Exon\s+
		    (\d+)[\s-]+	# start (1 based)
		    (\d+)\s+	# end
		    phase\s+(\d+) # phase
		    /x;
		my $e_strand;
		($e_start,$e_end,$e_strand) = $self->_get_strand($e_start,
								 $e_end);
		$transcript->strand($e_strand) unless $transcript->strand != 0;
		my $exon = Bio::SeqFeature::Gene::Exon->new
		    (-seq_id =>$self->_target_id,
		     -source => $source_tag,
		     -start  =>$e_start, 
		     -end    =>$e_end, 
		     -score  => $score,
		     #-frame => $phase,
		     -strand =>$e_strand);

		$exon->add_tag_value('phase',$phase);
		$exon->is_coding(1);
		if( $self->_prot_id ) {
		    $exon->add_tag_value('Parent',$self->_prot_id);
		}
		$exon->add_tag_value("Exon",$nbr++);
		if( $e =~ m/Supporting\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
		    my ($geno_start,$geno_end,
			$prot_start, $prot_end) = ($1,$2,$3,$4);
		    my $prot_strand;
		    ($prot_start,$prot_end,
		     $prot_strand) = $self->_get_strand($prot_start,$prot_end);
		    my $pf = Bio::SeqFeature::Generic->new
			( -start   => $prot_start, 
			  -end     => $prot_end,
			  -seq_id  => $self->_prot_id,
			  -score   => $score,
			  -strand  => $prot_strand,
			  -source  => $source_tag,
			  -primary_tag => 'supporting_protein_feature',);
		    my $geno_strand;
		    ($geno_start,$geno_end,
		     $geno_strand) = $self->_get_strand($geno_start,$geno_end);
		    my $gf = Bio::SeqFeature::Generic->new 
			( -start   => $geno_start,
			  -end     => $geno_end,
			  -seq_id  => $self->_target_id,
			  -score   => $score,
			  -strand  => $geno_strand,
			  -source  => $source_tag,
			  -primary_tag => 'supporting_genomic_feature',);
		    my $fp = Bio::SeqFeature::FeaturePair->new
			(-feature1 =>$gf,
			 -feature2 =>$pf);
		    $exon->add_tag_value( 'supporting_feature',$fp );
		    if( $self->_prot_id ) {
			$exon->add_tag_value('Target','Protein:'.$self->_prot_id);
			$exon->add_tag_value('Target',$prot_start);
			$exon->add_tag_value('Target',$prot_end);
		    }
		}
		$transcript->add_exon($exon);
	    }
	    $transcript->seq_id($self->_target_id);
	    $transcript->add_tag_value('ID', $self->_prot_id);
	    $transcript->add_tag_value('Parent', $self->_prot_id.".gene");
	    $genes->add_transcript($transcript);
	    $genes->seq_id($self->_target_id);
	    push @genes, $genes;
	    $gene_num++;
	}
    }
    $self->{'_genes'} = \@genes;
}

1;