# Open each PDB foreach my $pdb_file (<$pdb_list>) { { chomp($pdb_file); my $tmp_file; # We would open the PDB with this handle open($tmp_file, "< $pdb_file") or (die "Cannot open PDB: $!"); # Read X,Y,Z coordinates my @X; # X-coordinates my @Y; # Y-coordinates my @Z; # Z-coordinates my @pdb_tmp=<$tmp_file>; foreach (@pdb_tmp) { if (substr($_,0,3) eq "ATO") { push @X, substr($_,30,8); push @Y, substr($_,38,8); push @Z, substr($_,46,8); } } # Find the interaction pairs. Also strore the best angle, should it # occur again with another proton. Also keep track of the waters # that have made h-bond with the solute atoms. my @sel_wat; # Array of water molecule (numbers) selected my %hbond; # $hbond[$tag1:$tag2][0]=distance # $hbond[$tag1:$tag2][0]=angle # Solute as donor and water as acceptor { my @atom_cov; # Polar solute atom that is already covered. for (my $i=0; $i <= $#pol_h; $i++) { # If this donor is not already covered, then go ahead. if ( ! defined($atom_cov[$pol_h[$i][1]]) ) { for (my $j=0; $j <= $#wat_a; $j++) { my $dx=$X[$pol_h[$i][1]]-$X[$wat_a[$j]]; my $dy=$Y[$pol_h[$i][1]]-$Y[$wat_a[$j]]; my $dz=$Z[$pol_h[$i][1]]-$Z[$wat_a[$j]]; my $distSq=($dx*$dx)+($dy*$dy)+($dz*$dz); if ($distSq <= $hb_dist) { $atom_cov[$pol_h[$i][1]]=1; print $idty[$pol_h[$i][1]], " ", $idty[$wat_a[$j]], $distSq,"\n"; } } } } } } }