BioUtil/Misc.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 4 Conditioncond 0.0% 0 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 57 CC 3 SCAR 16.7
CC
3
Cov
0%
parse_embossre
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.3
1 package BioUtil::Misc;
2
3 use BioUtil::Seq;
4
5 require Exporter;
6 @ISA = (Exporter);
7 @EXPORT = qw(
8 parse_embossre
9 );
10
11 use vars qw($VERSION);
12
13 use 5.010_000;
14 use strict;
15 use warnings FATAL => 'all';
16
17 =head1 NAME
18
19 BioUtil::Misc - Miscellaneous functions
20
21 =head1 VERSION
22
23 Version 2014.0901
24
25 =cut
26
27 our $VERSION = 2014.0901;
28
29 =head1 EXPORT
30
31 parse_embossre
32
33 =head1 SYNOPSIS
34
35 use BioUtil::Misc;
36
37
38 =head1 SUBROUTINES/METHODS
39
40 =head2 parse_embossre
41
42 Example
43
44 my $enzs = parse_embossre("embossre.enz");
45
46 for my $enz ( sort keys %$enzs ) {
47 my $e = $$enzs{$enz};
48 print join ", ",
49 (
50 $$enzs{$enz}{name}, $$enzs{$enz}{pattern},
51 $$enzs{$enz}{length}, $$enzs{$enz}{cuts_number},
52 $$enzs{$enz}{is_blunt}, $$enzs{$enz}{c1},
53 $$enzs{$enz}{c2}, $$enzs{$enz}{c3},
54 $$enzs{$enz}{c4},
55 ),
56 "\n";
57 }
58
59 =cut
60
61 sub parse_embossre {
62 my ($file) = @_;
63 my ( $enzs, $enz ) = ( {}, '' );
64 open my $fh, $file or die "fail to open enzyme file $file!\n";
65 while (<$fh>) {
66 next if /^#/; # annotation
67 next unless /(\w+) # name
68 \t(\w+) # pattern
69 \t(\d+) # length of pattern
70 \t(\d+) # number of cuts made by enzyme
71 \t(\d+) # is blunt
72 \t([\d\-]+) # c1 = First 5' cut
73 \t([\d\-]+) # c2 = First 3' cut
74 \t([\d\-]+) # c3 = Second 5' cutx;
75 \t([\d\-]+) # c4 = Second 3' cut
76 /x;
77 $enz = $1;
78 $enz .= '*' while defined $$enzs{$enz};
79 $$enzs{$enz}{name} = $1;
80 $$enzs{$enz}{pattern} = uc $2;
81 $$enzs{$enz}{pattern_regexp}
82 = degenerate_seq_to_regexp( $$enzs{$enz}{pattern} );
83 $$enzs{$enz}{length} = $3;
84 $$enzs{$enz}{cuts_number} = $4;
85 $$enzs{$enz}{is_blunt} = $5;
86 $$enzs{$enz}{c1} = $6;
87 $$enzs{$enz}{c2} = $7;
88 $$enzs{$enz}{c3} = $8;
89 $$enzs{$enz}{c4} = $9;
90 }
91 close $fh;
92 return $enzs;
93 }
94
95 1;