comparison lib/CPT/Bio/RBS/Algo/Naive.pm @ 1:8691c1c61a8e draft default tip

planemo upload commit 94b0cd1fff0826c6db3e7dc0c91c0c5a8be8bb0c
author cpt
date Mon, 05 Jun 2023 02:48:47 +0000
parents
children
comparison
equal deleted inserted replaced
0:54c7a3ea81e2 1:8691c1c61a8e
1 package CPT::Bio::RBS::Algo::Naive;
2 use Moose;
3 with 'CPT::Bio::RBS::Algo';
4 use CPT::Bio::RBS_Object;
5
6 my @SDs = (
7 'aggaggt',
8 'ggaggt',
9 'aggagg',
10 'aggag',
11 'gaggt',
12 'ggagg',
13 'aggt',
14 'gggt',
15 'gagg',
16 'gggg',
17 'agga',
18 'ggag',
19 'gga',
20 'gag',
21 'agg',
22 'ggt',
23 );
24
25 sub predict {
26 my ( $self, %params ) = @_;
27 my $upstream = $params{sequence};
28 my $only_best = $params{return_best};
29
30 my $length = length($upstream);
31
32 my @results = ();
33 foreach my $rbs ( @SDs ){
34 while ($upstream =~ /$rbs/g) {
35 # Position of regex match
36 my $loc = $-[0];
37 # Seq before RBS
38 my $before = substr($upstream,0, $loc);
39 # Seq after RBS
40 my $after = substr($upstream, $loc + length($rbs));
41 my $rbs_o = CPT::Bio::RBS_Object->new(
42 upstream => sprintf('%s %s %s', $before , uc($rbs) , $after),
43 score => $self->score_match($rbs, length($after)),
44 rbs_seq => uc($rbs),
45 separation => length($after),
46 );
47 push( @results, $rbs_o );
48 }
49 }
50 @results = sort { $b->score() <=> $a->score() } @results;
51 if (@results) {
52 if($only_best){
53 return ($results[0]);
54 }else{
55 return @results;
56 }
57 }
58 else {
59 return (
60 CPT::Bio::RBS_Object->new(
61 upstream =>$upstream,
62 score => '-1',
63 rbs_seq => 'None',
64 separation => -1,
65 )
66 );
67 }
68 }
69
70 sub score_match {
71 my ($self, $match, $dist) = @_;
72 return length($match);
73 }
74
75 1;
76
77 __END__
78
79 =pod
80
81 =encoding UTF-8
82
83 =head1 NAME
84
85 CPT::Bio::RBS::Algo::Naive
86
87 =head1 VERSION
88
89 version 1.99.4
90
91 =head1 AUTHOR
92
93 Eric Rasche <rasche.eric@yandex.ru>
94
95 =head1 COPYRIGHT AND LICENSE
96
97 This software is Copyright (c) 2014 by Eric Rasche.
98
99 This is free software, licensed under:
100
101 The GNU General Public License, Version 3, June 2007
102
103 =cut