HackaMol
view release on metacpan or search on metacpan
t/HackaMol.t view on Meta::CPAN
is( $bonds[0]->name, 'N1_CA1', "bond name1" );
is( $bonds[1]->name, 'CA1_C1', "bond name2" );
is( $bonds[2]->name, 'C1_N2', "bond name3" );
is( $angles[1]->name, 'CA1_C1_N2', "second angle name" );
is( $dihedrals[-1]->name, 'C19_N20_CA20_C20', "last dihedral name" );
is( $bonds[-1]->name, 'CA20_C20', "last bond name1" );
is( $angles[-1]->name, 'N20_CA20_C20', "last angle name1" );
dies_ok { $hack->build_dihedrals( @bb[ 0 .. 2 ] ) } "build_dihedrals croak";
dies_ok { $hack->build_bonds( $bb[0] ) } "build_bonds croak";
dies_ok { $hack->build_angles( @bb[ 0, 1 ] ) } "build_angles croak";
{
$_->clear_name foreach @bb;
my @bonds = $hack->build_bonds(@bb);
my @angles = $hack->build_angles(@bb);
my @dihedrals = $hack->build_dihedrals(@bb);
is( $dihedrals[0]->name, 'D1_D1_D1_D2', "dihedral noname default" );
is( $angles[0]->name, 'A1_A1_A1', "angle noname default" );
is( $bonds[0]->name, 'B1_B1', "bond noname default" );
}
{
$_->name("foo") foreach @bb;
$_->resid foreach @bb;
my @bonds = $hack->build_bonds(@bb);
my @angles = $hack->build_angles(@bb);
my @dihedrals = $hack->build_dihedrals(@bb);
is( $dihedrals[0]->name, 'foo1_foo1_foo1_foo2',
"dihedral name foo resid default" );
is( $angles[0]->name, 'foo1_foo1_foo1', "angle name foo resid default" );
is( $bonds[0]->name, 'foo1_foo1', "bond name foo resid default" );
}
{ #find_disulfide_bonds
my $mol = $hack->read_file_mol("t/lib/1V0Z_A.pdb");
my @ss = $hack->find_disulfide_bonds( $mol->all_atoms );
is( scalar(@ss), 9, "found 9 disulfides in 1V0Z" );
my @ss_atoms = map { $_->all_atoms } @ss;
is( scalar(@ss_atoms), 18, "9 disulfides have 18 atoms" );
is( ( grep { $_->symbol eq "S" } @ss_atoms ), 18, "18 Sulfur atoms" );
my $bc = 0;
$bc += $_->bond_count foreach @ss_atoms;
is( $bc, 0, "0 bonds for 9 disulfides with no molecule" );
my $mol2 = HackaMol::Molecule->new(
name => "1voz.ss",
atoms => [@ss_atoms],
bonds => [@ss]
);
$bc += $_->bond_count foreach @ss_atoms;
is( $bc, 18, "18 bonds for 9 disulfides (1/atom) in molecule" );
my @ss_2 = $hack->mol_disulfide_bonds($mol,0.15);
is_deeply([@ss],[@ss_2],'mol_disulfide gives same as find_disulfide');
# checks out by viz xyz and pdb overlay
# $mol2->print_xyz;
}
{ # guess element from name make them dirty if don't exist in lookup
my @atoms;
warning_is { @atoms = $hack->read_file_atoms("t/lib/1L2Y_noelem.pdb") }
"MolReadRole> found 2 dirty atoms. Check symbols and lookup names PeriodicTable.pm: DIRTY: index 34 name HXYY element H -5.592 8.445 -1.281; DIRTY: index 35 name HXXX element H 0.000 0.000 0.000;",
"warning for dirty atoms";
# no warning...
is( $hack->hush_read, 0, 'hush_read off' );
$hack->hush_read(1);
is( $hack->hush_read, 1, 'hush_read on' );
my @watoms = $hack->read_file_atoms("t/lib/1L2Y_noelem.pdb");
my @lsymbols = map { $_->symbol } @atoms;
my @dirty = grep { $_->is_dirty } @atoms;
is( scalar(@dirty), 2, "2 dirty atoms" );
my @esymbols = qw(N C C O C C O N H H H H H H H H N C C O C C
C C H H H H H H H H H H H H);
is_deeply( \@lsymbols, \@esymbols, "symbols set from names" );
}
{ # pdbqt reading tests
my @atoms;
my $hack = HackaMol->new;
warning_is { @atoms = $hack->read_file_atoms("t/lib/test.pdbqt") }
"MolReadRole> found 27 dirty atoms. Check symbols and lookup names",
"warning for dirty atoms";
my $mol = HackaMol::Molecule->new( name => "drugs", atoms => [@atoms] );
is( $mol->tmax, 8, "9 models in test.pdbqt" )
}
{ # superpose tests...
my $g1 = HackaMol::AtomGroup->new(atoms => [
HackaMol::Atom->new(Z => 80, coords => [V(1,1,1)]),
HackaMol::Atom->new(Z => 80, coords => [V(2,1,1)]),
HackaMol::Atom->new(Z => 80, coords => [V(1,2,1)]),
HackaMol::Atom->new(Z => 80, coords => [V(1,1,2)]),
HackaMol::Atom->new(Z => 80, coords => [V( 0,1,1)]),
HackaMol::Atom->new(Z => 80, coords => [V(1, 0,1)]),
HackaMol::Atom->new(Z => 80, coords => [V(1,1, 0)]),
]);
my $g2 = HackaMol::AtomGroup->new(atoms => [
HackaMol::Atom->new(Z => 80, coords => [V(0,0,0)]),
HackaMol::Atom->new(Z => 80, coords => [V(1,0,0)]),
HackaMol::Atom->new(Z => 80, coords => [V(0,1,0)]),
HackaMol::Atom->new(Z => 80, coords => [V(0,0,1)]),
HackaMol::Atom->new(Z => 80, coords => [V(-1,0,0)]),
HackaMol::Atom->new(Z => 80, coords => [V(0,-1,0)]),
HackaMol::Atom->new(Z => 80, coords => [V(0,0,-1)]),
]);
# superpose has been checked against VMD, but more tests are needed
my $hack = HackaMol->new;
( run in 1.636 second using v1.01-cache-2.11-cpan-39bf76dae61 )