Bio::Restriction::IO base
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Restriction::IO::base - base enzyme set
Package variables
Privates (from "my" definitions)
$offset;
Included modules
Bio::Restriction::Enzyme
Bio::Restriction::EnzymeCollection
Bio::Restriction::IO
Data::Dumper
Inherit
Bio::Restriction::IO
Synopsis
Do not use this module directly. Use it via the Bio::Restriction::IO class.
Description
This class defines some base methods for restriction enzyme input and
at the same time gives a base list of common enzymes.
Methods
new
No description
Code
_initialize
No description
Code
readDescriptionCode
writeDescriptionCode
_cuts_from_siteDescriptionCode
_methDescriptionCode
_coordinate_shift_to_cutDescriptionCode
_make_multisitesDescriptionCode
_make_multicutsDescriptionCode
_companiesDescriptionCode
Methods description
readcode    nextTop
 Title   : read
 Usage   : $renzs = $stream->read
 Function: reads all the restrction enzymes from the stream
 Returns : a Bio::Restriction::Restriction object
 Args    : none
writecodeprevnextTop
 Title   : write
 Usage   : $stream->write($renzs)
 Function: writes restriction enzymes into the stream
 Returns : 1 for success and 0 for error
 Args    : a Bio::Restriction::Enzyme
           or a Bio::Restriction::EnzymeCollection object
_cuts_from_sitecodeprevnextTop
 Title   : _cuts_from_site
 Usage   : ($site, $cut, $comp_cut) = _cuts_from_site('ACGCGT(4/5)');
 Function: Separates cut positions from a single site string.
           Does nothing to site if it does not have the cut string
 Returns : array of site_string, forward_cut_position, reverse_cut_position
 Args    : recognition site string
_methcodeprevnextTop
 Title   : _meth
 Usage   : ($pos, $meth) = $self->_meth('2(5)');
 Function: Separates methylation postion and coce from a string.
           Adjusts the postion depending on enzyme site length
           and symmetry 
 Returns : array of position and methylation code
 Args    : 1. reference to Enzyme object
           2. methylation description string
_coordinate_shift_to_cutcodeprevnextTop
 Title   : _coordinate_shift_to_cut
 Usage   : $cut = $self->_coordinate_shift_to_cut($oricut, offset);
 Function: Adjust cut position coordinates to start from the 
           first nucleotides of site
 Returns : Cut position in correct coordinates
 Args    : 1. Original cut position
           2. Length of the recognition site
_make_multisitescodeprevnextTop
 Title   : _make_multisites
 Usage   : $self->_make_multisites($collection, $first_enzyme, \@sites, \@mets)
 Function: 

           Bless a Bio::Restriction::Enzyme (which is already part of
           the collection object) into
           Bio::Restriction::Enzyme::MultiSite and clone it as many
           times as there are alternative sites. The new objects are
           added into the collection and into others list of sister
           objects.

 Returns : nothing, does in place editing
 Args    : 1. a Bio::Restriction::EnzymeCollection
           2. a Bio::Restriction::Enzyme
           3. reference to an array of recognition site strings
           4. reference to an array of methylation code strings, optional
_make_multicutscodeprevnextTop
 Title   : _make_multicuts
 Usage   : $self->_make_multicuts($collection, $first_enzyme, $precuts)
 Function: 

           Bless a Bio::Restriction::Enzyme (which is already part of
           the collection object) into
           Bio::Restriction::Enzyme::MultiCut and clone it. The precut
           string is processed to replase the cut sites in the cloned
           object which is added into the collection. Both object
           refere to each other through others() method.

 Returns : nothing, does in place editing
 Args    : 1. a Bio::Restriction::EnzymeCollection
           2. a Bio::Restriction::Enzyme
           3. precut string, e.g. '12/7'
The examples we have of multiply cutting enzymes cut only four
times. This protected method deals only with a string of two
integers separated with a slash, e.g. '12/7'. The numbers represent the postions
BEFORE the start of the recognition site, i.e. negative positions.
_companiescodeprevnextTop
 Title     : _companies
 Purpose   : Defines the companies that we know about
 Returns   : A hash
 Argument  : Nothing
 Comments  : An internal method to define the companies that we know about
             REBASE uses a code, and this converts the code to the real name
	     (e.g. A = Amersham Pharmacia Biotech)
