line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package BioX::CLPM::Sequence; |
2
|
1
|
|
|
1
|
|
1243
|
use base qw(BioX::CLPM::Base); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
73
|
|
3
|
|
|
|
|
|
|
use Bio::Perl qw(read_sequence); |
4
|
|
|
|
|
|
|
use Class::Std; |
5
|
|
|
|
|
|
|
use Class::Std::Utils; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use warnings; |
8
|
|
|
|
|
|
|
use strict; |
9
|
|
|
|
|
|
|
use Carp; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use version; our $VERSION = qv('0.0.1'); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
{ |
14
|
|
|
|
|
|
|
my %sequence_of :ATTR( :get :set :default<''> :init_arg ); |
15
|
|
|
|
|
|
|
my %sequence_id_of :ATTR( :get :set :default<''> :init_arg ); |
16
|
|
|
|
|
|
|
my %cl_sequence_of :ATTR( :get :set :default<''> :init_arg ); |
17
|
|
|
|
|
|
|
my %ann_cl_sequence_of :ATTR( :get :set :default<''> :init_arg ); |
18
|
|
|
|
|
|
|
my %fragments_of :ATTR( :get :set :default<[]> :init_arg ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub START { |
21
|
|
|
|
|
|
|
my ( $self, $ident, $arg_ref ) = @_; |
22
|
|
|
|
|
|
|
if ( $arg_ref ) { $self->_load( $arg_ref ); } |
23
|
|
|
|
|
|
|
return; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub fragments { my ( $self ) = @_; return @{ $self->get_fragments() }; } |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub _load { |
29
|
|
|
|
|
|
|
my ( $self, $arg_ref ) = @_; |
30
|
|
|
|
|
|
|
#my $sequence_id = defined $arg_ref->{sequence_id} ? |
31
|
|
|
|
|
|
|
if ( defined $arg_ref->{sequence_id} ) { |
32
|
|
|
|
|
|
|
$self->_load_from_db( $arg_ref ); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
elsif ( defined $arg_ref->{sequence} ) { |
35
|
|
|
|
|
|
|
# $self->_load_from_sequence( $arg_ref ); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
elsif ( defined $arg_ref->{file} ) { |
38
|
|
|
|
|
|
|
$self->_load_from_file( $arg_ref ); |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
# if(defined $arg_ref->{linker}){ |
41
|
|
|
|
|
|
|
# if( $self->get_cl_sequence eq ''){ |
42
|
|
|
|
|
|
|
# $self->mark_cl_sites( { linker=>$arg_ref->{linker} } ); |
43
|
|
|
|
|
|
|
# } |
44
|
|
|
|
|
|
|
# } |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _load_from_file { |
48
|
|
|
|
|
|
|
my ( $self, $arg_ref ) = @_; |
49
|
|
|
|
|
|
|
my $file = $arg_ref->{file} ? $arg_ref->{file} : ''; |
50
|
|
|
|
|
|
|
my $sequence; |
51
|
|
|
|
|
|
|
if ( -e $file ) { |
52
|
|
|
|
|
|
|
# Guess file format from extension with read_sequence() |
53
|
|
|
|
|
|
|
my $seq_object = read_sequence( $file ); |
54
|
|
|
|
|
|
|
$sequence = $seq_object->seq(); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
$self->set_sequence( $sequence ); |
57
|
|
|
|
|
|
|
warn "SEQUENCE _load_from_file() file $file sequence $sequence \n"; |
58
|
|
|
|
|
|
|
return; |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub insert { |
62
|
|
|
|
|
|
|
my ( $self, $arg_ref ) = @_; |
63
|
|
|
|
|
|
|
my $sequence = defined $arg_ref->{sequence} ? |
64
|
|
|
|
|
|
|
$arg_ref->{sequence} : |
65
|
|
|
|
|
|
|
$self->get_sequence(); |
66
|
|
|
|
|
|
|
if ( $sequence ) { $self->set_sequence($sequence); } |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# Calculate cl_sequence and ann_cl_sequence |
69
|
|
|
|
|
|
|
# TODO |
70
|
|
|
|
|
|
|
my $cl_sequence; |
71
|
|
|
|
|
|
|
my $ann_cl_sequence; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $sql = 'insert into sequences (sequence, cl_sequence, ann_cl_sequence) '; |
74
|
|
|
|
|
|
|
$sql .= "values ('$sequence', '$cl_sequence', '$ann_cl_sequence')"; |
75
|
|
|
|
|
|
|
$self->sqlexec( $sql ); |
76
|
|
|
|
|
|
|
$sql = 'select LAST_INSERT_ID()'; |
77
|
|
|
|
|
|
|
my ( $sequence_id ) = $self->sqlexec( $sql, '\@@' ); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$self->set_sequence_id( $sequence_id ); |
80
|
|
|
|
|
|
|
$self->set_sequence( $sequence ); |
81
|
|
|
|
|
|
|
$self->set_cl_sequence( $cl_sequence ); |
82
|
|
|
|
|
|
|
$self->set_ann_cl_sequence( $ann_cl_sequence ); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub _load_from_db { |
86
|
|
|
|
|
|
|
my ( $self, $arg_ref ) = @_; |
87
|
|
|
|
|
|
|
my $sequence_id = defined $arg_ref->{sequence_id} ? |
88
|
|
|
|
|
|
|
$arg_ref->{sequence_id} : |
89
|
|
|
|
|
|
|
$self->get_sequence_id(); |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
if ( defined $arg_ref->{sequence_id} ) { |
92
|
|
|
|
|
|
|
$self->set_sequence_id($sequence_id); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my $sql = 'select sequence, cl_sequence, ann_cl_sequence '; |
96
|
|
|
|
|
|
|
$sql .= "from sequences where sequence_id = '$sequence_id'"; |
97
|
|
|
|
|
|
|
my ( $sequence, $cl_sequence, $ann_cl_sequence ) = $self->sqlexec( $sql, '@' ); |
98
|
|
|
|
|
|
|
$self->set_sequence( $sequence ); |
99
|
|
|
|
|
|
|
$self->set_cl_sequence( $cl_sequence ); |
100
|
|
|
|
|
|
|
$self->set_ann_cl_sequence( $ann_cl_sequence ); |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
# sub _load_from_sequence{ |
104
|
|
|
|
|
|
|
# my ( $self, $arg_ref ) = @_; |
105
|
|
|
|
|
|
|
# my $sequence = defined $arg_ref->{sequence} ? |
106
|
|
|
|
|
|
|
# $arg_ref->{sequence} : |
107
|
|
|
|
|
|
|
# $self->get_sequence(); |
108
|
|
|
|
|
|
|
# if ( defined $arg_ref->{sequence} ) { |
109
|
|
|
|
|
|
|
# $self->set_sequence(uc($sequence)); |
110
|
|
|
|
|
|
|
# } |
111
|
|
|
|
|
|
|
# return; |
112
|
|
|
|
|
|
|
# } |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# sub mark_cl_sites{ |
115
|
|
|
|
|
|
|
# my ($self, $arg_ref) = @_; |
116
|
|
|
|
|
|
|
# my $end1 = $arg_ref->{linker}->get_end1(); |
117
|
|
|
|
|
|
|
# my $end2 = $arg_ref->{linker}->get_end2(); |
118
|
|
|
|
|
|
|
# foreach my $amino_acid (split('', $end1 . $end2)){ |
119
|
|
|
|
|
|
|
# $amino_acid = uc($amino_acid); |
120
|
|
|
|
|
|
|
# my $amino_acid_lc = lc($amino_acid); |
121
|
|
|
|
|
|
|
# my $sequence = $self->get_sequence(); |
122
|
|
|
|
|
|
|
# $sequence=~s/$amino_acid/$amino_acid_lc/g; |
123
|
|
|
|
|
|
|
# $self->set_cl_sequence($sequence); |
124
|
|
|
|
|
|
|
# } |
125
|
|
|
|
|
|
|
# } |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
129
|
|
|
|
|
|
|
__END__ |