/usr/share/perl5/Bio/Tools/Geneid.pm is in libbio-perl-perl 1.6.924-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 | #
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Keith James
#
# Copyright Genome Research Ltd.
#
# You may distribute this module under the same terms as Perl itself
# POD documentation - main docs before the code
=encoding utf-8
=head1 NAME
Bio::Tools::Geneid - Results of one geneid run
=head1 SYNOPSIS
use Bio::Tools::Geneid;
my $gid = Bio::Tools::Geneid(-file => "geneid.out");
while (my $gene = $gid->next_prediction)
{
my @transcripts = $gene->transcripts;
foreach my $t (@transcripts)
{
my @exons = $t->exons;
foreach my $e (@exons)
{
printf("Exon %d..%d\n", $e->start, $e->end);
}
}
}
=head1 DESCRIPTION
This is the parser for the output of geneid by Enrique Blanco and
Roderic GuigE<243> (IMIM-UPF). See http://www1.imim.es/software/geneid. It
relies on native geneid output format internally and will work with
geneid versions 1.0 and 1.1. Currently this module supports only the
default mode of operation which is to predict exons and assemble an
optimal gene prediction.
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 - Keith James
Email: kdj@sanger.ac.uk
=head1 APPENDIX
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _
=cut
package Bio::Tools::Geneid;
use vars qw($SOURCE_TAG);
use strict;
use Bio::Tools::AnalysisResult;
use Bio::SeqFeature::Generic;
use Bio::SeqFeature::Gene::Exon;
use Bio::SeqFeature::Gene::Transcript;
use Bio::SeqFeature::Gene::GeneStructure;
use base qw(Bio::Root::Root Bio::Root::IO);
$SOURCE_TAG = 'geneid';
=head2 new
Title : new
Usage : $obj->new(-file = "<geneid.out");
$obj->new(-fh => \*GI);
Function: Constructor for geneid wrapper. Takes either a file
: or filehandle
Returns : L<Bio::Tools::Geneid>
=cut
sub new
{
my($class, @args) = @_;
my $self = $class->SUPER::new(@args);
$self->_initialize_io(@args);
return $self;
}
=head2 next_prediction
Title : next_prediction
Usage : while($gene = $geneid->next_prediction)
{
# do something
}
Function: Returns the gene structure prediction of the geneid result
file. Call this method repeatedly until FALSE is returned.
Returns : A Bio::SeqFeature::Gene::GeneStructure object
Args : None
=cut
sub next_prediction
{
my ($self) = @_;
my ($gene, $transcript, $current_gene_id);
my $transcript_score = 0;
my ($gene_id, $exon_type, $exon_start, $exon_end, $exon_score,
$exon_strand, $start_phase, $end_phase, $start_sig_score,
$end_sig_score, $coding_pot_score, $homol_score);
while (defined($_ = $self->_readline))
{
$self->debug($_);
s/^\s+//;
s/\s+$//;
# We have a choice of geneid, gff or XML formats. The native
# geneid format has more information than gff. However, we
# then need to perform the hack of extracting the sequence ID
# from the header of the embedded Fasta file which comes after
# the exon data, as it is not stored elsewhere. Ack.
# the new version of geneID includes the sequence ID in a slightly
# different format and a new "or" statement was added below
# also removed "unless defined $self->_target_id;" inorder to continue
# generating new sequence IDs.
if (/^>(\S+)\|GeneId/ or /^# Sequence (\S+)/)
{
my $target_id = $1;
$self->_target_id($target_id);
next;
}
next unless (/(Single|First|Internal|Terminal)/);
my @fields = split(/\s+/, $_);
# Grab gene_id from eol first as there are issues with
# inconsistent whitespace in the AA coords field
$gene_id = pop @fields;
($exon_type, $exon_start, $exon_end, $exon_score,
$exon_strand, $start_phase, $end_phase, $start_sig_score,
$end_sig_score, $coding_pot_score, $homol_score) = @fields[0..10];
if (! defined $current_gene_id)
{
# Starting the requested prediction
$current_gene_id = $gene_id;
$transcript_score = $exon_score;
$gene = Bio::SeqFeature::Gene::GeneStructure->new(-source =>
$SOURCE_TAG);
$transcript = Bio::SeqFeature::Gene::Transcript->new(-source =>
$SOURCE_TAG);
$self->_add_exon($gene, $transcript, $exon_type, $exon_start, $exon_end, $exon_score,
$exon_strand, $start_phase, $end_phase, $start_sig_score,
$end_sig_score, $coding_pot_score, $homol_score);
}
elsif ($gene_id eq $current_gene_id)
{
# Still in requested prediction
$transcript_score += $exon_score;
$self->_add_exon($gene, $transcript, $exon_type, $exon_start, $exon_end, $exon_score,
$exon_strand, $start_phase, $end_phase, $start_sig_score,
$end_sig_score, $coding_pot_score, $homol_score);
}
else
{
# Found following prediction
$self->_pushback($_);
last;
}
}
if (defined $gene)
{
$transcript->seq_id($self->_target_id);
$transcript->score($transcript_score);
$gene->add_transcript($transcript);
$gene->seq_id($self->_target_id);
foreach my $exon ($gene->exons)
{
$exon->seq_id($self->_target_id);
}
$self->_set_strand($gene);
}
return $gene;
}
=head2 _add_exon
Title : _add_exon
Usage : $obj->_add_exon($gene, $transcript, ... exon data ...)
Function: Adds a new exon to both gene and transcript from the data
: supplied as args
Example :
Returns : Nothing
=cut
sub _add_exon
{
my ($self, $gene, $transcript, $exon_type, $exon_start, $exon_end,
$exon_score, $exon_strand, $start_phase, $end_phase, $start_sig_score,
$end_sig_score, $coding_pot_score, $homol_score) = @_;
$exon_type =~ s/First/Initial/;
my $strand = $exon_strand eq '+' ? 1 : -1;
my $exon = Bio::SeqFeature::Gene::Exon->new(-source => $SOURCE_TAG,
-start => $exon_start,
-end => $exon_end,
-strand => $strand,
-score => $exon_score);
$exon->is_coding(1);
$exon->add_tag_value("Type", $exon_type);
$exon->add_tag_value('phase', $start_phase);
$exon->add_tag_value('end_phase', $end_phase);
$exon->add_tag_value('start_signal_score', $start_sig_score);
$exon->add_tag_value('end_signal_score', $end_sig_score);
$exon->add_tag_value('coding_potential_score', $coding_pot_score);
$exon->add_tag_value('homology_score', $homol_score);
$transcript->strand($strand) unless $transcript->strand != 0;
$transcript->add_exon($exon, $exon_type);
}
=head2 _set_strand
Title : _set_strand
Usage : $obj->_set_strand($gene)
Function: Sets the overall gene strand to the same strand as all
: the exons if they are all on the same strand, or to strand 0
: if the exons are on different strands.
Example :
Returns : Nothing
=cut
sub _set_strand
{
my ($self, $gene) = @_;
my $fwd = 0;
my $rev = 0;
my @exons = $gene->exons;
foreach my $exon (@exons)
{
my $strand = $exon->strand;
if ($strand == 1)
{
$fwd++;
}
elsif ($strand == -1)
{
$rev++;
}
}
if ($#exons == $fwd)
{
$gene->strand(1);
}
elsif ($#exons == $rev)
{
$gene->strand(-1);
}
else
{
$gene->strand(0);
}
return $gene;
}
=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,$val) = @_;
if ($val)
{
$self->{'_target_id'} = $val;
}
return $self->{'_target_id'};
}
1;
|