| 1 | package HackaMol::Roles::ReadPdbqtRole; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | $HackaMol::Roles::ReadPdbqtRole::VERSION = '0.053'; | |||||||||||||||||||||||||||||||||||||||||
| 3 | # ABSTRACT: Read files with molecular information | ||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 11 | ▶ | use HackaMol::PeriodicTable qw(_element_name _trim _qstring_num); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use Math::Vector::Real; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 11 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | sub read_pdbqt_atoms { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read_pdbqt_atoms: called CC=17 SCAR=30.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||
| 11 | # this is too similar to reading pdb for it too exist separately... think about | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | my $fh = shift; | |||||||||||||||||||||||||||||||||||||||||
| 14 | #my $file = shift; | ||||||||||||||||||||||||||||||||||||||||||
| 15 | #my $fh = FileHandle->new("<$file") or croak "unable to open $file"; | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # $RtBrnch{ROOT}{iatoms} = LIST integers of atoms in root | ||||||||||||||||||||||||||||||||||||||||||
| 18 | # $RtBrnch{BRNCH1}{iatoms} = LIST integers of atoms in BRNCH1 | ||||||||||||||||||||||||||||||||||||||||||
| 19 | # $RtBrnch{BRNCH1}{ROOT} = LIST two integers of rotable bond for BRNCH1 | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # $RtBrnch{BRNCH2}{iatoms} = LIST integers of atoms in BRNCH2 | ||||||||||||||||||||||||||||||||||||||||||
| 21 | # $RtBrnch{BRNCH2}{SBRNCH1} iatoms} = LIST integers of atoms in BRNCH2 | ||||||||||||||||||||||||||||||||||||||||||
| 22 | # each branch is rigid block of atoms | ||||||||||||||||||||||||||||||||||||||||||
| 23 | # NONONONONO!!!! for now, just read in atoms. We'll figure out how to save the tree later | ||||||||||||||||||||||||||||||||||||||||||
| 24 | 1 | my %RtBrnch; | |||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | my @atoms; | ||||||||||||||||||||||||||||||||||||||||||
| 27 | 1 | my ( $n, $t ) = ( 0, 0 ); | |||||||||||||||||||||||||||||||||||||||||
| 28 | 1 | my $q_tbad = 0; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | my $something_dirty = 0; | |||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||
| 31 | 1 | ▶ | while (<$fh>) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 378 | ▶ | if (/^(?:MODEL\s+(\d+))/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 9 | $n = 0; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 9 | $q_tbad = 0; # flag a bad model and never read again! | |||||||||||||||||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||||||||||||||||
| 37 | elsif (/^(?:ENDMDL)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 38 | 9 | $t++; | |||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | elsif (/^(?:HETATM|ATOM)/) { | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 252 | ▶ | next if $q_tbad; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | my ( | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 252 | $record_name, $serial, $name, $altloc, $resName, | |||||||||||||||||||||||||||||||||||||||||
| 44 | $chainID, $resSeq, $icod, $x, $y, | ||||||||||||||||||||||||||||||||||||||||||
| 45 | $z, $occ, $B, $charge, $ADTtype | ||||||||||||||||||||||||||||||||||||||||||
| 46 | ) = unpack "A6A5x1A4A1A3x1A1A4A1x3A8A8A8A6A6x4A6x1A2", $_; | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | #ATOM 1 O LIG d 1 8.299 4.799 79.371 0.00 0.00 -0.292 OA | ||||||||||||||||||||||||||||||||||||||||||
| 49 | #-----|----|x---||--|x|---||xxx-------|-------|-------|-----|-----|xxxx-----|x-| | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 252 | ▶ | if ( $chainID =~ m/\w/ ) { $chainID = uc( _trim($chainID) ) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | else { $chainID = ' ' } | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 252 | $name = _trim($name); | |||||||||||||||||||||||||||||||||||||||||
| 55 | 252 | $resName = _trim($resName); | |||||||||||||||||||||||||||||||||||||||||
| 56 | 252 | $resSeq = _trim($resSeq); | |||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||
| 58 | #$resSeq = 0 if ( $resSeq < 0 ); | ||||||||||||||||||||||||||||||||||||||||||
| 59 | 252 | $serial = _trim($serial); | |||||||||||||||||||||||||||||||||||||||||
| 60 | 252 | $charge = _trim($charge); | |||||||||||||||||||||||||||||||||||||||||
| 61 | 252 | $ADTtype = _trim($ADTtype); | |||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 252 | my ( $element, $qdirt ) = _element_name($ADTtype); | |||||||||||||||||||||||||||||||||||||||||
| 64 | 252 | ▶ | $something_dirty++ if ($qdirt); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 252 | my $xyz = V( $x, $y, $z ); | |||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 252 | ▶ | if ( $t == 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 28 | $atoms[$n] = HackaMol::Atom->new( | |||||||||||||||||||||||||||||||||||||||||
| 69 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 70 | record_name => $record_name, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | serial => $serial, | ||||||||||||||||||||||||||||||||||||||||||
| 72 | chain => $chainID, | ||||||||||||||||||||||||||||||||||||||||||
| 73 | symbol => $element, | ||||||||||||||||||||||||||||||||||||||||||
| 74 | charges => [$charge], | ||||||||||||||||||||||||||||||||||||||||||
| 75 | coords => [$xyz], | ||||||||||||||||||||||||||||||||||||||||||
| 76 | occ => $occ * 1, | ||||||||||||||||||||||||||||||||||||||||||
| 77 | bfact => $B * 1, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | resname => $resName, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | resid => $resSeq, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | segid => $ADTtype, | ||||||||||||||||||||||||||||||||||||||||||
| 81 | altloc => $altloc, | ||||||||||||||||||||||||||||||||||||||||||
| 82 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 28 | ▶ | $atoms[$n]->is_dirty($qdirt) unless $atoms[$n]->is_dirty; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||
| 85 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 86 | #croak condition if atom changes between models | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 224 | ▶ | if ( $n > $#atoms or $name ne $atoms[$n]->name | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$n > $#atoms or $name ne $atoms[$n]->name or $element ne $atoms[$n]->symbol
$n > $#atoms or $name ne $atoms[$n]->name
MC/DC0%0/3
$n > $#atoms or $name ne $atoms[$n]->name or $element ne $atoms[$n]->symbol
$n > $#atoms
$name ne $atoms[$n]->name
$element ne $atoms[$n]->symbol
Truth table25%1/4
A or B or C
A= $n > $#atomsB= $name ne $atoms[$n]->nameC= $element ne $atoms[$n]->symbol
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | or $element ne $atoms[$n]->symbol ) | ||||||||||||||||||||||||||||||||||||||||||
| 89 | { | ||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | my $carp_message = | |||||||||||||||||||||||||||||||||||||||||
| 91 | "BAD t->$t PDB Atom $n " | ||||||||||||||||||||||||||||||||||||||||||
| 92 | . "serial $serial resname $resName " | ||||||||||||||||||||||||||||||||||||||||||
| 93 | . "has changed"; | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | carp $carp_message; | |||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $q_tbad = $t; # this is a bad model! | |||||||||||||||||||||||||||||||||||||||||
| 96 | #wipe out all the coords prior | ||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | $atoms[$_]->delete_coords($t) foreach 0 .. $n - 1; | |||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $t--; | |||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 224 | $atoms[$n]->set_coords( $t, $xyz ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 252 | $n++; | |||||||||||||||||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | # set iatom to track the array. diff from serial which refers to pdb | ||||||||||||||||||||||||||||||||||||||||||
| 108 | 1 | $atoms[$_]->iatom($_) foreach ( 0 .. $#atoms ); | |||||||||||||||||||||||||||||||||||||||||
| 109 | 1 | ▶ | if ($something_dirty) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 1 | ▶ | unless ( $self->hush_read ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 1 | my $message = "MolReadRole> found $something_dirty dirty atoms. "; | |||||||||||||||||||||||||||||||||||||||||
| 112 | 1 | $message .= "Check symbols and lookup names"; | |||||||||||||||||||||||||||||||||||||||||
| 113 | 1 | carp $message; | |||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 1 | return (\@atoms); | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 11 | ▶ | no Moose::Role; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | __END__ | ||||||||||||||||||||||||||||||||||||||||||