#!/usr/bin/perl -w use strict; use constant { RAD => 9, X => 5, Y => 6, Z => 7, NB => 1, REST => 10, }; my $file; print "Please type the filename with the solvent: "; chomp($file = ); die "File \"$file\" doesn\'t seem to exist!!\n" unless -e $file; open(SOLVFILE, $file) or die("Couldn't open file $file\n"); print "Please type the filename with the structure: \n"; chomp($file = ); die "File \"$file\" doesn\'t seem to exist!!\n" unless -e $file; open(STRUCTFILE, $file) or die("Couldn't open file $file\n"); open(PDB, ">Solvent.pdb") or die "$!"; open(OVERL, ">OverL.txt") or die "$!"; my @solv; my $line; while ($line=) { chomp $line; push @solv, [split /\s+/, $line]; push @{$solv[-1]}, $line; } close SOLVFILE; print "Number of atoms in solvent file is ",$#solv+1," \n"; my @struct; while ($line=) { chomp($line); push @struct, [split /\s+/, $line]; push @{$struct[-1]}, $line; } close STRUCTFILE; print "Number of atoms in structure file is ",$#struct+1," \n"; for (my $i = 0; $i <= $#solv; $i++) { my $v = $solv[$i]; for my $t (@struct) { if ( # Sum of radius is greater than distance # between the atoms ($v->[RAD] + $t->[RAD]) > sqrt( ($v->[X] - $t->[X])**2 + ($v->[Y] - $t->[Y])**2 + ($v->[Z] - $t->[Z])**2 )) { print OVERL "Overlap for atoms ", $v->[NB]," and ",$t->[NB],"\n"; } else { print PDB $v->[REST],"\n"; } } } close OVERL; close PDB; exit;