#!/usr/bin/perl -w

while(defined($file1=glob("*.fna")))

# do this before running the script:
# module load MUMmer/4.0.2 
# module load gnuplot

{
	while(defined($file2=glob("*.fna")))
	{ 
	if ($file1 eq $file2) {next};
	@part1=split(/\./,$file1);
	@part2=split(/\./,$file2);
	$outname="$part1[0]_"."$part2[0]";
	
	
system ("nucmer $file1 $file2");	
system ("mummerplot --postscript --prefix $outname out.delta"); 
$plotname="$outname"."\.gp";
system ("gnuplot $plotname"); 
	}
}

# using MUMmer/4.0.2  
# these messages and errors appear to be normal
# Reading delta file out.delta
# Writing plot files E_marmotae_NCTC8196_Shigella_boydii_600657.fplot, E_marmotae_NCTC8196_Shigella_boydii_600657.rplot
# Writing gnuplot script E_marmotae_NCTC8196_Shigella_boydii_600657.gp
# Rendering plot E_marmotae_NCTC8196_Shigella_boydii_600657.ps
# WARNING: Unable to run 'false E_marmotae_NCTC8196_Shigella_boydii_600657.gp', Inappropriate ioctl for device
# gnuplot 5.2 patchlevel 2
# could get it to run only with postscript output 
# the call of gnuplot from with in mummerplot failed, but gnuplot worked without complaints on the *.gp file
#
# The first sequence is the REF, the second the query