2 # BioPerl module for Bio::Restriction::IO::withrefm
4 # Please direct questions and support issues to <bioperl-l@bioperl.org>
6 # Cared for by Rob Edwards <redwards@utmem.edu>
8 # Copyright Rob Edwards
10 # You may distribute this module under the same terms as perl itself
13 # POD documentation - main docs before the code
17 Bio::Restriction::IO::bairoch - bairoch enzyme set
21 Do not use this module directly. Use it via the Bio::Restriction::IO class.
25 This is the most complete format of the REBASE files, and basically
26 includes all the data on each of the restriction enzymes.
28 This parser is for the Bairoch format (aka MacVector, Vector NTI, PC/Gene
29 (Bairoch) format), REBASE format #19
35 User feedback is an integral part of the evolution of this and other
36 Bioperl modules. Send your comments and suggestions preferably to the
37 Bioperl mailing lists Your participation is much appreciated.
39 bioperl-l@bioperl.org - General discussion
40 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
44 Please direct usage questions or support issues to the mailing list:
46 I<bioperl-l@bioperl.org>
48 rather than to the module maintainer directly. Many experienced and
49 reponsive experts will be able look at the problem and quickly
50 address it. Please include a thorough description of the problem
51 with code and data examples if at all possible.
55 Report bugs to the Bioperl bug tracking system to help us keep track
56 the bugs and their resolution. Bug reports can be submitted via the
59 http://bugzilla.open-bio.org/
63 Rob Edwards, redwards@utmem.edu
67 Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
71 The rest of the documentation details each of the object
72 methods. Internal methods are usually preceded with a _
76 # Let the code begin...
78 package Bio
::Restriction
::IO
::bairoch
;
80 use vars
qw(%WITH_REFM_FIELD);
83 use Bio::Restriction::Enzyme;
84 use Bio::Restriction::Enzyme::MultiCut;
85 use Bio::Restriction::Enzyme::MultiSite;
86 use Bio::Restriction::EnzymeCollection;
90 use base qw(Bio::Restriction::IO::base);
95 Usage : $renzs = $stream->read
96 Function: reads all the restrction enzymes from the stream
97 Returns : a Bio::Restriction::Restriction object
105 my $renzs = Bio
::Restriction
::EnzymeCollection
->new(-empty
=> 1);
108 while (defined(my $entry=$self->_readline()) ) {
109 $self->debug("|$entry|\n");
112 # Minimal information
114 my ($name) = $entry =~ /ID\s+(\S+)/;
115 my ($site) = $entry =~ /RS\s+([^\n]+)/;
116 next unless ($name && $site);
118 # the standard sequence format for these guys is:
120 # or, for enzymes that cut more than once
123 # there are a couple of sequences that have multiple
128 @sequences = split /\;/, $site;
129 $self->debug(@sequences,"\n");
130 $site=shift @sequences;
133 my ($seq, $cut)=split /,\s+/, $site;
134 $self->debug("SITE: |$site| GAVE: |$seq| and |$cut|\n");
136 $self->warn("$name: no site. Skipping") if $self->verbose > 1;
140 # this is mainly an error check to make sure that I am adding what I think I am!
141 if ($seq !~ /[NGATC]/i) {
142 $self->throw("Sequence $name has weird sequence: |$seq|");
146 $re = Bio::Restriction::Enzyme->new(-name=>$name, -seq => $seq);
149 if ($cut !~ /^-?\d+$/) {
150 $self->throw("Cut site from $name is weird: |$cut|\n");
153 $re = Bio::Restriction::Enzyme->new(-name=>$name,
158 $renzs->enzymes($re);
161 # prototype / isoschizomers
163 my ($prototype) = $entry =~ /PT\s+([^\n]+)/;
166 #$re->isoschizomers(split /\,/, $isoschizomers);
167 #NOTE: Need to add a method so that we can add isoschosomers to enzymes that may not exist!
168 $re->is_prototype(0);
170 $re->is_prototype(1);
177 my ($meth) = $entry =~ /MS\s+([^\n]+)/;
180 # this can be either X(Y) or X(Y),X2(Y2)
181 # where X is the base and y is the type of methylation
182 if ( $meth =~ /(\S+)\((\d+)\),(\S+)\((\d+)\)/ ) { # two msites per site
183 #my ($p1, $m1, $p2, $m2) = ($1, $2, $3, $4);
184 $re->methylation_sites($self->_meth($re,$1, $2),
185 $self->_meth($re,$3,$4));
187 elsif ($meth =~ /(\S+)\((\d+)\)/ ) { # one msite per site or more sites
189 $re->methylation_sites( $self->_meth($re,$1,$2) );
190 @meths = split /, /, $meth;
193 $self->warn("Unknown methylation format [$meth]") if $self->verbose >0;
200 my ($microbe) = $entry =~ /OS\s+([^\n]+)/;
201 $re->microbe($microbe) if $microbe;
206 #my ($source) = $entry =~ /<6>([^\n]+)/;
207 #$re->source($source) if $source;
212 my ($vendors) = $entry =~ /CR\s+([^\n]+)/;
213 $re->vendors(split /,\s*/, $vendors) if $vendors;
218 #my ($refs) = $entry =~ /<8>(.+)/s;
219 #$re->references(map {split /\n+/} $refs) if $refs;
222 # create special types of Enzymes
224 $self->warn("Current issues with multisite enzymes using bairoch format\n".
225 "Recommend using itype2 or withrefm formats for now") if @sequences;
226 #$self->_make_multisites($renzs, $re, \@sequences, \@meths) if @sequences;
237 Usage : $stream->write($renzs)
238 Function: writes restriction enzymes into the stream
239 Returns : 1 for success and 0 for error
240 Args : a Bio::Restriction::Enzyme
241 or a Bio::Restriction::EnzymeCollection object
247 $self->throw_not_implemented;