Methods code
newdescriptionprevnextTop
sub new {
    my($class, @args) = @_;
    my $self = bless {}, $class;
    $self->_initialize(@args);
    return $self;
}
_initializedescriptionprevnextTop
sub _initialize {
    my($self,@args) = @_;
    return unless $self->SUPER::_initialize(@args);
}
readdescriptionprevnextTop
sub read {
    my $self = shift;

    my $renzs = new Bio::Restriction::EnzymeCollection(-empty => 1);
    seek DATA,($offset||=tell DATA), 0;
    while (<DATA>) {
        chomp;
        next if /^\s*$/;
        my ($name, $site, $cut) = split /\s+/;
        #foreach my $key (keys %{$res}) {
#my ($site, $cut) = split /\s+/, $res->{$key};
my $re = new Bio::Restriction::Enzyme(-name => $name, -site => $site, -cut => $cut); $renzs->enzymes($re); } return $renzs;
}
writedescriptionprevnextTop
sub write {
    my $self = shift;
    foreach (@_) {
        map { printf "%s\t%s\t%s\n", $_->name, $_->string, $_->cut
          } sort {$a->name cmp $b->name} $_->each_enzyme
            if $_->isa('Bio::Restriction::EnzymeCollection');
        printf "%s\t%s\t%s\n", $_->name, $_->string, $_->cut 
            if $_->isa('Bio::Restriction::Enzyme');
    }
}
_cuts_from_sitedescriptionprevnextTop
sub _cuts_from_site {
    my ($self, $site) = @_;
    my ($cut, $comp_cut) = $site =~ /\((-?\d+)\/(-?\d+)\)/;
    $site =~ s/\(.*\)$//;
    return ($site, $cut, $comp_cut);
}
_methdescriptionprevnextTop
sub _meth {
    my ($self, $re, $meth) = @_;

    $meth =~ /(\S+)\((\d+)\)/;
    my ($pos, $m) = ($1, $2);
    $pos = 0 if $pos eq '?';
    $pos = $re->seq->length + $pos if $pos and ! $re->palindromic;
    return ($pos, $m);

    $self->warn("Unknown methylation format [$meth]") if $self->verbose >0;
}
_coordinate_shift_to_cutdescriptionprevnextTop
sub _coordinate_shift_to_cut {
    my ($self, $cut, $site_length) = @_;
    return $cut + $site_length;
}
_make_multisitesdescriptionprevnextTop
sub _make_multisites {
    my ($self, $renzs, $re, $sites, $meths) = @_;

    bless $re, 'Bio::Restriction::Enzyme::MultiSite';
    #print Dumper $re, $sites, $meths;
my $count = 0; while ($count < scalar @{$sites}) { #print ">>>>>>>>>>>", scalar @{$sites}, ">>>>>>>>>>>>>>>>>>>>>> $count\n";
my $re2 = $re->clone; my $site = @{$sites}[$count]; my ($cut, $comp_cut); ($site, $cut, $comp_cut) = $self->_cuts_from_site($site); $re2->site($site); if ($cut) { $re->cut($self->_coordinate_shift_to_cut(length($site), $cut)); $re->complementary_cut($self->_coordinate_shift_to_cut(length($site), $comp_cut)); } if ($meths and @$meths) { $re2->purge_methylation_sites; $re2->methylation_sites($self->_meth($re2, @{$meths}[$count])); } $re->others($re2); $count++; } foreach my $enz ($re->others) { $enz->others($re, grep {$_ ne $enz} $re->others); } #print Dumper $re;
1;
}
_make_multicutsdescriptionprevnextTop
sub _make_multicuts {
    my ($self, $renzs, $re, $precut) = @_;

    bless $re, 'Bio::Restriction::Enzyme::MultiCut';

    my ($cut, $comp_cut) = $precut =~ /(-?\d+)\/(-?\d+)/;
    
    # Pads the front to prevent detection of sites when the 1st
# cut is off the end of the sequence.
my $site = $re->site; $re->site(('N' x abs($cut)) . $site); my $re2 = $re->clone; $re2->cut("-$cut"); $re2->complementary_cut("-$comp_cut"); $re->others($re2); 1;
}
_companiesdescriptionprevnextTop
sub _companies {
    # this is just so it is easy to set up the codes that REBASE uses
my $self=shift; my %companies=( 'A'=>'Amersham Pharmacia Biotech (1/03)', 'C'=>'Minotech Biotechnology (6/01)', 'E'=>'Stratagene (1/03)', 'F'=>'Fermentas AB (1/03)', 'G'=>'Qbiogene (1/03)', 'H'=>'American Allied Biochemical, Inc. (10/98)', 'I'=>'SibEnzyme Ltd. (1/03)', 'J'=>'Nippon Gene Co., Ltd. (6/00)', 'K'=>'Takara Shuzo Co. Ltd. (1/03)', 'M'=>'Roche Applied Science (1/03)', 'N'=>'New England Biolabs (1/03)', 'O'=>'Toyobo Biochemicals (11/98)', 'P'=>'Megabase Research Products (5/99)', 'Q'=>'CHIMERx (1/03)', 'R'=>'Promega Corporation (1/03)', 'S'=>'Sigma Chemical Corporation (1/03)', 'U'=>'Bangalore Genei (1/03)', 'V'=>'MRC-Holland (1/03)', 'X'=>'EURx Ltd. (1/03)'); $self->{company}=\%companies;
}
General documentation
FEEDBACKTop
Mailing ListsTop
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://bio.perl.org/MailList.html        - About the mailing lists
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
the bugs and their resolution. Bug reports can be submitted via email
or the web:
  bioperl-bugs@bio.perl.org
  http://bugzilla.bioperl.org/
AUTHORTop
Rob Edwards, redwards@utmem.edu
CONTRIBUTORSTop
Heikki Lehvaslaiho, heikki@ebi.ac.uk
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
Common REBASE parsing methodsTop
The rest of the methods in this file are to be used by other REBASE
parsers. They are not to be used outside subclasses of this base
class. (They are 'protected' in the sense the word is used in Java.)