BioX-CLPM
view release on metacpan or search on metacpan
lib/BioX/CLPM/Enzyme.pm view on Meta::CPAN
package BioX::CLPM::Enzyme;
use base qw(BioX::CLPM::Base);
use Class::Std;
use Class::Std::Utils;
use warnings;
use strict;
use Carp;
use version; our $VERSION = qv('0.0.1');
{
my %enzyme_id_of :ATTR( :get<enzyme_id> :set<enzyme_id> :default<''> :init_arg<enzyme_id> );
my %name_of :ATTR( :get<name> :set<name> :default<''> :init_arg<name> );
my %clvg_sites_of :ATTR( :get<clvg_sites> :set<clvg_sites> :default<''> :init_arg<clvg_sites> );
my %clvg_position_of :ATTR( :get<clvg_position> :set<clvg_position> :default<''> :init_arg<clvg_position> );
my %rule_of :ATTR( :get<rule> :set<rule> :default<''> :init_arg<rule> );
sub START {
my ( $self, $ident, $arg_ref ) = @_;
if ( $arg_ref ) { $self->_load( $arg_ref ); }
return;
}
sub _load {
my ( $self, $arg_ref ) = @_;
# Update new enzyme_id if exists
if ( defined $arg_ref->{enzyme_id} ) {
my $enzyme_id = $arg_ref->{enzyme_id};
$self->set_enzyme_id($enzyme_id);
# Load other enzyme data from db
my $sql = 'select name, clvg_sites, clvg_position, rule ';
$sql .= "from enzymes where enzyme_id = '$enzyme_id'";
my ( $enzyme_name, $clvg_sites, $clvg_position, $rule ) = $self->sqlexec( $sql, '@' );
$self->set_name($enzyme_name);
$self->set_clvg_sites($clvg_sites);
$self->set_clvg_position($clvg_position);
$self->set_rule($rule);
warn "ENZYME _load() ( $enzyme_id, $enzyme_name, $clvg_sites, $clvg_position, $rule )\n";
}
elsif ( defined $arg_ref->{enzyme_name} ) {
my $enzyme_name = $arg_ref->{enzyme_name};
$self->set_name($enzyme_name);
# Load other enzyme data from db
my $sql = 'select enzyme_id, clvg_sites, clvg_position, rule ';
$sql .= "from enzymes where name = '$enzyme_name'";
my ( $enzyme_id, $clvg_sites, $clvg_position, $rule ) = $self->sqlexec( $sql, '@' );
$self->set_enzyme_id($enzyme_id);
$self->set_clvg_sites($clvg_sites);
$self->set_clvg_position($clvg_position);
$self->set_rule($rule);
warn "ENZYME _load() ( $enzyme_id, $enzyme_name, $clvg_sites, $clvg_position, $rule )\n";
}
}
# API READ ONLY
sub clvg_sites { my ( $self ) = @_; return split( //, $self->get_clvg_sites() ); }
sub generate_fragments {
my ($self, $arg_ref) = @_;
my @clvg_sites;
foreach my $sequence (@$arg_ref->{sequences}){
my @sequence = split(//, $sequence);
my $fragment;
my @initial_fragments;
foreach my $amino_acid (@sequence){
$fragment .= $amino_acid;
foreach my $clvg_site(@clvg_sites){
if (uc($amino_acid) eq $clvg_site){
push(@initial_fragments, $fragment);
$fragment='';
}
}
}
my @all_fragments = @initial_fragments;
for ( my $i = @initial_fragments - 1; $i > 1; $i--){
for ( my $j=0; $j<@initial_fragments-$i+1; $j++){
my $new_fragment = '';
$new_fragment.=$initial_fragments[$j];
for ( my $k=0; $k<$i-1; $k++){
$new_fragment.=$initial_fragments[$j+$k+1];
}
push (@all_fragments, $new_fragment);
}
}
foreach $fragment(@all_fragments){
if ($fragment=~m/.*[a-z]+.*/){
#&SQLExec("insert into fragments(sequence_id, fragment_sequence) values ($sequence_id, '$fragment')");
}
}
}
}
}
1; # Magic true value required at end of module
__END__
=head1 NAME
BioX::CLPM::Enzyme - Perl Tools for Mass Spec Peptide Matching
=head1 VERSION
This document describes BioX::CLPM::Enzyme version 0.0.1
=head1 SYNOPSIS
use BioX::CLPM::Enzyme;
my $obj = BioX::CLPM::Enzyme->new({attribute => 'value'});
print $obj->get_attribute(), "\n";
$obj->set_attribute('new value');
print $obj->get_attribute(), "\n";
=for author to fill in:
Brief code example(s) here showing commonest usage(s).
This section will be as far as many users bother reading
so make it as educational and exeplary as possible.
=head1 DESCRIPTION
=for author to fill in:
Write a full description of the module and its features here.
Use subsections (=head2, =head3) as appropriate.
=head1 INTERFACE
=for author to fill in:
Write a separate section listing the public components of the modules
interface. These normally consist of either subroutines that may be
exported, or methods that may be called on objects belonging to the
classes provided by the module.
=head1 DIAGNOSTICS
=for author to fill in:
List every single error and warning message that the module can
generate (even the ones that will "never happen"), with a full
explanation of each problem, one or more likely causes, and any
suggested remedies.
( run in 0.993 second using v1.01-cache-2.11-cpan-364913b4093 )