line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::SeqUtils::Promoter::Annotations::Consensus; |
2
|
|
|
|
|
|
|
#################################################################### |
3
|
|
|
|
|
|
|
# Charles Stephen Embry # |
4
|
|
|
|
|
|
|
# MidSouth Bioinformatics Center # |
5
|
|
|
|
|
|
|
# University of Arkansas Little Rock # |
6
|
|
|
|
|
|
|
#################################################################### |
7
|
1
|
|
|
1
|
|
2011
|
use base qw(BioX::SeqUtils::Promoter::Annotations::Base); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
142
|
|
8
|
|
|
|
|
|
|
use Class::Std; |
9
|
|
|
|
|
|
|
use Class::Std::Utils; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use BioX::SeqUtils::Promoter::Sequence; |
12
|
|
|
|
|
|
|
use BioX::SeqUtils::Promoter::Sequences; |
13
|
|
|
|
|
|
|
use DBIx::MySperql qw(DBConnect SQLExec $dbh); |
14
|
|
|
|
|
|
|
use warnings; |
15
|
|
|
|
|
|
|
use strict; |
16
|
|
|
|
|
|
|
use Carp; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use version; our $VERSION = qv('0.1.1'); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
{ |
21
|
|
|
|
|
|
|
my %motifs_of :ATTR( :get :set :default<[]> :init_arg ); |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub BUILD { |
24
|
|
|
|
|
|
|
my ($self, $ident, $arg_ref) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub START { |
30
|
|
|
|
|
|
|
my ($self, $ident, $arg_ref) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
sub print_motifs { |
35
|
|
|
|
|
|
|
my ($self, $arg_ref) = @_; |
36
|
|
|
|
|
|
|
my $motifs = $self->get_motifs(); |
37
|
|
|
|
|
|
|
print join(', ', @$motifs ), "\n"; |
38
|
|
|
|
|
|
|
return; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub set_reg { |
42
|
|
|
|
|
|
|
my ($self, $arg_ref) = @_; |
43
|
|
|
|
|
|
|
#takes a Sequences object as a parameter |
44
|
|
|
|
|
|
|
my $bases = defined $arg_ref->{bases} ? $arg_ref->{bases} : ''; |
45
|
|
|
|
|
|
|
my $num = 0; |
46
|
|
|
|
|
|
|
my $database = 'stephen'; |
47
|
|
|
|
|
|
|
my $host = 'localhost'; |
48
|
|
|
|
|
|
|
my $user = 'root'; |
49
|
|
|
|
|
|
|
my $pass = '2020.mbc'; |
50
|
|
|
|
|
|
|
my @sequences = $bases->get_objects(); |
51
|
|
|
|
|
|
|
my $id_seq; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
foreach my $seqobj(@sequences) { |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
my $DNA = $seqobj->get_sequence(); |
56
|
|
|
|
|
|
|
my $test = $DNA; |
57
|
|
|
|
|
|
|
my $label = $sequences[$num]->get_label(); |
58
|
|
|
|
|
|
|
#print "$label\n"; |
59
|
|
|
|
|
|
|
my $seqlength = $self->length({ string => $sequences[$num]->get_sequence( label => $label) }); |
60
|
|
|
|
|
|
|
#print "$seqlength\n"; |
61
|
|
|
|
|
|
|
$num++; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#my $colors = $seqobj->get_color_list(); |
64
|
|
|
|
|
|
|
my $colors; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
#print "$colors->[0]\n"; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
#my $base = $seqobj->get_base_list(); |
69
|
|
|
|
|
|
|
my $base; |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
#create a default list of colors the correct length and a list of ascending numberical value |
72
|
|
|
|
|
|
|
for(my $k =0; $k <= $seqlength; $k++){ |
73
|
|
|
|
|
|
|
$base->[$k] = $k; |
74
|
|
|
|
|
|
|
$colors->[$k] = 'black'; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
$id_seq .= "$label\n"; |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
#connect to MySql database |
81
|
|
|
|
|
|
|
$dbh = DBConnect(database => $database, host => $host, user => $user, pass => $pass); |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
my $sql = "select consensus_id, consensus_name, motif, length, color from consensus"; |
84
|
|
|
|
|
|
|
my $rowsref = SQLExec( $sql, '\@@' ); |
85
|
|
|
|
|
|
|
foreach my $rowref ( @$rowsref ) { |
86
|
|
|
|
|
|
|
my ( $id, $name, $motif, $length, $color ) = @$rowref; |
87
|
|
|
|
|
|
|
my $pattern = "(.*)($motif)"; |
88
|
|
|
|
|
|
|
my $position; |
89
|
|
|
|
|
|
|
my $first = 1; |
90
|
|
|
|
|
|
|
#match database sequences against user data |
91
|
|
|
|
|
|
|
while ( $test =~ m/(.*?)$motif/g ) { |
92
|
|
|
|
|
|
|
if ( $first ) { |
93
|
|
|
|
|
|
|
$position = scalar( split( '', $1 ) ) + 1; |
94
|
|
|
|
|
|
|
} else { |
95
|
|
|
|
|
|
|
$position += scalar( split( '', $1 ) ) + $length; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
#print "$id, $name, $motif, $position, $length, $color \n"; |
99
|
|
|
|
|
|
|
$id_seq .= "$id, $name, $motif, $position, $length, $color \n"; |
100
|
|
|
|
|
|
|
$first = 0; |
101
|
|
|
|
|
|
|
for (my $i = 0 ; $i <= $length - 1; $i++ ) { |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$colors->[$position -1 + $i] = $color; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
#print "test space\n"; |
106
|
|
|
|
|
|
|
#$bases->set_color({bases => $base, colors => $colors, label => $label}); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$bases->set_color({bases => $base, colors => $colors, label => $label}); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
open (MYFILE, '>out_consensus'); |
116
|
|
|
|
|
|
|
#write a file that list in which sequence object matches where found |
117
|
|
|
|
|
|
|
print MYFILE $id_seq; |
118
|
|
|
|
|
|
|
close (MYFILE); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
return; |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
126
|
|
|
|
|
|
|
__END__ |