/usr/share/perl5/Bio/SeqIO/FTHelper.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 | #
# BioPerl module for Bio::SeqIO::FTHelper
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Ewan Birney <birney@ebi.ac.uk>
#
# Copyright Ewan Birney
#
# You may distribute this module under the same terms as perl itself
# POD documentation - main docs before the code
=head1 NAME
Bio::SeqIO::FTHelper - Helper class for EMBL/Genbank feature tables
=head1 SYNOPSIS
Used by Bio::SeqIO::EMBL,Bio::SeqIO::genbank, and Bio::SeqIO::swiss to
help process the Feature Table
=head1 DESCRIPTION
Represents one particular Feature with the following fields
key - the key of the feature
loc - the location string of the feature
<other fields> - other fields
=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 - Ewan Birney
Email birney@ebi.ac.uk
=head1 CONTRIBUTORS
Jason Stajich jason@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::SeqIO::FTHelper;
use strict;
use Bio::SeqFeature::Generic;
use Bio::Location::Simple;
use Bio::Location::Fuzzy;
use Bio::Location::Split;
use base qw(Bio::Root::Root);
sub new {
my ($class, @args) = @_;
# no chained new because we make lots and lots of these.
my $self = {};
bless $self,$class;
$self->{'_field'} = {};
return $self;
}
=head2 _generic_seqfeature
Title : _generic_seqfeature
Usage : $fthelper->_generic_seqfeature($annseq, "GenBank")
Function: processes fthelper into a generic seqfeature
Returns : TRUE on success and otherwise FALSE
Args : The Bio::Factory::LocationFactoryI object to use for parsing
location strings. The ID (e.g., display_id) of the sequence on which
this feature is located, optionally a string indicating the source
(GenBank/EMBL/SwissProt)
=cut
sub _generic_seqfeature {
my ($fth, $locfac, $seqid, $source) = @_;
my ($sf);
# set a default if not specified
if(! defined($source)) {
$source = "EMBL/GenBank/SwissProt";
}
# initialize feature object
$sf = Bio::SeqFeature::Generic->direct_new();
# parse location; this may cause an exception, in which case we gently
# recover and ignore this feature
my $loc;
eval {
$loc = $locfac->from_string($fth->loc);
};
if(! $loc) {
$fth->warn("exception while parsing location line [" . $fth->loc .
"] in reading $source, ignoring feature " .
$fth->key() . " (seqid=" . $seqid . "): " . $@);
return;
}
# set additional location attributes
if($seqid && (! $loc->is_remote())) {
$loc->seq_id($seqid); # propagates if it is a split location
}
# set attributes of feature
$sf->location($loc);
$sf->primary_tag($fth->key);
$sf->source_tag($source);
$sf->seq_id($seqid);
foreach my $key ( keys %{$fth->field} ){
foreach my $value ( @{$fth->field->{$key}} ) {
$sf->add_tag_value($key,$value);
}
}
return $sf;
}
=head2 from_SeqFeature
Title : from_SeqFeature
Usage : @fthelperlist = Bio::SeqIO::FTHelper::from_SeqFeature($sf,
$context_annseq);
Function: constructor of fthelpers from SeqFeatures
:
: The additional annseq argument is to allow the building of FTHelper
: lines relevant to particular sequences (ie, when features are spread over
: enteries, knowing how to build this)
Returns : an array of FThelpers
Args : seq features
=cut
sub from_SeqFeature {
my ($sf, $context_annseq) = @_;
my @ret;
#
# If this object knows how to make FThelpers, then let it
# - this allows us to store *really* weird objects that can write
# themselves to the EMBL/GenBank...
#
if ( $sf->can("to_FTHelper") ) {
return $sf->to_FTHelper($context_annseq);
}
my $fth = Bio::SeqIO::FTHelper->new();
my $key = $sf->primary_tag();
my $locstr = $sf->location->to_FTstring;
# ES 25/06/01 Commented out this code, Jason to double check
#The location FT string for all simple subseqfeatures is already
#in the Split location FT string
# going into sub features
#foreach my $sub ( $sf->sub_SeqFeature() ) {
#my @subfth = &Bio::SeqIO::FTHelper::from_SeqFeature($sub);
#push(@ret, @subfth);
#}
$fth->loc($locstr);
$fth->key($key);
$fth->field->{'note'} = [];
# the lines below take specific tags (e.g. /score=23 ) and re-enter them as
# new tags like /note="score=25" - if the file is round-tripped this creates
# duplicate values
#$sf->source_tag && do { push(@{$fth->field->{'note'}},"source=" . $sf->source_tag ); };
#($sf->can('score') && $sf->score) && do { push(@{$fth->field->{'note'}},
# "score=" . $sf->score ); };
#($sf->can('frame') && $sf->frame) && do { push(@{$fth->field->{'note'}},
# "frame=" . $sf->frame ); };
#$sf->strand && do { push(@{$fth->field->{'note'}},"strand=" . $sf->strand ); };
foreach my $tag ( $sf->get_all_tags ) {
# Tags which begin with underscores are considered
# private, and are therefore not printed
next if $tag =~ /^_/;
if ( !defined $fth->field->{$tag} ) {
$fth->field->{$tag} = [];
}
foreach my $val ( $sf->get_tag_values($tag) ) {
push(@{$fth->field->{$tag}},$val);
}
}
push(@ret, $fth);
unless (@ret) {
$context_annseq->throw("Problem in processing seqfeature $sf - no fthelpers. Error!");
}
foreach my $ft (@ret) {
if ( !$ft->isa('Bio::SeqIO::FTHelper') ) {
$sf->throw("Problem in processing seqfeature $sf - made a $fth!");
}
}
return @ret;
}
=head2 key
Title : key
Usage : $obj->key($newval)
Function:
Example :
Returns : value of key
Args : newvalue (optional)
=cut
sub key {
my ($obj, $value) = @_;
if ( defined $value ) {
$obj->{'key'} = $value;
}
return $obj->{'key'};
}
=head2 loc
Title : loc
Usage : $obj->loc($newval)
Function:
Example :
Returns : value of loc
Args : newvalue (optional)
=cut
sub loc {
my ($obj, $value) = @_;
if ( defined $value ) {
$obj->{'loc'} = $value;
}
return $obj->{'loc'};
}
=head2 field
Title : field
Usage :
Function:
Example :
Returns :
Args :
=cut
sub field {
my ($self) = @_;
return $self->{'_field'};
}
=head2 add_field
Title : add_field
Usage :
Function:
Example :
Returns :
Args :
=cut
sub add_field {
my ($self, $key, $val) = @_;
if ( !exists $self->field->{$key} ) {
$self->field->{$key} = [];
}
push( @{$self->field->{$key}} , $val);
}
1;
|