| 1 | package HackaMol; | ||||||||||||||||||||||||||||
| 2 | 11 | $HackaMol::VERSION = '0.051'; | |||||||||||||||||||||||||||
| 3 | #ABSTRACT: HackaMol: Object-Oriented Library for Molecular Hacking | ||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use 5.008; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use HackaMol::AtomGroup; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use HackaMol::Molecule; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use HackaMol::Atom; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use HackaMol::Bond; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use HackaMol::Angle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use HackaMol::Dihedral; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use Math::Vector::Real; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use namespace::autoclean; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 11 | ▶ | use MooseX::StrictConstructor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 11 | ▶ | use Scalar::Util qw(refaddr); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 11 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 11 | has 'readline_func' => ( | |||||||||||||||||||||||||||
| 19 | is => 'rw', | ||||||||||||||||||||||||||||
| 20 | isa => 'CodeRef', | ||||||||||||||||||||||||||||
| 21 | predicate => 'has_readline_func', | ||||||||||||||||||||||||||||
| 22 | clearer => 'clear_readline_func', | ||||||||||||||||||||||||||||
| 23 | ); | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 11 | with | |||||||||||||||||||||||||||
| 26 | 'HackaMol::Roles::NameRole', | ||||||||||||||||||||||||||||
| 27 | 'HackaMol::Roles::MolReadRole', | ||||||||||||||||||||||||||||
| 28 | 'HackaMol::Roles::PathRole', | ||||||||||||||||||||||||||||
| 29 | 'HackaMol::Roles::ExeRole', | ||||||||||||||||||||||||||||
| 30 | 'HackaMol::Roles::FileFetchRole', | ||||||||||||||||||||||||||||
| 31 | 'HackaMol::Roles::NERFRole', | ||||||||||||||||||||||||||||
| 32 | 'HackaMol::Roles::RcsbRole'; | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | sub pdbid_mol { | ||||||||||||||||||||||||||||
| 37 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
pdbid_mol: called CC=2 SCAR=10.1
Pod
documented
| |||||||||||||||||||||||||||||
| 38 | 1 | ▶ | my $pdbid = shift || croak "Croak on passing pdbid, e.g. 2cba"; | ||||||||||||||||||||||||||
|
Condition33%1/3
shift() || croak('Croak on passing pdbid, e.g. 2cba')
MC/DC0%0/2
shift() || croak('Croak on passing pdbid, e.g. 2cba')
shift()
croak('Croak on passing pdbid, e.g. 2cba')
Truth table33%1/3
A || B
A= shift()B= croak('Croak on passing pdbid, e.g. 2cba')
| |||||||||||||||||||||||||||||
| 39 | 0 | my ($file) = $self->getstore_pdbid($pdbid); | |||||||||||||||||||||||||||
| 40 | 0 | return $self->read_file_mol($file); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub read_file_push_coords_mol { | ||||||||||||||||||||||||||||
| 44 | 5 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
read_file_push_coords_mol: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 45 | 5 | my $file = shift; | |||||||||||||||||||||||||||
| 46 | 5 | ▶ | my $mol = shift or croak "must pass molecule to add coords to"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 4 | my @atoms = $self->read_file_atoms($file); | |||||||||||||||||||||||||||
| 49 | 4 | my @matoms = $mol->all_atoms; | |||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 4 | ▶ | if ( scalar(@matoms) != scalar(@atoms) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | 1 | croak "file_push_coords_mol> number of atoms not same"; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | 3 | foreach my $i ( 0 .. $#atoms ) { | |||||||||||||||||||||||||||
| 55 | 117 | ▶ | if ( $matoms[$i]->Z != $atoms[$i]->Z ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 1 | croak "file_push_coords_mol> atom mismatch"; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | 116 | $matoms[$i]->push_coords($_) foreach ( $atoms[$i]->all_coords ); | |||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | sub read_pdbfile_mol { | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | # keeps the header, and a map of model_ids | ||||||||||||||||||||||||||||
| 65 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
read_pdbfile_mol: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 1 | my $file = shift; | |||||||||||||||||||||||||||
| 67 | 1 | my ( $header, $atoms, $model_ids ) = $self->read_file_pdb_parts($file); | |||||||||||||||||||||||||||
| 68 | return ( | ||||||||||||||||||||||||||||
| 69 | 1 | HackaMol::Molecule->new( | |||||||||||||||||||||||||||
| 70 | name => $file, | ||||||||||||||||||||||||||||
| 71 | atoms => $atoms, | ||||||||||||||||||||||||||||
| 72 | info => $header, | ||||||||||||||||||||||||||||
| 73 | model_ids => $model_ids | ||||||||||||||||||||||||||||
| 74 | ) | ||||||||||||||||||||||||||||
| 75 | ); | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | sub read_file_mol { | ||||||||||||||||||||||||||||
| 79 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
read_file_mol: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 80 | 6 | my $file = shift; | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 6 | my @atoms = $self->read_file_atoms($file); | |||||||||||||||||||||||||||
| 83 | 6 | my $name = $file; | |||||||||||||||||||||||||||
| 84 | 6 | return ( HackaMol::Molecule->new( name => $name, atoms => [@atoms] ) ); | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | sub read_string_mol { | ||||||||||||||||||||||||||||
| 88 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
read_string_mol: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 89 | 6 | my $string = shift; | |||||||||||||||||||||||||||
| 90 | 6 | ▶ | my $format = shift or croak "must pass format: xyz, pdb, pdbqt, zmat, yaml"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 6 | my @atoms = $self->read_string_atoms( $string, $format ); | |||||||||||||||||||||||||||
| 93 | 6 | my $name = $format . ".mol"; | |||||||||||||||||||||||||||
| 94 | 6 | return ( HackaMol::Molecule->new( name => $name, atoms => [@atoms] ) ); | |||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | sub build_bonds { | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | #take a list of n, atoms; walk down list and generate bonds | ||||||||||||||||||||||||||||
| 100 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
build_bonds: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 101 | 4 | my @atoms = @_; | |||||||||||||||||||||||||||
| 102 | 4 | ▶ | croak "<2 atoms passed to build_bonds" unless ( @atoms > 1 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | 3 | my @bonds; | |||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | # build the bonds | ||||||||||||||||||||||||||||
| 106 | 3 | my $k = 0; | |||||||||||||||||||||||||||
| 107 | 3 | ▶ | while ( $k + 1 <= $#atoms ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 108 | my $name = | ||||||||||||||||||||||||||||
| 109 | 177 | join( "_", map { _name_resid( $_, 'B' ) } @atoms[ $k .. $k + 1 ] ); | |||||||||||||||||||||||||||
| 110 | 177 | push @bonds, | |||||||||||||||||||||||||||
| 111 | HackaMol::Bond->new( | ||||||||||||||||||||||||||||
| 112 | name => $name, | ||||||||||||||||||||||||||||
| 113 | atoms => [ @atoms[ $k, $k + 1 ] ] | ||||||||||||||||||||||||||||
| 114 | ); | ||||||||||||||||||||||||||||
| 115 | 177 | $k++; | |||||||||||||||||||||||||||
| 116 | } | ||||||||||||||||||||||||||||
| 117 | 3 | return (@bonds); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||
| 120 | sub build_angles { | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | #take a list of n, atoms; walk down list and generate angles | ||||||||||||||||||||||||||||
| 123 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
build_angles: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 124 | 4 | my @atoms = @_; | |||||||||||||||||||||||||||
| 125 | 4 | ▶ | croak "<3 atoms passed to build_angles" unless ( @atoms > 2 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 126 | 3 | my @angles; | |||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | # build the angles | ||||||||||||||||||||||||||||
| 129 | 3 | my $k = 0; | |||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||
| 131 | 3 | ▶ | while ( $k + 2 <= $#atoms ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | my $name = | ||||||||||||||||||||||||||||
| 133 | 174 | join( "_", map { _name_resid( $_, 'A' ) } @atoms[ $k .. $k + 2 ] ); | |||||||||||||||||||||||||||
| 134 | 174 | push @angles, | |||||||||||||||||||||||||||
| 135 | HackaMol::Angle->new( | ||||||||||||||||||||||||||||
| 136 | name => $name, | ||||||||||||||||||||||||||||
| 137 | atoms => [ @atoms[ $k .. $k + 2 ] ] | ||||||||||||||||||||||||||||
| 138 | ); | ||||||||||||||||||||||||||||
| 139 | 174 | $k++; | |||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||
| 141 | 3 | return (@angles); | |||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | sub _name_resid { | ||||||||||||||||||||||||||||
| 145 | 1560 | ▶ | my $atom = shift; | ||||||||||||||||||||||||||
|
Subroutine
_name_resid: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 146 | 1560 | my $default = shift; | |||||||||||||||||||||||||||
| 147 | 1560 | ▶ | return ( $default . $atom->resid ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 148 | unless $atom->has_name; # this comes up when undefined atoms are passed | ||||||||||||||||||||||||||||
| 149 | 1040 | return ( $atom->name . $atom->resid ); | |||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||
| 152 | sub build_dihedrals { | ||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||
| 154 | #take a list of n, atoms; walk down list and generate dihedrals | ||||||||||||||||||||||||||||
| 155 | 4 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
build_dihedrals: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 156 | 4 | my @atoms = @_; | |||||||||||||||||||||||||||
| 157 | 4 | ▶ | croak "<4 atoms passed to build_dihedrals" unless ( @atoms > 3 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 158 | 3 | my @dihedrals; | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | # build the dihedrals | ||||||||||||||||||||||||||||
| 161 | 3 | my $k = 0; | |||||||||||||||||||||||||||
| 162 | 3 | ▶ | while ( $k + 3 <= $#atoms ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 163 | my $name = | ||||||||||||||||||||||||||||
| 164 | 171 | join( "_", map { _name_resid( $_, 'D' ) } @atoms[ $k .. $k + 3 ] ); | |||||||||||||||||||||||||||
| 165 | 171 | push @dihedrals, | |||||||||||||||||||||||||||
| 166 | HackaMol::Dihedral->new( | ||||||||||||||||||||||||||||
| 167 | name => $name, | ||||||||||||||||||||||||||||
| 168 | atoms => [ @atoms[ $k .. $k + 3 ] ] | ||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||
| 170 | 171 | $k++; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | 3 | return (@dihedrals); | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | sub group_by_atom_attr { | ||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||
| 177 | # group atoms by attribute | ||||||||||||||||||||||||||||
| 178 | # Z, name, bond_count, etc. | ||||||||||||||||||||||||||||
| 179 | 16 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
group_by_atom_attr: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 180 | 16 | my $attr = shift; | |||||||||||||||||||||||||||
| 181 | 16 | my @atoms = @_; | |||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 16 | my %group; | |||||||||||||||||||||||||||
| 184 | 16 | foreach my $atom (@atoms) { | |||||||||||||||||||||||||||
| 185 | 1520 | push @{ $group{ $atom->$attr } }, $atom; | |||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||
| 188 | my @atomgroups = | ||||||||||||||||||||||||||||
| 189 | 16 | map { HackaMol::AtomGroup->new( atoms => $group{$_} ) } sort | |||||||||||||||||||||||||||
| 190 | keys(%group); | ||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||
| 192 | 16 | return (@atomgroups); | |||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||
| 196 | sub group_by_atom_attrs { | ||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||
| 198 | # group atoms by attributes | ||||||||||||||||||||||||||||
| 199 | # Z, name, bond_count, etc. | ||||||||||||||||||||||||||||
| 200 | # keep splitting the groups until there are no more attributes | ||||||||||||||||||||||||||||
| 201 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
group_by_atom_attrs: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 202 | 1 | my @attrs = @{ +shift }; | |||||||||||||||||||||||||||
| 203 | 1 | my @atoms = @_; | |||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||
| 205 | 1 | ▶ | return () unless @attrs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 1 | my @groups = ( HackaMol::AtomGroup->new( atoms => [@atoms] ) ); | |||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||
| 209 | 1 | foreach my $attr (@attrs) { | |||||||||||||||||||||||||||
| 210 | 2 | my @local_groups; | |||||||||||||||||||||||||||
| 211 | 2 | foreach my $group (@groups) { | |||||||||||||||||||||||||||
| 212 | 13 | push @local_groups, | |||||||||||||||||||||||||||
| 213 | $self->group_by_atom_attr( $attr, $group->all_atoms ); | ||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||
| 215 | 2 | @groups = @local_groups; | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 1 | return (@groups); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | sub mol_disulfide_bonds { | ||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||
| 224 | # take atom group | ||||||||||||||||||||||||||||
| 225 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
mol_disulfide_bonds: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||
| 226 | 1 | my $mol = shift; | |||||||||||||||||||||||||||
| 227 | 1 | my $fudge = shift; | |||||||||||||||||||||||||||
| 228 | 1 | ▶ | $fudge = 0.15 unless defined($fudge); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||
| 230 | 1 | my @sulfs = $mol->select_group("Z 16")->all_atoms; | |||||||||||||||||||||||||||
| 231 | 1 | ▶ | return unless @sulfs; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 232 | 1 | my $dcut = 2 * $sulfs[0]->covalent_radius + $fudge; | |||||||||||||||||||||||||||
| 233 | 1 | my $nm = "S-S"; | |||||||||||||||||||||||||||
| 234 | 1 | my $count = 1; | |||||||||||||||||||||||||||
| 235 | 1 | my @bonds = (); | |||||||||||||||||||||||||||
| 236 | 1 | foreach my $is ( 0 .. $#sulfs ) { | |||||||||||||||||||||||||||
| 237 | 27 | my $at_i = $sulfs[$is]; | |||||||||||||||||||||||||||
| 238 | 27 | foreach my $js ( $is + 1 .. $#sulfs ) { | |||||||||||||||||||||||||||
| 239 | 351 | my $at_j = $sulfs[$js]; | |||||||||||||||||||||||||||
| 240 | 351 | my $dist = $at_j->distance($at_i); | |||||||||||||||||||||||||||
| 241 | 351 | ▶ | if ( $dist <= $dcut ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 242 | 9 | push @bonds, | |||||||||||||||||||||||||||
| 243 | HackaMol::Bond->new( | ||||||||||||||||||||||||||||
| 244 | name => $nm . "_" . $count++, | ||||||||||||||||||||||||||||
| 245 | atoms => [ $at_i, $at_j ], | ||||||||||||||||||||||||||||
| 246 | ); | ||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | 1 | return @bonds; | |||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||
| 252 | |||||||||||||||||||||||||||||
| 253 | sub find_disulfide_bonds { | ||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||
| 255 | # to be deprecated | ||||||||||||||||||||||||||||
| 256 | # works fine for single disulfide bonds | ||||||||||||||||||||||||||||
| 257 | # but does not | ||||||||||||||||||||||||||||
| 258 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
find_disulfide_bonds: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | 1 | my @sulf = grep { $_->Z == 16 } @_; | |||||||||||||||||||||||||||
| 261 | 1 | my @ss = $self->find_bonds_brute( | |||||||||||||||||||||||||||
| 262 | bond_atoms => [@sulf], | ||||||||||||||||||||||||||||
| 263 | candidates => [@sulf], | ||||||||||||||||||||||||||||
| 264 | fudge => 0.15, # 0.45 is too large | ||||||||||||||||||||||||||||
| 265 | max_bonds => 1, | ||||||||||||||||||||||||||||
| 266 | ); | ||||||||||||||||||||||||||||
| 267 | 1 | return @ss; | |||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | sub find_bonds_brute { | ||||||||||||||||||||||||||||
| 271 | 6 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
find_bonds_brute: called CC=10 SCAR=23.0
Pod
documented
| |||||||||||||||||||||||||||||
| 272 | 6 | my %args = @_; | |||||||||||||||||||||||||||
| 273 | 6 | my @bond_atoms = @{ $args{bond_atoms} }; | |||||||||||||||||||||||||||
| 274 | 6 | my @atoms = @{ $args{candidates} }; | |||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 6 | my $fudge = 0.45; | |||||||||||||||||||||||||||
| 277 | 6 | my $max_bonds = 99; | |||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 6 | ▶ | $fudge = $args{fudge} if ( exists( $args{fudge} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 280 | 6 | ▶ | $max_bonds = $args{max_bonds} if ( exists( $args{max_bonds} ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||
| 282 | 6 | my @init_bond_counts = map { $_->bond_count } ( @bond_atoms, @atoms ); | |||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||
| 284 | 6 | my @bonds; | |||||||||||||||||||||||||||
| 285 | my %name; | ||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||
| 287 | 6 | foreach my $at_i (@bond_atoms) { | |||||||||||||||||||||||||||
| 288 | 37 | ▶ | next if ( $at_i->bond_count >= $max_bonds ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | 28 | my $cov_i = $at_i->covalent_radius; | |||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||
| 291 | 28 | foreach my $at_j (@atoms) { | |||||||||||||||||||||||||||
| 292 | 1030 | ▶ | next if ( refaddr($at_i) == refaddr($at_j) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 293 | 1002 | ▶ | next if ( $at_j->bond_count >= $max_bonds ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 294 | 844 | my $cov_j = $at_j->covalent_radius; | |||||||||||||||||||||||||||
| 295 | 844 | my $dist = $at_j->distance($at_i); | |||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||
| 297 | 844 | ▶ | if ( $dist <= $cov_i + $cov_j + $fudge ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 298 | 33 | my $nm = $at_i->symbol . "-" . $at_j->symbol; | |||||||||||||||||||||||||||
| 299 | 33 | $name{$nm}++; | |||||||||||||||||||||||||||
| 300 | push @bonds, | ||||||||||||||||||||||||||||
| 301 | HackaMol::Bond->new( | ||||||||||||||||||||||||||||
| 302 | 33 | name => "$nm\_" . $name{$nm}, | |||||||||||||||||||||||||||
| 303 | atoms => [ $at_i, $at_j ], | ||||||||||||||||||||||||||||
| 304 | ); | ||||||||||||||||||||||||||||
| 305 | 33 | $at_i->inc_bond_count; | |||||||||||||||||||||||||||
| 306 | 33 | $at_j->inc_bond_count; | |||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 6 | my $i = 0; | |||||||||||||||||||||||||||
| 313 | 6 | foreach my $at ( @bond_atoms, @atoms ) { | |||||||||||||||||||||||||||
| 314 | 338 | $at->reset_bond_count; | |||||||||||||||||||||||||||
| 315 | 338 | $at->inc_bond_count( $init_bond_counts[$i] ); | |||||||||||||||||||||||||||
| 316 | 338 | $i++; | |||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||
| 318 | 6 | return (@bonds); | |||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||
| 322 | sub group_rot { | ||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||
| 324 | # no pod yet | ||||||||||||||||||||||||||||
| 325 | # this method walks out from the two atoms in a bond and returns a group | ||||||||||||||||||||||||||||
| 326 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
group_rot: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 327 | 0 | my $mol = shift; | |||||||||||||||||||||||||||
| 328 | 0 | my $bond = shift; | |||||||||||||||||||||||||||
| 329 | 0 | my $iba = $bond->get_atoms(0)->iatom; | |||||||||||||||||||||||||||
| 330 | 0 | my $ibb = $bond->get_atoms(1)->iatom; | |||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||
| 332 | 0 | my $init = { | |||||||||||||||||||||||||||
| 333 | $iba => 1, | ||||||||||||||||||||||||||||
| 334 | $ibb => 1, | ||||||||||||||||||||||||||||
| 335 | }; | ||||||||||||||||||||||||||||
| 336 | 0 | my $root = $ibb; | |||||||||||||||||||||||||||
| 337 | 0 | my $rotation_indices = _qrotatable( $mol->atoms, $ibb, $init ); | |||||||||||||||||||||||||||
| 338 | 0 | delete( $rotation_indices->{$iba} ); | |||||||||||||||||||||||||||
| 339 | 0 | delete( $rotation_indices->{$ibb} ); | |||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | return ( | ||||||||||||||||||||||||||||
| 342 | HackaMol::AtomGroup->new( | ||||||||||||||||||||||||||||
| 343 | atoms => [ | ||||||||||||||||||||||||||||
| 344 | 0 | map { $mol->get_atoms($_) } | |||||||||||||||||||||||||||
| 345 | 0 | keys %{$rotation_indices} | |||||||||||||||||||||||||||
| 346 | ] | ||||||||||||||||||||||||||||
| 347 | ) | ||||||||||||||||||||||||||||
| 348 | ); | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | sub superpose_rt { | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | # args: two HackaMol::AtomGroup or HackaMol::Molecule with the same number of atoms | ||||||||||||||||||||||||||||
| 355 | # the atoms are assumed to be in the same order, that's it! | ||||||||||||||||||||||||||||
| 356 | # | ||||||||||||||||||||||||||||
| 357 | # uses all vectors (mvr) in group to calculate the rotation matrix, and translation vector | ||||||||||||||||||||||||||||
| 358 | # needed to superpose the second group on to the first group. | ||||||||||||||||||||||||||||
| 359 | # | ||||||||||||||||||||||||||||
| 360 | # a typical workflow will run this to get the rotation and translation and then the AtomGroupRole | ||||||||||||||||||||||||||||
| 361 | # rotate_translate method to actually do the coordinate transformation. | ||||||||||||||||||||||||||||
| 362 | # | ||||||||||||||||||||||||||||
| 363 | # the algorithm is lifted from Bio::PDB::Structure, which in turn implements | ||||||||||||||||||||||||||||
| 364 | # method from S. Kearsley, Acta Cryst. A45, 208-210 1989 | ||||||||||||||||||||||||||||
| 365 | # may not be very fast. better suited to PDL | ||||||||||||||||||||||||||||
| 366 | # | ||||||||||||||||||||||||||||
| 367 | # returns: | ||||||||||||||||||||||||||||
| 368 | # 1. rotation matrix [3 rows, each is a MVR , e.g. x' = row_1 * xyz] | ||||||||||||||||||||||||||||
| 369 | # 2. translation vector (MVR) | ||||||||||||||||||||||||||||
| 370 | # 3. rmsd | ||||||||||||||||||||||||||||
| 371 | # | ||||||||||||||||||||||||||||
| 372 | 1 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
superpose_rt: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 373 | 1 | my $g2 = shift; # switch order, function here vs method in Bio::PDB | |||||||||||||||||||||||||||
| 374 | 1 | my $g1 = shift; | |||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | 1 | my $nrd1 = $g1->count_atoms; | |||||||||||||||||||||||||||
| 377 | 1 | my $nrd2 = $g2->count_atoms; | |||||||||||||||||||||||||||
| 378 | 1 | ▶ | die "superpose error: groups must have same number of atoms\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$nrd1 == $nrd2 and $nrd1 > 0
MC/DC0%0/2
$nrd1 == $nrd2 and $nrd1 > 0
$nrd1 == $nrd2
$nrd1 > 0
Truth table33%1/3
A and B
A= $nrd1 == $nrd2B= $nrd1 > 0
| |||||||||||||||||||||||||||||
| 379 | unless ( $nrd1 == $nrd2 && $nrd1 > 0 ); | ||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||
| 381 | 1 | my ( $x1, $y1, $z1 ); | |||||||||||||||||||||||||||
| 382 | 1 | my ( $x2, $y2, $z2 ); | |||||||||||||||||||||||||||
| 383 | 1 | my ( $xm, $ym, $zm ); | |||||||||||||||||||||||||||
| 384 | 1 | my ( $xp, $yp, $zp ); | |||||||||||||||||||||||||||
| 385 | 1 | my ( $Sxmxm, $Sxpxp, $Symym, $Sypyp, $Szmzm, $Szpzp ); | |||||||||||||||||||||||||||
| 386 | 1 | my ( $Sxmym, $Sxmyp, $Sxpym, $Sxpyp ); | |||||||||||||||||||||||||||
| 387 | 1 | my ( $Sxmzm, $Sxmzp, $Sxpzm, $Sxpzp ); | |||||||||||||||||||||||||||
| 388 | 1 | my ( $Symzm, $Symzp, $Sypzm, $Sypzp ); | |||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | 1 | my $gc1 = $g1->center; | |||||||||||||||||||||||||||
| 391 | 1 | my $gc2 = $g2->center; # these are MVRs | |||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||
| 393 | 1 | my @mvr1 = map { $_->xyz - $gc1 } $g1->all_atoms; | |||||||||||||||||||||||||||
| 394 | 1 | my @mvr2 = map { $_->xyz - $gc2 } $g2->all_atoms; | |||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 1 | foreach my $i ( 0 .. $nrd1 - 1 ) { | |||||||||||||||||||||||||||
| 397 | 7 | ( $x1, $y1, $z1 ) = @{ $mvr1[$i] }; | |||||||||||||||||||||||||||
| 398 | 7 | ( $x2, $y2, $z2 ) = @{ $mvr2[$i] }; | |||||||||||||||||||||||||||
| 399 | 7 | $xm = ( $x1 - $x2 ); | |||||||||||||||||||||||||||
| 400 | 7 | $xp = ( $x1 + $x2 ); | |||||||||||||||||||||||||||
| 401 | 7 | $ym = ( $y1 - $y2 ); | |||||||||||||||||||||||||||
| 402 | 7 | $yp = ( $y1 + $y2 ); | |||||||||||||||||||||||||||
| 403 | 7 | $zm = ( $z1 - $z2 ); | |||||||||||||||||||||||||||
| 404 | 7 | $zp = ( $z1 + $z2 ); | |||||||||||||||||||||||||||
| 405 | |||||||||||||||||||||||||||||
| 406 | 7 | $Sxmxm += $xm * $xm; | |||||||||||||||||||||||||||
| 407 | 7 | $Sxpxp += $xp * $xp; | |||||||||||||||||||||||||||
| 408 | 7 | $Symym += $ym * $ym; | |||||||||||||||||||||||||||
| 409 | 7 | $Sypyp += $yp * $yp; | |||||||||||||||||||||||||||
| 410 | 7 | $Szmzm += $zm * $zm; | |||||||||||||||||||||||||||
| 411 | 7 | $Szpzp += $zp * $zp; | |||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 7 | $Sxmym += $xm * $ym; | |||||||||||||||||||||||||||
| 414 | 7 | $Sxmyp += $xm * $yp; | |||||||||||||||||||||||||||
| 415 | 7 | $Sxpym += $xp * $ym; | |||||||||||||||||||||||||||
| 416 | 7 | $Sxpyp += $xp * $yp; | |||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 7 | $Sxmzm += $xm * $zm; | |||||||||||||||||||||||||||
| 419 | 7 | $Sxmzp += $xm * $zp; | |||||||||||||||||||||||||||
| 420 | 7 | $Sxpzm += $xp * $zm; | |||||||||||||||||||||||||||
| 421 | 7 | $Sxpzp += $xp * $zp; | |||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | 7 | $Symzm += $ym * $zm; | |||||||||||||||||||||||||||
| 424 | 7 | $Symzp += $ym * $zp; | |||||||||||||||||||||||||||
| 425 | 7 | $Sypzm += $yp * $zm; | |||||||||||||||||||||||||||
| 426 | 7 | $Sypzp += $yp * $zp; | |||||||||||||||||||||||||||
| 427 | } | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 1 | my @m; | |||||||||||||||||||||||||||
| 430 | 1 | $m[0] = $Sxmxm + $Symym + $Szmzm; | |||||||||||||||||||||||||||
| 431 | 1 | $m[1] = $Sypzm - $Symzp; | |||||||||||||||||||||||||||
| 432 | 1 | $m[2] = $Sxmzp - $Sxpzm; | |||||||||||||||||||||||||||
| 433 | 1 | $m[3] = $Sxpym - $Sxmyp; | |||||||||||||||||||||||||||
| 434 | 1 | $m[4] = $m[1]; | |||||||||||||||||||||||||||
| 435 | 1 | $m[5] = $Sypyp + $Szpzp + $Sxmxm; | |||||||||||||||||||||||||||
| 436 | 1 | $m[6] = $Sxmym - $Sxpyp; | |||||||||||||||||||||||||||
| 437 | 1 | $m[7] = $Sxmzm - $Sxpzp; | |||||||||||||||||||||||||||
| 438 | 1 | $m[8] = $m[2]; | |||||||||||||||||||||||||||
| 439 | 1 | $m[9] = $m[6]; | |||||||||||||||||||||||||||
| 440 | 1 | $m[10] = $Sxpxp + $Szpzp + $Symym; | |||||||||||||||||||||||||||
| 441 | 1 | $m[11] = $Symzm - $Sypzp; | |||||||||||||||||||||||||||
| 442 | 1 | $m[12] = $m[3]; | |||||||||||||||||||||||||||
| 443 | 1 | $m[13] = $m[7]; | |||||||||||||||||||||||||||
| 444 | 1 | $m[14] = $m[11]; | |||||||||||||||||||||||||||
| 445 | 1 | $m[15] = $Sxpxp + $Sypyp + $Szmzm; | |||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||
| 447 | #compute the egienvectors and eigenvalues of the matrix | ||||||||||||||||||||||||||||
| 448 | 1 | my ( $revec, $reval ) = &__diagonalize(@m); | |||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | #the smallest eigenvalue is the rmsd for the optimal alignment | ||||||||||||||||||||||||||||
| 451 | 1 | my $rmsd = sqrt( abs( $reval->[0] ) / $nrd1 ); | |||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | #fetch the optimal quaternion | ||||||||||||||||||||||||||||
| 454 | 1 | my @q; | |||||||||||||||||||||||||||
| 455 | 1 | $q[0] = $revec->[0][0]; | |||||||||||||||||||||||||||
| 456 | 1 | $q[1] = $revec->[1][0]; | |||||||||||||||||||||||||||
| 457 | 1 | $q[2] = $revec->[2][0]; | |||||||||||||||||||||||||||
| 458 | 1 | $q[3] = $revec->[3][0]; | |||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||
| 460 | #construct the rotation matrix given by the quaternion | ||||||||||||||||||||||||||||
| 461 | 1 | my @mt; | |||||||||||||||||||||||||||
| 462 | 1 | $mt[0] = $q[0] * $q[0] + $q[1] * $q[1] - $q[2] * $q[2] - $q[3] * $q[3]; | |||||||||||||||||||||||||||
| 463 | 1 | $mt[1] = 2.0 * ( $q[1] * $q[2] - $q[0] * $q[3] ); | |||||||||||||||||||||||||||
| 464 | 1 | $mt[2] = 2.0 * ( $q[1] * $q[3] + $q[0] * $q[2] ); | |||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | 1 | $mt[3] = 2.0 * ( $q[2] * $q[1] + $q[0] * $q[3] ); | |||||||||||||||||||||||||||
| 467 | 1 | $mt[4] = $q[0] * $q[0] - $q[1] * $q[1] + $q[2] * $q[2] - $q[3] * $q[3]; | |||||||||||||||||||||||||||
| 468 | 1 | $mt[5] = 2.0 * ( $q[2] * $q[3] - $q[0] * $q[1] ); | |||||||||||||||||||||||||||
| 469 | |||||||||||||||||||||||||||||
| 470 | 1 | $mt[6] = 2.0 * ( $q[3] * $q[1] - $q[0] * $q[2] ); | |||||||||||||||||||||||||||
| 471 | 1 | $mt[7] = 2.0 * ( $q[3] * $q[2] + $q[0] * $q[1] ); | |||||||||||||||||||||||||||
| 472 | 1 | $mt[8] = $q[0] * $q[0] - $q[1] * $q[1] - $q[2] * $q[2] + $q[3] * $q[3]; | |||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | #compute the displacement vector | ||||||||||||||||||||||||||||
| 475 | 1 | my @vt; | |||||||||||||||||||||||||||
| 476 | 1 | $vt[0] = | |||||||||||||||||||||||||||
| 477 | $gc2->[0] - $mt[0] * $gc1->[0] - $mt[1] * $gc1->[1] - $mt[2] * $gc1->[2]; | ||||||||||||||||||||||||||||
| 478 | 1 | $vt[1] = | |||||||||||||||||||||||||||
| 479 | $gc2->[1] - $mt[3] * $gc1->[0] - $mt[4] * $gc1->[1] - $mt[5] * $gc1->[2]; | ||||||||||||||||||||||||||||
| 480 | 1 | $vt[2] = | |||||||||||||||||||||||||||
| 481 | $gc2->[2] - $mt[6] * $gc1->[0] - $mt[7] * $gc1->[1] - $mt[8] * $gc1->[2]; | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | 1 | return ( [ V( @mt[ 0, 1, 2 ] ), V( @mt[ 3, 4, 5 ] ), V( @mt[ 6, 7, 8 ] ) ], | |||||||||||||||||||||||||||
| 484 | V(@vt), $rmsd ); | ||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||
| 487 | sub rmsd { | ||||||||||||||||||||||||||||
| 488 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
rmsd: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||
| 489 | 0 | my $g1 = shift; # switch order, function here vs method in Bio::PDB | |||||||||||||||||||||||||||
| 490 | 0 | my $g2 = shift; | |||||||||||||||||||||||||||
| 491 | 0 | my $w = shift; | |||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||
| 493 | 0 | my $nrd1 = $g1->count_atoms; | |||||||||||||||||||||||||||
| 494 | 0 | my $nrd2 = $g2->count_atoms; | |||||||||||||||||||||||||||
| 495 | 0 | ▶ | die "rmsd error: groups must have same number of atoms\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$nrd1 == $nrd2 and $nrd1 > 0
MC/DC0%0/2
$nrd1 == $nrd2 and $nrd1 > 0
$nrd1 == $nrd2
$nrd1 > 0
Truth table0%0/3
A and B
A= $nrd1 == $nrd2B= $nrd1 > 0
| |||||||||||||||||||||||||||||
| 496 | unless ( $nrd1 == $nrd2 && $nrd1 > 0 ); | ||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||
| 498 | 0 | my @w; | |||||||||||||||||||||||||||
| 499 | 0 | ▶ | if ( defined($w) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 500 | 0 | @w = @{$w}; | |||||||||||||||||||||||||||
| 501 | } | ||||||||||||||||||||||||||||
| 502 | else { | ||||||||||||||||||||||||||||
| 503 | 0 | @w = map { 1 } 0 .. $nrd1 - 1; | |||||||||||||||||||||||||||
| 504 | } | ||||||||||||||||||||||||||||
| 505 | |||||||||||||||||||||||||||||
| 506 | 0 | ▶ | die "rmsd error: atom array weight must have same dimension as groups\n" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 507 | unless ( $nrd1 == scalar(@w) ); | ||||||||||||||||||||||||||||
| 508 | 0 | my $sum_weights = | |||||||||||||||||||||||||||
| 509 | 0; # will be same as number of atoms if no weights are defined | ||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||
| 511 | 0 | $sum_weights += $_ foreach @w; | |||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||
| 513 | 0 | my @xyz_1 = map { $_->xyz } $g1->all_atoms; | |||||||||||||||||||||||||||
| 514 | 0 | my @xyz_2 = map { $_->xyz } $g2->all_atoms; | |||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||
| 516 | 0 | my $sqr_dev = 0; | |||||||||||||||||||||||||||
| 517 | 0 | $sqr_dev += $w[$_] * $xyz_1[$_]->dist2( $xyz_2[$_] ) foreach 0 .. $#xyz_1; | |||||||||||||||||||||||||||
| 518 | 0 | return sqrt( $sqr_dev / $sum_weights ); | |||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||
| 521 | sub _qrotatable { | ||||||||||||||||||||||||||||
| 522 | 0 | ▶ | my $atoms = shift; | ||||||||||||||||||||||||||
|
Subroutine
_qrotatable: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||
| 523 | 0 | my $iroot = shift; | |||||||||||||||||||||||||||
| 524 | 0 | my $visited = shift; | |||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||
| 526 | 0 | $visited->{$iroot}++; | |||||||||||||||||||||||||||
| 527 | |||||||||||||||||||||||||||||
| 528 | 0 | ▶ | if ( scalar( keys %$visited ) > 80 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 529 | 0 | carp "search too deep. exiting recursion"; | |||||||||||||||||||||||||||
| 530 | 0 | return; | |||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||
| 533 | 0 | my @cands; | |||||||||||||||||||||||||||
| 534 | 0 | foreach my $at (@$atoms) { | |||||||||||||||||||||||||||
| 535 | 0 | ▶ | push @cands, $at unless ( grep { $at->iatom == $_ } keys %{$visited} ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 536 | } | ||||||||||||||||||||||||||||
| 537 | |||||||||||||||||||||||||||||
| 538 | #not calling in object context, hence the dummy 'self' | ||||||||||||||||||||||||||||
| 539 | 0 | my @bonds = find_bonds_brute( | |||||||||||||||||||||||||||
| 540 | 'self', | ||||||||||||||||||||||||||||
| 541 | bond_atoms => [ $atoms->[$iroot] ], | ||||||||||||||||||||||||||||
| 542 | candidates => [@cands], | ||||||||||||||||||||||||||||
| 543 | fudge => 0.45, | ||||||||||||||||||||||||||||
| 544 | ); | ||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||
| 546 | 0 | foreach my $cand ( map { $_->get_atoms(1) } @bonds ) { | |||||||||||||||||||||||||||
| 547 | 0 | ▶ | next if $visited->{ $cand->iatom }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 548 | 0 | my $visited = _qrotatable( $atoms, $cand->iatom, $visited ); | |||||||||||||||||||||||||||
| 549 | } | ||||||||||||||||||||||||||||
| 550 | 0 | return ($visited); | |||||||||||||||||||||||||||
| 551 | } | ||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||
| 553 | #Jacobi diagonalizer | ||||||||||||||||||||||||||||
| 554 | sub __diagonalize { | ||||||||||||||||||||||||||||
| 555 | 1 | ▶ | my ( $onorm, $dnorm ); | ||||||||||||||||||||||||||
|
Subroutine
__diagonalize: called CC=22 SCAR=47.0
| |||||||||||||||||||||||||||||
| 556 | 1 | my ( $b, $dma, $q, $t, $c, $s ); | |||||||||||||||||||||||||||
| 557 | 1 | my ( $atemp, $vtemp, $dtemp ); | |||||||||||||||||||||||||||
| 558 | 1 | my ( $i, $j, $k, $l ); | |||||||||||||||||||||||||||
| 559 | 1 | my @a; | |||||||||||||||||||||||||||
| 560 | 1 | my @v; | |||||||||||||||||||||||||||
| 561 | 1 | my @d; | |||||||||||||||||||||||||||
| 562 | 1 | my $nrot = 30; #number of sweeps | |||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||
| 564 | 1 | ▶ | for ( $i = 0 ; $i < 4 ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 565 | 4 | ▶ | for ( $j = 0 ; $j < 4 ; $j++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 566 | 16 | $a[$i][$j] = $_[ 4 * $i + $j ]; | |||||||||||||||||||||||||||
| 567 | 16 | $v[$i][$j] = 0.0; | |||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||
| 569 | } | ||||||||||||||||||||||||||||
| 570 | |||||||||||||||||||||||||||||
| 571 | 1 | ▶ | for ( $j = 0 ; $j <= 3 ; $j++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 572 | 4 | $v[$j][$j] = 1.0; | |||||||||||||||||||||||||||
| 573 | 4 | $d[$j] = $a[$j][$j]; | |||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||
| 576 | 1 | ▶ | for ( $l = 1 ; $l <= $nrot ; $l++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 577 | 1 | $dnorm = 0.0; | |||||||||||||||||||||||||||
| 578 | 1 | $onorm = 0.0; | |||||||||||||||||||||||||||
| 579 | 1 | ▶ | for ( $j = 0 ; $j <= 3 ; $j++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 580 | 4 | $dnorm += abs( $d[$j] ); | |||||||||||||||||||||||||||
| 581 | 4 | ▶ | for ( $i = 0 ; $i <= $j - 1 ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 582 | 6 | $onorm += abs( $a[$i][$j] ); | |||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||
| 584 | } | ||||||||||||||||||||||||||||
| 585 | 1 | ▶ | last if ( ( $onorm / $dnorm ) <= 1.0e-12 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 586 | 0 | ▶ | for ( $j = 1 ; $j <= 3 ; $j++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 587 | 0 | ▶ | for ( $i = 0 ; $i <= $j - 1 ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 588 | 0 | $b = $a[$i][$j]; | |||||||||||||||||||||||||||
| 589 | 0 | ▶ | if ( abs($b) > 0.0 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 590 | 0 | $dma = $d[$j] - $d[$i]; | |||||||||||||||||||||||||||
| 591 | 0 | ▶ | if ( ( abs($dma) + abs($b) ) <= abs($dma) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 592 | 0 | $t = $b / $dma; | |||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||
| 594 | else { | ||||||||||||||||||||||||||||
| 595 | 0 | $q = 0.5 * $dma / $b; | |||||||||||||||||||||||||||
| 596 | 0 | $t = 1.0 / ( abs($q) + sqrt( 1.0 + $q * $q ) ); | |||||||||||||||||||||||||||
| 597 | 0 | ▶ | $t *= -1.0 if ( $q < 0.0 ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||
| 599 | 0 | $c = 1.0 / sqrt( $t * $t + 1.0 ); | |||||||||||||||||||||||||||
| 600 | 0 | $s = $t * $c; | |||||||||||||||||||||||||||
| 601 | 0 | $a[$i][$j] = 0.0; | |||||||||||||||||||||||||||
| 602 | 0 | ▶ | for ( $k = 0 ; $k <= $i - 1 ; $k++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 603 | 0 | $atemp = $c * $a[$k][$i] - $s * $a[$k][$j]; | |||||||||||||||||||||||||||
| 604 | 0 | $a[$k][$j] = $s * $a[$k][$i] + $c * $a[$k][$j]; | |||||||||||||||||||||||||||
| 605 | 0 | $a[$k][$i] = $atemp; | |||||||||||||||||||||||||||
| 606 | } | ||||||||||||||||||||||||||||
| 607 | 0 | ▶ | for ( $k = $i + 1 ; $k <= $j - 1 ; $k++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 608 | 0 | $atemp = $c * $a[$i][$k] - $s * $a[$k][$j]; | |||||||||||||||||||||||||||
| 609 | 0 | $a[$k][$j] = $s * $a[$i][$k] + $c * $a[$k][$j]; | |||||||||||||||||||||||||||
| 610 | 0 | $a[$i][$k] = $atemp; | |||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||
| 612 | 0 | ▶ | for ( $k = $j + 1 ; $k <= 3 ; $k++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 613 | 0 | $atemp = $c * $a[$i][$k] - $s * $a[$j][$k]; | |||||||||||||||||||||||||||
| 614 | 0 | $a[$j][$k] = $s * $a[$i][$k] + $c * $a[$j][$k]; | |||||||||||||||||||||||||||
| 615 | 0 | $a[$i][$k] = $atemp; | |||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||
| 617 | 0 | ▶ | for ( $k = 0 ; $k <= 3 ; $k++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 618 | 0 | $vtemp = $c * $v[$k][$i] - $s * $v[$k][$j]; | |||||||||||||||||||||||||||
| 619 | 0 | $v[$k][$j] = $s * $v[$k][$i] + $c * $v[$k][$j]; | |||||||||||||||||||||||||||
| 620 | 0 | $v[$k][$i] = $vtemp; | |||||||||||||||||||||||||||
| 621 | } | ||||||||||||||||||||||||||||
| 622 | 0 | $dtemp = | |||||||||||||||||||||||||||
| 623 | $c * $c * $d[$i] + $s * $s * $d[$j] - 2.0 * $c * $s * $b; | ||||||||||||||||||||||||||||
| 624 | 0 | $d[$j] = | |||||||||||||||||||||||||||
| 625 | $s * $s * $d[$i] + $c * $c * $d[$j] + 2.0 * $c * $s * $b; | ||||||||||||||||||||||||||||
| 626 | 0 | $d[$i] = $dtemp; | |||||||||||||||||||||||||||
| 627 | } | ||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||
| 631 | 1 | $nrot = $l; | |||||||||||||||||||||||||||
| 632 | 1 | ▶ | for ( $j = 0 ; $j <= 2 ; $j++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 633 | 3 | $k = $j; | |||||||||||||||||||||||||||
| 634 | 3 | $dtemp = $d[$k]; | |||||||||||||||||||||||||||
| 635 | 3 | ▶ | for ( $i = $j + 1 ; $i <= 3 ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 636 | 6 | ▶ | if ( $d[$i] < $dtemp ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 637 | 0 | $k = $i; | |||||||||||||||||||||||||||
| 638 | 0 | $dtemp = $d[$k]; | |||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||
| 642 | 3 | ▶ | if ( $k > $j ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 643 | 0 | $d[$k] = $d[$j]; | |||||||||||||||||||||||||||
| 644 | 0 | $d[$j] = $dtemp; | |||||||||||||||||||||||||||
| 645 | 0 | ▶ | for ( $i = 0 ; $i <= 3 ; $i++ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 646 | 0 | $dtemp = $v[$i][$k]; | |||||||||||||||||||||||||||
| 647 | 0 | $v[$i][$k] = $v[$i][$j]; | |||||||||||||||||||||||||||
| 648 | 0 | $v[$i][$j] = $dtemp; | |||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||
| 653 | 1 | return ( \@v, \@d ); | |||||||||||||||||||||||||||
| 654 | } | ||||||||||||||||||||||||||||
| 655 | |||||||||||||||||||||||||||||
| 656 | 11 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||
| 658 | 11 | 1; | |||||||||||||||||||||||||||
| 659 | |||||||||||||||||||||||||||||
| 660 | __END__ | ||||||||||||||||||||||||||||
| 661 | |||||||||||||||||||||||||||||
| 662 | =pod | ||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||
| 664 | =head1 NAME | ||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||
| 666 | HackaMol - HackaMol: Object-Oriented Library for Molecular Hacking | ||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||
| 668 | =head1 VERSION | ||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||
| 670 | version 0.051 | ||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||
| 672 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||
| 674 | The L<HackaMol publication|http://pubs.acs.org/doi/abs/10.1021/ci500359e> has | ||||||||||||||||||||||||||||
| 675 | a more complete description of the library (L<pdf available from researchgate|http://www.researchgate.net/profile/Demian_Riccardi/publication/273778191_HackaMol_an_object-oriented_Modern_Perl_library_for_molecular_hacking_on_multiple_scales/links/550ebec60cf27526109e6ade.pdf>). | ||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||
| 677 | Citation: J. Chem. Inf. Model., 2015, 55, 721 | ||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||
| 679 | Loading the HackaMol library in a script with | ||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||
| 681 | use HackaMol; | ||||||||||||||||||||||||||||
| 682 | |||||||||||||||||||||||||||||
| 683 | provides attributes and methods of a builder class. It also loads all the | ||||||||||||||||||||||||||||
| 684 | classes provided by the core so including them is not necessary, e.g.: | ||||||||||||||||||||||||||||
| 685 | |||||||||||||||||||||||||||||
| 686 | use HackaMol::Atom; | ||||||||||||||||||||||||||||
| 687 | use HackaMol::Bond; | ||||||||||||||||||||||||||||
| 688 | use HackaMol::Angle; | ||||||||||||||||||||||||||||
| 689 | use HackaMol::Dihedral; | ||||||||||||||||||||||||||||
| 690 | use HackaMol::AtomGroup; | ||||||||||||||||||||||||||||
| 691 | use HackaMol::Molecule; | ||||||||||||||||||||||||||||
| 692 | |||||||||||||||||||||||||||||
| 693 | The methods, described below, facilitate the creation of objects from files and | ||||||||||||||||||||||||||||
| 694 | other objects. It is a builder class that evolves more rapidly than the classes for the molecular objects. | ||||||||||||||||||||||||||||
| 695 | For example, the superpose_rt and rmsd methods will likely be moved to a more suitable class or | ||||||||||||||||||||||||||||
| 696 | functional module. | ||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||
| 698 | =head1 METHODS | ||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||
| 700 | =head2 pdbid_mol | ||||||||||||||||||||||||||||
| 701 | |||||||||||||||||||||||||||||
| 702 | one argument: pdbid | ||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||
| 704 | This method will download the pdb, unless it exists, and load it into a | ||||||||||||||||||||||||||||
| 705 | HackaMol::Molecule object. For example, | ||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||
| 707 | my $mol = HackaMol->new->pdbid_mol('2cba'); | ||||||||||||||||||||||||||||
| 708 | |||||||||||||||||||||||||||||
| 709 | =head2 read_file_atoms | ||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||
| 711 | one argument: filename. | ||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||
| 713 | This method parses the file (e.g. file.xyz, file.pdb) and returns an | ||||||||||||||||||||||||||||
| 714 | array of HackaMol::Atom objects. It uses the filename postfix to decide which parser to use. e.g. file.pdb will | ||||||||||||||||||||||||||||
| 715 | trigger the pdb parser. | ||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||
| 717 | =head2 read_file_mol | ||||||||||||||||||||||||||||
| 718 | |||||||||||||||||||||||||||||
| 719 | one argument: filename. | ||||||||||||||||||||||||||||
| 720 | |||||||||||||||||||||||||||||
| 721 | This method parses the file (e.g. file.xyz, file.pdb) and returns a | ||||||||||||||||||||||||||||
| 722 | HackaMol::Molecule object. | ||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||
| 724 | =head2 read_file_push_coords_mol | ||||||||||||||||||||||||||||
| 725 | |||||||||||||||||||||||||||||
| 726 | two arguments: filename and a HackaMol::Molecule object. | ||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||
| 728 | This method reads the coordinates from a file and pushes them into the atoms | ||||||||||||||||||||||||||||
| 729 | contained in the molecule. Thus, the atoms in the molecule and the atoms in | ||||||||||||||||||||||||||||
| 730 | the file must be the same. | ||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||
| 732 | =head2 build_bonds | ||||||||||||||||||||||||||||
| 733 | |||||||||||||||||||||||||||||
| 734 | takes a list of atoms and returns a list of bonds. The bonds are generated for | ||||||||||||||||||||||||||||
| 735 | "list neighbors" by simply stepping through the atom list one at a time. e.g. | ||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||
| 737 | my @bonds = $hack->build_bonds(@atoms[1,3,5]); | ||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||
| 739 | will return two bonds: B13 and B35 | ||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||
| 741 | =head2 build_angles | ||||||||||||||||||||||||||||
| 742 | |||||||||||||||||||||||||||||
| 743 | takes a list of atoms and returns a list of angles. The angles are generated | ||||||||||||||||||||||||||||
| 744 | analagously to build_bonds, e.g. | ||||||||||||||||||||||||||||
| 745 | |||||||||||||||||||||||||||||
| 746 | my @angles = $hack->build_angles(@atoms[1,3,5]); | ||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||
| 748 | will return one angle: A135 | ||||||||||||||||||||||||||||
| 749 | |||||||||||||||||||||||||||||
| 750 | =head2 build_dihedrals | ||||||||||||||||||||||||||||
| 751 | |||||||||||||||||||||||||||||
| 752 | takes a list of atoms and returns a list of dihedrals. The dihedrals are generated | ||||||||||||||||||||||||||||
| 753 | analagously to build_bonds, e.g. | ||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||
| 755 | my @dihedral = $hack->build_dihedrals(@atoms[1,3,5]); | ||||||||||||||||||||||||||||
| 756 | |||||||||||||||||||||||||||||
| 757 | will croak! you need atleast four atoms. | ||||||||||||||||||||||||||||
| 758 | |||||||||||||||||||||||||||||
| 759 | my @dihedral = $hack->build_dihedrals(@atoms[1,3,5,6,9]); | ||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||
| 761 | will return two dihedrals: D1356 and D3569 | ||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||
| 763 | =head2 group_by_atom_attr | ||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||
| 765 | args: atom attribute (e.g. 'name') ; list of atoms (e.g. $mol->all_atoms) | ||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||
| 767 | returns array of AtomGroup objects | ||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||
| 769 | =head2 group_by_atom_attrs | ||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||
| 771 | args: array reference of multiple atom attributes (e.g. ['resname', 'chain' ]); list of atoms. | ||||||||||||||||||||||||||||
| 772 | |||||||||||||||||||||||||||||
| 773 | returns array of AtomGroup objects | ||||||||||||||||||||||||||||
| 774 | |||||||||||||||||||||||||||||
| 775 | =head2 find_bonds_brute | ||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||
| 777 | The arguments are key_value pairs of bonding criteria (see example below). | ||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||
| 779 | This method returns bonds between bond_atoms and the candidates using the | ||||||||||||||||||||||||||||
| 780 | criteria (many of wich have defaults). | ||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||
| 782 | my @oxy_bonds = $hack->find_bonds_brute( | ||||||||||||||||||||||||||||
| 783 | bond_atoms => [$hg], | ||||||||||||||||||||||||||||
| 784 | candidates => [$mol->all_atoms], | ||||||||||||||||||||||||||||
| 785 | fudge => 0.45, | ||||||||||||||||||||||||||||
| 786 | max_bonds => 6, | ||||||||||||||||||||||||||||
| 787 | ); | ||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||
| 789 | fudge is optional with Default is 0.45 (open babel uses same default); | ||||||||||||||||||||||||||||
| 790 | max_bonds is optional with default of 99. max_bonds is compared against | ||||||||||||||||||||||||||||
| 791 | the atom bond count, which are incremented during the search. Before returning | ||||||||||||||||||||||||||||
| 792 | the bonds, the bond_count are returned the values before the search. For now, | ||||||||||||||||||||||||||||
| 793 | molecules are responsible for setting the number of bonds in atoms. | ||||||||||||||||||||||||||||
| 794 | find_bonds_brute uses a bruteforce algorithm that tests the interatomic | ||||||||||||||||||||||||||||
| 795 | separation against the sum of the covalent radii + fudge. It will not test | ||||||||||||||||||||||||||||
| 796 | for bond between atoms if either atom has >= max_bonds. It does not return | ||||||||||||||||||||||||||||
| 797 | a self bond for an atom (C< next if refaddr($ati) == refaddr($atj) >). | ||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||
| 799 | =head2 mol_disulfide_bonds | ||||||||||||||||||||||||||||
| 800 | |||||||||||||||||||||||||||||
| 801 | my @ss = $bldr->mol_disulfide_bonds($mol, [$fudge]); # default $fudge = 0.15 | ||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||
| 803 | Returns all disulfide bonds with lengths leq 2 x S->covalent_radius + $fudge. $mol can be an AtomGroup | ||||||||||||||||||||||||||||
| 804 | or Molecule. | ||||||||||||||||||||||||||||
| 805 | |||||||||||||||||||||||||||||
| 806 | =head2 find_disulfide_bonds | ||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||
| 808 | my @ss = $bldr->find_disulfide_bonds(@atoms); | ||||||||||||||||||||||||||||
| 809 | |||||||||||||||||||||||||||||
| 810 | DEPRECATED. Uses find_bonds_brute with fudge of 0.15 and max_bonds 1. mol_disulfides was developed | ||||||||||||||||||||||||||||
| 811 | after finding funky cysteine clusters (e.g. 1f3h) | ||||||||||||||||||||||||||||
| 812 | |||||||||||||||||||||||||||||
| 813 | =head2 rmsd ($group1,$group2,$weights) | ||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||
| 815 | my $rmsd = $bldr->rmsd($group1, $group2, [$weights]); #optional weights need to be tested | ||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||
| 817 | Computes the root mean square deviation between atomic vectors of the two AtomGroup/Molecule objects. | ||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||
| 819 | =head2 superpose_rt ($group1, $group2) | ||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||
| 821 | WARNING: 1. needs more testing (feel free to contribute tests!). 2. may shift to another class. | ||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||
| 823 | args: two hackmol objects (HackaMol::AtomGroup or HackaMol::Molecule) with same number of atoms. | ||||||||||||||||||||||||||||
| 824 | This method is intended to be very flexible. It does not check meta data of the atoms, it just pulls | ||||||||||||||||||||||||||||
| 825 | the vectors in each group to calculate the rotation matrix and translation vector needed to superpose | ||||||||||||||||||||||||||||
| 826 | the second set on to the first set. | ||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||
| 828 | The vectors assumed to be in the same order, that's it! | ||||||||||||||||||||||||||||
| 829 | |||||||||||||||||||||||||||||
| 830 | A typical workflow: | ||||||||||||||||||||||||||||
| 831 | |||||||||||||||||||||||||||||
| 832 | my $bb1 = $mol1->select_group('backbone'); | ||||||||||||||||||||||||||||
| 833 | my $bb2 = $mol2->select_group('backbone'); | ||||||||||||||||||||||||||||
| 834 | my ($rmat,$trans,$rmsd) = HackaMol->new()->superpose_rt($bb1,$bb2); | ||||||||||||||||||||||||||||
| 835 | # $rmsd is the RMSD between backbones | ||||||||||||||||||||||||||||
| 836 | |||||||||||||||||||||||||||||
| 837 | # to calculate rmsd between other atoms after the backbone alignment | ||||||||||||||||||||||||||||
| 838 | $mol2->rotate_translate($rmat,$trans); | ||||||||||||||||||||||||||||
| 839 | my $total_rmsd = HackaMol->new()->rmsd($mol1,$mol2); | ||||||||||||||||||||||||||||
| 840 | # $total_rmsd is from all atoms in each mol | ||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||
| 842 | the algorithm is lifted from Bio::PDB::Structure, which implements | ||||||||||||||||||||||||||||
| 843 | algorithm from S. Kearsley, Acta Cryst. A45, 208-210 1989 | ||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||
| 845 | returns: | ||||||||||||||||||||||||||||
| 846 | 1. rotation matrix [3 rows, each is a MVR , e.g. x' = row_1 * xyz] | ||||||||||||||||||||||||||||
| 847 | 2. translation vector (MVR) | ||||||||||||||||||||||||||||
| 848 | 3. rmsd | ||||||||||||||||||||||||||||
| 849 | |||||||||||||||||||||||||||||
| 850 | =head1 ATTRIBUTES | ||||||||||||||||||||||||||||
| 851 | |||||||||||||||||||||||||||||
| 852 | =head2 name | ||||||||||||||||||||||||||||
| 853 | |||||||||||||||||||||||||||||
| 854 | name is a rw str provided by HackaMol::NameRole. | ||||||||||||||||||||||||||||
| 855 | |||||||||||||||||||||||||||||
| 856 | =head2 readline_func | ||||||||||||||||||||||||||||
| 857 | |||||||||||||||||||||||||||||
| 858 | hook to add control to parsing files | ||||||||||||||||||||||||||||
| 859 | |||||||||||||||||||||||||||||
| 860 | HackaMol->new( | ||||||||||||||||||||||||||||
| 861 | readline_func => sub {return "PDB_SKIP" unless /LYS/ } | ||||||||||||||||||||||||||||
| 862 | ) | ||||||||||||||||||||||||||||
| 863 | ->pdbid_mol("2cba") | ||||||||||||||||||||||||||||
| 864 | ->print_pdb; # will parse lysines because the PDB reader looks for the PDB_SKIP return value | ||||||||||||||||||||||||||||
| 865 | |||||||||||||||||||||||||||||
| 866 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 867 | |||||||||||||||||||||||||||||
| 868 | # simple example: load pdb file and extract the disulfide bonds | ||||||||||||||||||||||||||||
| 869 | |||||||||||||||||||||||||||||
| 870 | use HackaMol; | ||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||
| 872 | my $bldr = HackaMol->new( name => 'builder'); | ||||||||||||||||||||||||||||
| 873 | my $mol = $bldr->pdbid_mol('1kni'); | ||||||||||||||||||||||||||||
| 874 | |||||||||||||||||||||||||||||
| 875 | my @disulfide_bonds = $bldr->find_disulfide_bonds( $mol->all_atoms ); | ||||||||||||||||||||||||||||
| 876 | |||||||||||||||||||||||||||||
| 877 | print $_->dump foreach @disulfide_bonds; | ||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||
| 879 | See the above executed in this L<linked notebook|https://github.com/demianriccardi/p5-IPerl-Notebooks/blob/master/HackaMol/HackaMol-Synopsis.ipynb> | ||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||
| 881 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||
| 883 | =over 4 | ||||||||||||||||||||||||||||
| 884 | |||||||||||||||||||||||||||||
| 885 | =item * | ||||||||||||||||||||||||||||
| 886 | |||||||||||||||||||||||||||||
| 887 | L<HackaMol::Atom> | ||||||||||||||||||||||||||||
| 888 | |||||||||||||||||||||||||||||
| 889 | =item * | ||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||
| 891 | L<HackaMol::Bond> | ||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||
| 893 | =item * | ||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||
| 895 | L<HackaMol::Angle> | ||||||||||||||||||||||||||||
| 896 | |||||||||||||||||||||||||||||
| 897 | =item * | ||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||
| 899 | L<HackaMol::Dihedral> | ||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||
| 901 | =item * | ||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||
| 903 | L<HackaMol::AtomGroup> | ||||||||||||||||||||||||||||
| 904 | |||||||||||||||||||||||||||||
| 905 | =item * | ||||||||||||||||||||||||||||
| 906 | |||||||||||||||||||||||||||||
| 907 | L<HackaMol::Molecule> | ||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||
| 909 | =item * | ||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||
| 911 | L<HackaMol::X::Calculator> | ||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||
| 913 | =item * | ||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||
| 915 | L<HackaMol::X::Vina> | ||||||||||||||||||||||||||||
| 916 | |||||||||||||||||||||||||||||
| 917 | =item * | ||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||
| 919 | L<Protein Data Bank|http://pdb.org> | ||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||
| 921 | =item * | ||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||
| 923 | L<VMD|http://www.ks.uiuc.edu/Research/vmd/> | ||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||
| 925 | =back | ||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||
| 927 | =head1 EXTENDS | ||||||||||||||||||||||||||||
| 928 | |||||||||||||||||||||||||||||
| 929 | =over 4 | ||||||||||||||||||||||||||||
| 930 | |||||||||||||||||||||||||||||
| 931 | =item * L<Moose::Object> | ||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||
| 933 | =back | ||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||
| 935 | =head1 CONSUMES | ||||||||||||||||||||||||||||
| 936 | |||||||||||||||||||||||||||||
| 937 | =over 4 | ||||||||||||||||||||||||||||
| 938 | |||||||||||||||||||||||||||||
| 939 | =item * L<HackaMol::Roles::ExeRole> | ||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||
| 941 | =item * L<HackaMol::Roles::FileFetchRole> | ||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||
| 943 | =item * L<HackaMol::Roles::MolReadRole> | ||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||
| 945 | =item * L<HackaMol::Roles::NERFRole> | ||||||||||||||||||||||||||||
| 946 | |||||||||||||||||||||||||||||
| 947 | =item * L<HackaMol::Roles::NameRole> | ||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||
| 949 | =item * L<HackaMol::Roles::NameRole|HackaMol::Roles::MolReadRole|HackaMol::Roles::PathRole|HackaMol::Roles::ExeRole|HackaMol::Roles::FileFetchRole|HackaMol::Roles::NERFRole|HackaMol::Roles::RcsbRole> | ||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||
| 951 | =item * L<HackaMol::Roles::PathRole> | ||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||
| 953 | =item * L<HackaMol::Roles::RcsbRole> | ||||||||||||||||||||||||||||
| 954 | |||||||||||||||||||||||||||||
| 955 | =item * L<HackaMol::Roles::ReadPdbRole> | ||||||||||||||||||||||||||||
| 956 | |||||||||||||||||||||||||||||
| 957 | =item * L<HackaMol::Roles::ReadPdbqtRole> | ||||||||||||||||||||||||||||
| 958 | |||||||||||||||||||||||||||||
| 959 | =item * L<HackaMol::Roles::ReadPdbxRole> | ||||||||||||||||||||||||||||
| 960 | |||||||||||||||||||||||||||||
| 961 | =item * L<HackaMol::Roles::ReadXyzRole> | ||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||
| 963 | =item * L<HackaMol::Roles::ReadYAMLRole> | ||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||
| 965 | =item * L<HackaMol::Roles::ReadYAMLRole|HackaMol::Roles::ReadZmatRole|HackaMol::Roles::ReadPdbRole|HackaMol::Roles::ReadPdbxRole|HackaMol::Roles::ReadPdbqtRole|HackaMol::Roles::ReadXyzRole> | ||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||
| 967 | =item * L<HackaMol::Roles::ReadZmatRole> | ||||||||||||||||||||||||||||
| 968 | |||||||||||||||||||||||||||||
| 969 | =back | ||||||||||||||||||||||||||||
| 970 | |||||||||||||||||||||||||||||
| 971 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 972 | |||||||||||||||||||||||||||||
| 973 | Demian Riccardi <demianriccardi@gmail.com> | ||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||
| 975 | =head1 COPYRIGHT AND LICENSE | ||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||
| 977 | This software is copyright (c) 2017 by Demian Riccardi. | ||||||||||||||||||||||||||||
| 978 | |||||||||||||||||||||||||||||
| 979 | This is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 980 | the same terms as the Perl 5 programming language system itself. | ||||||||||||||||||||||||||||
| 981 | |||||||||||||||||||||||||||||
| 982 | =cut | ||||||||||||||||||||||||||||