/usr/share/perl5/Bio/Restriction/EnzymeCollection.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 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 400 401 402 403 404 405 406 407 408 409 410 411 412 | #-------------------------------------------------------------------------------
#
# BioPerl module Bio::Restriction::EnzymeCollection
#
# Please direct questions and support issues to <bioperl-l@bioperl.org>
#
# Cared for by Rob Edwards <redwards@utmem.edu>
#
# You may distribute this module under the same terms as perl itself
#-------------------------------------------------------------------------------
## POD Documentation:
=head1 NAME
Bio::Restriction::EnzymeCollection - Set of restriction endonucleases
=head1 SYNOPSIS
use Bio::Restriction::EnzymeCollection;
# Create a collection with the default enzymes.
my $default_collection = Bio::Restriction::EnzymeCollection->new();
# Or create a collection from a REBASE 'withrefm' file obtained from
# ftp://ftp.neb.com/pub/rebase/. (See Bio::Restriction::IO for more
# information.)
my $rebase = Bio::Restriction::IO->new(
-file => 'withrefm.610',
-format => 'withrefm' );
my $rebase_collection = $rebase->read();
# Or create an empty collection and set the enzymes later. See
# 'CUSTOM COLLECTIONS' below for more information.
my $empty_collection =
Bio::Restriction::EnzymeCollection->new( -empty => 1 );
# Get an array of Bio::Restriction::Enzyme objects from the collection.
my @enzymes = $default_collection->each_enzyme();
# Get a Bio::Restriction::Enzyme object for a particular enzyme by name.
my $enz = $default_collection->get_enzyme( 'EcoRI' );
# Get a Bio::Restriction::EnzymeCollection object containing the enzymes
# that have the equivalent of 6-bp recognition sequences.
my $six_cutters = $default_collection->cutters( 6 );
# Get a Bio::Restriction::EnzymeCollection object containing the enzymes
# that are rare cutters.
my $rare_cutters = $default_collection->cutters( -start => 6, -end => 8 );
# Get a Bio::Restriction::EnzymeCollection object that contains enzymes
# that generate blunt ends:
my $blunt_cutters = $default_collection->blunt_enzymes();
# See 'CUSTOM COLLECTIONS' below for an example of creating a
# Bio::Restriction::EnzymeCollection object with a specified subset of
# enzymes using methods provided by the Bio::RestrictionEnzyme class.
=head1 DESCRIPTION
Bio::Restriction::EnzymeCollection represents a collection of
restriction enzymes.
If you create a new collection directly rather than from a REBASE
file using L<Bio::Restriction::IO>, it will be populated by a
default set of enzymes with site and cut information
only.
Use L<Bio::Restriction::Analysis> to figure out which enzymes are
available and where they cut your sequence.
=head1 CUSTOM COLLECTIONS
Note that the underlying L<Bio::Restriction::Enzyme> objects have a rich
variety of methods that allow more complicated selections than the methods
that are defined by Bio::Restriction::EnzymeCollection.
For example, the way to create a custom collection of Type II enzymes
is as follows:
my $complete_collection =
Bio::Restriction::EnzymeCollection->new();
my $type_ii_collection =
Bio::Restriction::EnzymeCollection->new( -empty => 1 );
$type_ii_collection->enzymes(
grep { $_->type() eq 'II' } $complete_collection->each_enzyme() );
=head1 SEE ALSO
L<Bio::Restriction::IO> - read in enzymes from REBASE files
L<Bio::Restriction::Analysis> - figure out what enzymes cut a sequence
L<Bio::Restriction::Enzyme> - define a single restriction enzyme
=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
Rob Edwards, redwards@utmem.edu
=head1 CONTRIBUTORS
Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
=head1 COPYRIGHT
Copyright (c) 2003 Rob Edwards.
Some of this work is Copyright (c) 1997-2002 Steve A. Chervitz. All
Rights Reserved.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 APPENDIX
Methods beginning with a leading underscore are considered private and
are intended for internal use by this module. They are not considered
part of the public interface and are described here for documentation
purposes only.
=cut
package Bio::Restriction::EnzymeCollection;
use strict;
use Bio::Restriction::Enzyme;
use Bio::Restriction::IO;
use Data::Dumper;
use base qw(Bio::Root::Root);
=head2 new
Title : new
Function : Initializes the Restriction::EnzymeCollection object
Returns : The Restriction::EnzymeCollection object
Arguments : optional named parameter -empty
Set parameter -empty to true if you do NOT want the collection be
populated by the default set of prototype type II enzymes.
Alternatively, pass an array of enzymes to -enzymes parameter.
=cut
sub new {
my($class, @args) = @_;
my $self = $class->SUPER::new(@args);
my ($empty, $enzymes) =
$self->_rearrange([qw(
EMPTY
ENZYMES
)], @args);
$self->{'_all_enzymes'} = [];
$self->{'_enzymes'} = {};
return $self if $empty;
if ($enzymes) {
# as advertised in pod/maj
$self->throw( "Arg to -enzymes must be an arrayref to Bio::Restriction::Enzyme objects") unless ref($enzymes) eq 'ARRAY';
$self->enzymes(@$enzymes);
return $self;
}
else {
# the default set of enzymes
my $in = Bio::Restriction::IO->new(-verbose => $self->verbose);
return $in->read;
}
}
=head2 Manipulate the enzymes within the collection
=cut
=head2 enzymes
Title : enzyme
Function : add/get method for enzymes and enzyme collections
Returns : object itself
Arguments : array of Bio::Restriction::Enzyme and
Bio::Restriction::EnzymeCollection objects
=cut
sub enzymes {
my ($self, @enzs)=@_;
foreach my $e (@enzs) {
if ( ref $e eq '') {
print "|$e|\n";
}
elsif ($e->isa('Bio::Restriction::EnzymeI')) {
push(@{$self->{'_all_enzymes'}},$e);
$self->{'_enzymes'}->{$e->name} = $e;
}
elsif ($e->isa('Bio::Restriction::EnzymeCollection')) {
$self->enzymes($e->each_enzyme);
} else {
my $r = 1;
$self->warn("EnzymeCollection can not deal with ".
ref($e)." objects");
}
}
return $self;
}
#
# method to remove duplicates?
#
=head2 each_enzyme
Title : each_enzyme
Function : get an array of enzymes
Returns : array of Bio::Restriction::Enzyme objects
Arguments : -
=cut
sub each_enzyme {
my $self = shift;
return @{$self->{'_all_enzymes'}};
}
=head2 get_enzyme
Title : get_enzyme
Function : Gets a Bio::Restriction::Enzyme object for the enzyme name
Returns : A Bio::Restriction::Enzyme object or undef
Arguments : An enzyme name that is in the collection
=cut
sub get_enzyme {
my ($self, $name)=@_;
return $self->{'_enzymes'}->{$name};
}
=head2 available_list
Title : available_list
Function : Gets a list of all the enzymes that we know about
Returns : A reference to an array with all the enzyme names
that we have defined or 0 if none are defined
Arguments : Nothing
Comments : Note, I maintain this for backwards compatibility,
but I don't like the name as it is very ambiguous
=cut
sub available_list {
my ($self, $size)=@_;
my @keys = sort keys %{$self->{'_enzymes'}};
return @keys;
}
=head2 longest_cutter
Title : longest_cutter
Function : Gets the enzyme with the longest recognition site
Returns : A Bio::Restriction::Enzyme object
Arguments : Nothing
Comments : Note, this is used by Bio::Restriction::Analysis
to figure out what to do with circular sequences
=cut
sub longest_cutter {
my ($self)=@_;
my $longest=0; my $longest_enz='.';
foreach my $enz ($self->each_enzyme) {
my $len=$enz->recognition_length;
if ($len > $longest) {$longest=$len; $longest_enz=$enz}
}
return $longest_enz;
}
=head2 Filter enzymes
=cut
=head2 blunt_enzymes
Title : blunt_enzymes
Function : Gets a list of all the enzymes that are blunt cutters
Returns : A reference to an array with all the enzyme names that
are blunt cutters or 0 if none are defined
Arguments : Nothing
Comments :
This is an example of the kind of filtering better done by the scripts
using the rich collection of methods in Bio::Restriction::Enzyme.
=cut
sub blunt_enzymes {
my $self=shift;
my $bs = Bio::Restriction::EnzymeCollection->new(-empty => 1);
return $bs->enzymes( grep { $_->overhang eq 'blunt' } $self->each_enzyme );
}
=head2 cutters
Title : cutters
Function : Gets a list of all the enzymes that recognize a
certain size, e.g. 6-cutters
Usage : $cutters = $collection->cutters(6);
Returns : A reference to an array with all the enzyme names
that are x cutters or 0 if none are defined
Arguments : A positive number for the size of cutters to return
OR
A range: (-start => 6, -end => 8,
-inclusive => 1, -exclusive = 0 )
The default for a range is 'inclusive'
=cut
sub cutters {
my ($self) = shift;
return unless @_; # no argument
if (scalar @_ == 1 ) {
my $size = shift;
my @sizes;
(ref $size eq 'ARRAY') ? push @sizes, @{$size} : push @sizes, $size;
my $bs = Bio::Restriction::EnzymeCollection->new(-empty => 1);
for my $size (@sizes) {
$self->throw("Need a positive number [$size]")
unless $size =~ /[+]?[\d\.]+/;
foreach my $e ($self->each_enzyme) {
##print $e->name, ": ", $e->cutter, "\n" if $e->cutter == $size;
$bs->enzymes($e) if $e->cutter == $size;
}
}
return $bs;
} else { # named arguments
my ($start, $end, $inclusive, $exclusive ) =
$self->_rearrange([qw(
START
END
INCLUSIVE
EXCLUSIVE
)], @_);
$self->throw("Start needs a positive number [$start]")
unless $start =~ /[+]?[\d\.]+/;
$self->throw("End needs a positive number [$end]")
unless $end =~ /[+]?[\d\.]+/;
my $limits;
$inclusive = 1 if $inclusive or not $exclusive;
$inclusive = 0 if $exclusive;
my $bs = Bio::Restriction::EnzymeCollection->new(-empty => 1);
if ($inclusive) {
foreach my $e ($self->each_enzyme) {
$bs->enzymes($e) if $e->cutter >= $start and $e->cutter <= $end;
}
} else {
foreach my $e ($self->each_enzyme) {
$bs->enzymes($e) if $e->cutter > $start and $e->cutter < $end;
}
}
return $bs;
}
}
1;
|