1 # BioPerl module for Bio::Restriction::IO::itype2
3 # Please direct questions and support issues to <bioperl-l@bioperl.org>
5 # Cared for by Rob Edwards <redwards@utmem.edu>
7 # Copyright Rob Edwards
9 # You may distribute this module under the same terms as perl itself
12 # POD documentation - main docs before the code
16 Bio::Restriction::IO::itype2 - itype2 enzyme set
20 Do not use this module directly. Use it via the Bio::Restriction::IO class.
24 This is tab delimited, entry per line format which is fast to process.
30 User feedback is an integral part of the evolution of this and other
31 Bioperl modules. Send your comments and suggestions preferably to the
32 Bioperl mailing lists Your participation is much appreciated.
34 bioperl-l@bioperl.org - General discussion
35 http://bioperl.org/wiki/Mailing_lists - About the mailing lists
39 Please direct usage questions or support issues to the mailing list:
41 I<bioperl-l@bioperl.org>
43 rather than to the module maintainer directly. Many experienced and
44 reponsive experts will be able look at the problem and quickly
45 address it. Please include a thorough description of the problem
46 with code and data examples if at all possible.
50 Report bugs to the Bioperl bug tracking system to help us keep track
51 the bugs and their resolution. Bug reports can be submitted via the
54 https://github.com/bioperl/bioperl-live/issues
58 Rob Edwards, redwards@utmem.edu
62 Heikki Lehvaslaiho, heikki-at-bioperl-dot-org
63 Mark A. Jensen, maj-at-fortinbras-dot-us
67 The rest of the documentation details each of the object
68 methods. Internal methods are usually preceded with a _
72 # Let the code begin...
74 package Bio
::Restriction
::IO
::itype2
;
78 use Bio
::Restriction
::Enzyme
;
79 use Bio
::Restriction
::EnzymeCollection
;
83 use base
qw(Bio::Restriction::IO::base);
88 Usage : $renzs = $stream->read
89 Function: reads all the restrction enzymes from the stream
90 Returns : a Bio::Restriction::IO object
93 Internally creates a hash of enzyme information which is passed on to
94 L<Bio::Restriction::Enzyme::new>.
101 my $renzs = Bio
::Restriction
::EnzymeCollection
->new(-empty
=> 1);
103 # read until start of data
104 while (defined( my $line = $self->_readline()) ) {
105 next if $line =~ /^[ R]/;
106 $self->_pushback($line);
110 # enzyme name [tab] prototype [tab] recognition sequence with
111 # cleavage site [tab] methylation site and type [tab] commercial
112 # source [tab] references
114 while (defined(my $line = $self->_readline()) ) {
118 my ($name, $prototype, $site, $meth, $vendor, $refs) = split /\t/, $line;
119 # we need mininum name and site
121 $self->warn("Can not parse line with name [$name]") if $self->verbose > 0;
126 # # four cut enzymes are not in this format
128 # if ($site =~ m/^\((\d+\/\d+)\)[ATGCN]+/) {
130 # $site =~ s/\($precut\)//;
132 # -------------- cut ---------------
134 # this regexp now parses all possible components
135 # $1 : (s/t) or undef
137 # $3 : (m/n) or undef /maj
139 my ($precut, $recog, $postcut) = ( $site =~ m/^(?:\((\w+\/\w
+)\
))?
([\w
^]+)(?
:\
((\w
+\
/\w+)\))?/ );
144 @sequences = split( /\,/, $site);
145 $site=shift @sequences;
152 # presence of a name means the prototype isoschizomer, absence means
153 # this enzyme is the prototype
154 my $is_prototype = ($prototype ?
1 : 0);
161 @vendors = ( split / */, $vendor) if $vendor;
167 @refs = map {split /\n+/} $refs if $refs;
169 # when enz is constructed, site() will contain original characters,
170 # but recog() will contain a regexp if required.../maj
172 my $re = Bio
::Restriction
::Enzyme
->new(
177 -postcut
=> $postcut,
178 -is_prototype
=> $is_prototype,
179 -prototype => $prototype,
180 -vendors
=> [@vendors],
181 -references
=> [@refs],
182 -xln_sub
=> \
&_xln_sub
188 # [easier to set here during parsing than in constructor] /maj
191 # this can be either X(Y) or X(Y),X2(Y2)
192 # where X is the base and y is the type of methylation
193 if ( $meth =~ /(\S+)\((\d+)\),(\S+)\((\d+)\)/ ) { # two msites per site
194 #my ($p1, $m1, $p2, $m2) = ($1, $2, $3, $4);
195 $re->methylation_sites($self->_meth($re,$1, $2),
196 $self->_meth($re,$3,$4));
198 elsif ($meth =~ /(\S+)\((\d+)\)/ ) { # one msite per site or more sites
200 $re->methylation_sites( $self->_meth($re,$1,$2) );
201 @meths = split (/, /, $meth);
204 $self->warn("Unknown methylation format [$meth]") if $self->verbose >0;
209 # create special types of Enzymes
211 $self->_make_multisites( $re, \
@sequences, \
@meths) if @sequences;
212 $renzs->enzymes($re);
223 Function: Translates withrefm coords to Bio::Restriction coords
224 Args : Bio::Restriction::Enzyme object, scalar integer (cut posn)
225 Note : Used internally; pass as a coderef to the B:R::Enzyme
232 return ($c < 0 ?
$c : length($z->string)+$c);
238 Usage : $stream->write($renzs)
239 Function: writes restriction enzymes into the stream
240 Returns : 1 for success and 0 for error
241 Args : a Bio::Restriction::Enzyme
242 or a Bio::Restriction::EnzymeCollection object
248 $self->throw_not_implemented;