#!/usr/bin/perl -w @desBooli = (); @ATOM = (); @atmnb1 = (); @atmname1 = (); @resname1 = (); @resnb1 = (); @rest1 = (); @x1 = (); @y1 = (); @z1 = (); @q1 = (); @rad1 = (); @atmnb2 = (); @atmname2 = (); @resname2 = (); @resnb2 = (); @x2 = (); @y2 = (); @z2 = (); @q2 = (); @rad2 = (); print "Please type the filename with the solvent: "; $file1 = ; chomp $file1; #Does the file exist? unless ( -e $file1) { print "File \"$file1\" doesn\'t seem to exist!!\n"; exit; } #Can we open the file? open(SOLVFILE, $file1) || die("Couldn't open file $file1\n"); print "Please type the filename with the structure: "; $file2 = ; chomp $file2; #Does the file exist? unless ( -e $file2) { print "File \"$file2\" doesn\'t seem to exist!!\n"; exit; } #Can we open the file? open(STRUCTFILE, $file2) || die ("Couldn't open file $file2\n"); open(test1, ">Solvent.pdb"); open(test2, ">OverL.txt"); $i=0; while ($line=) { chop($line); $rest1[$i] = $line; ($ATOM, $atomnb1[$i], $atmname1[$i],$resname1[$i],$resnb1[$i],$x1[$i],$y1[$i],$z1[$i],$q1[$i],$rad1[$i])= split(/\s+/, $line); $i++; } $Nsolv = $i; print "Number of atoms in solvent file is $Nsolv \n"; $i = 0; while ($line=) { chop($line); ($ATOM, $atomnb2[$i], $atmname2[$i],$resname2[$i],$resnb2[$i],$x2[$i],$y2[$i],$z2[$i],$q2[$i],$rad2[$i])= split(/\s+/, $line); $i++; } $Nstruct = $i; print "Number of atoms in structure file is $Nstruct \n"; for ($i = 0; $i <=$Nsolv-1; $i++) { $desBooli[$i] = 0; } for ($i = 0; $i <=$Nsolv-1; $i++) { for ($j = 0; $j <=$Nstruct-1; $j++) { $dist = sqrt(($x1[$i]-$x2[$j])*($x1[$i]-$x2[$j])+($z1[$i]-$z2[$j])*($z1[$i]-$z2[$j])+($z1[$i]-$z2[$j])*($z1[$i]-$z2[$j])); $radSum = $rad1[$i] +$rad2[$j]; if($dist < $radSum) { print test2 "Overlap for atoms $atomnb1[$i] and $atomnb2[$j]\n"; $desBooli[$i] = 1; } } } $i = 0; for ($i = 0; $i <=$Nsolv-1; $i++) { if ($desBooli[$i] == 0){ print test1 "$rest1[$i]\n" } } close STRUCTFILE; close SOLVFILE; close test1; close test2; exit;