File Coverage

blib/lib/HackaMol/Roles/SymopRole.pm
Criterion Covered Total %
statement 12 40 30.0
branch n/a
condition n/a
subroutine 4 5 80.0
pod 1 1 100.0
total 17 46 36.9


line stmt bran cond sub pod time code
1             package HackaMol::Roles::SymopRole;
2             $HackaMol::Roles::SymopRole::VERSION = '0.000_02'; # TRIAL
3              
4             $HackaMol::Roles::SymopRole::VERSION = '0.00002';#ABSTRACT: Fill your coordinates using symmetry operations
5 1     1   795 use Moose::Role;
  1         1  
  1         6  
6 1     1   3759 use Math::Vector::Real;
  1         1  
  1         45  
7 1     1   9 use Carp;
  1         1  
  1         297  
8              
9             sub apply_pdbstr_symops {
10              
11 0     0 1   my $self = shift;
12 0           my $symops = shift;
13 0           my $mol = shift;
14              
15 0           my $t = $mol->tmax+1;
16              
17 0           my %sym_op = (); # a hash to store them!
18             #this regex may be general enough to work on entire pdb
19 0           foreach my $line ( grep { m/REMARK 350\s+(BIOMT|SMTRY)\d+\s+\d+/ } split( '\n' , $symops ) ){
  0            
20 0           my @entries = split(' ', $line);
21 0           push @{$sym_op{$entries[3]}}, V(@entries[4,5,6,7]);
  0            
22             }
23              
24              
25 0           foreach my $symop (sort {$a<=>$b} keys %sym_op){
  0            
26 0           my @mat_d = @{$sym_op{$symop}};
  0            
27 0           my $cx = V(map{$_->[0]} @mat_d);
  0            
28 0           my $cy = V(map{$_->[1]} @mat_d);
  0            
29 0           my $cz = V(map{$_->[2]} @mat_d);
  0            
30 0           my $dxyz = V(map{$_->[3]} @mat_d);
  0            
31              
32 0           foreach my $atom ($mol->all_atoms){
33 0           my ($x,$y,$z) = @{$atom->xyz};
  0            
34 0           my $xyz_new = $x*$cx + $y*$cy + $z*$cz + $dxyz;
35 0           $atom->set_coords($t,$xyz_new);
36             }
37 0           $t++;
38             }
39              
40             }
41              
42 1     1   4 no Moose::Role;
  1         1  
  1         4  
43              
44             1;
45              
46             __END__
47              
48             =pod
49              
50             =head1 NAME
51              
52             HackaMol::Roles::SymopRole - Fill your coordinates using symmetry operations
53              
54             =head1 VERSION
55              
56             version 0.000_02
57              
58             =head1 DESCRIPTION
59              
60             The goal of HackaMol::Roles::SymopRole is to simplify the application of
61             symmetry operations. This role is not loaded with the core; it
62             must be applied as done in the synopsis. This role is envisioned for
63             instances of the HackaMol class, which provides builder.
64              
65             =head1 METHODS
66              
67             =head2 apply_pdbstr_symops
68              
69             takes two arguments:
70              
71             1. a string with one or more symmetry operations. As the name of the method suggests, the method works for strings formatted as in a
72             typical protein databank file. It will filter for lines containing the SMTRY or BIOMT pattern.
73              
74             2. the molecule with the initial coordinates
75              
76             The method applies the symmetry operators and adds the coordinates to each atom of the molecule.
77              
78             =head1 SYNOPSIS
79              
80             ## Symmetry operations using copy and pasted from the PDB
81              
82             my $symops = '
83             REMARK 350 APPLY THE FOLLOWING TO CHAINS: A, B
84             REMARK 350 BIOMT1 1 1.000000 0.000000 0.000000 0.00000
85             REMARK 350 BIOMT2 1 0.000000 1.000000 0.000000 0.00000
86             REMARK 350 BIOMT3 1 0.000000 0.000000 1.000000 0.00000
87             REMARK 350 BIOMT1 2 -1.000000 0.000000 0.000000 -125.59400
88             REMARK 350 BIOMT2 2 0.000000 -1.000000 0.000000 -125.48300
89             REMARK 350 BIOMT3 2 0.000000 0.000000 1.000000 0.00000
90             '; # from pdb
91              
92             say $mol->tmax ; # says 0
93              
94             $bldr->apply_pdbstr_symops($symops,$mol); # will add coordinates for each, even the identity op (the first three)
95              
96             $mol->tmax ; # says 2
97              
98              
99             my $enzyme = $mol->select_group("chain E");
100             my $inhib = $mol->select_group("chain I");
101              
102             =head1 WARNING
103              
104             This is still under active development and may change or just not work. I still need to add warnings to help with bad
105             selections. Let me know if you have problems or suggestions!
106              
107             =head1 AUTHOR
108              
109             Demian Riccardi <demianriccardi@gmail.com>
110              
111             =head1 COPYRIGHT AND LICENSE
112              
113             This software is copyright (c) 2016 by Demian Riccardi.
114              
115             This is free software; you can redistribute it and/or modify it under
116             the same terms as the Perl 5 programming language system itself.
117              
118             =cut