#!/usr/bin/perl # This is a script which compares the query file and base with some threshold given by the user #use warnings; use strict; print "Enter the Threshold Value: \n"; my $j= ; my $filename1 = "10.asc.output"; my (%hash, @queryx, @queryy); open (FILE1, $filename1) or die "can't open $filename1: $!\n"; while() { if ($_ =~ /(\S+)\s+(\S+)/) { $hash{$1} = $2; push(@queryx,$1); push (@queryy, $2); } } close(FILE1); my ($filename, $i, @basex, @basey, $folder, $a1, $a2, $a3, $b1, $b2, $b3, $r1, $r2, $r3, $rr1, $rr1, $rr2, $rr3); $folder = '/home/users/dachs/perl_scripts/perlup'; #folder path where opendir(MYDIR, $folder) || die "System cant open directory reading for\n"; while ($filename = readdir MYDIR){ next unless $filename =~ /\.asc.output$/i; #Check for the file .asc #undef %hash; #undef @basex; #undef @basey; open FILE, "$filename" or die "can't open $filename: $!\n"; while(){ if ($_ =~ /(\S+)\s+(\S+)/) { $hash{$1} = $2; push(@basex,$1); push (@basey, $2); } } close (FILE); open(FILEHANDLE, ">$filename.cmp") or die "cannot open file for reading: $!";#Creates an output file while ($i <= $#basex) { $a1 = $queryx[$i]; $a2 = $queryx[$i+1]; $a3 = $queryx[$i+2]; $b1 = $basex[$i]; $b2 = $basex[$i+1]; $b3 = $basex[$i+2]; $rr1 = (($a1) - ($b1)); $rr2 = (($a2) - ($b2)); $rr3 = (($a3) - ($b3)); $r1 = abs($rr1); $r2 = abs($rr2); $r3 = abs($rr3); $i++; print $rr1, "\n"; if (($r1 <= $j) && ($r2 <= $j) && ($r3 <= $j)) { print FILEHANDLE "Matched: ", $a1, "\t", $a2, "\t", $a3, "\n"; #$count = $count + 1; print $r1, $r2, $r3, "\n"; } } close (FILEHANDLE); } closedir(MYDIR);