#!/usr/bin/env perl
################################################################################
#677968693279877869823280736982826932696779678132535748555051505432666947666976#
#some modules required (if not installed use command line cpan install <module>)
use Modern::Perl '2011'; # used as warnings/strict
use Smart::Comments '###'; # used to trace run progress 
use Getopt::Euclid;# used to document perl code
use File::Basename; # used to capture file names and locations
use File::Copy 'copy'; # used to archive some filesµ
use File::Compare; # used to compare files (archiving)
use Cwd; # used to catch current working directory
use File::Find;
use Win32::DriveInfo;#to check drive space available

#my (undef, undef, undef, undef, undef, $total, $free) =
#    Win32::DriveInfo::DriveSpace('c');

#next are hardly coded values to evaluate if drive will support process (size)
my $totalfastqgzsize = 0;
my $totalfastqsize = 0;
my $drivefastq;#drive where decompressed Fastq files will be recorded
my $drivefastqgz;#drive where copies of FastQ.gz files will be archived
my $drivefastqtotalsize = 0;#drive where decompressed Fastq files will be recorded
my $drivefastqgztotalsize = 0;#drive where copies of FastQ.gz files will be archived
my $drivefastqfreesize = 0;#drive where decompressed Fastq files will be recorded
my $drivefastqgzfreesize = 0;#drive where copies of FastQ.gz files will be archived
my $sizewarning = 0.1;# value left space on drive / drive for warning
my $sizestop = 0.05;# value left space on drive / drive to reject process
my $ratiogznotgz = 6;#averaged size expansion factor gz to not gz

# Fetching code and folder and current working dir
my $code = $0;
my $currentdir = getcwd();
my $codename = $0;
if ($codename =~ m/([^\/]+)$/) {#for archiving
	$codename = $1;}
my $rundatetime = getdate();# get date_time from sub for reporting

print "\nWelcome to $codename.\n\n";

#fetching 7-zip location and checking 7z.exe exists (passed as argument --sevenzip)
my $sevenzipdir = uc $ARGV{'--sevenzip'};#uppercase for windows...
#next is to eventually switch to windows format (slaches to backslaches) 
while($sevenzipdir =~ s/\//\\/){}
#removing quote and double quote
while($sevenzipdir =~ s/\'//) {}
while($sevenzipdir =~ s/\"//) {}
#checking if exists and is folder
if ((!-e $sevenzipdir) || (!-d $sevenzipdir)) {
	BACKFROMZIPEXE:
	print "\n\nThe folder:\n\t$sevenzipdir\nyou provided as location for 7-Zip executable:\n\t1. Does not exist OR\n\t2. Is not a folder OR\n\t3. You do not have rights to use it.\n\t4. Folder contains space/blank (So try simple \' or double \" quoting)\n\n";
	SEVENZIPDIR:
	while (1>0) {
		print "\nYou can try again giving a new folder (or type \"Quit\" to quit):";
		my $answersevenzip = <STDIN>;
		chomp $answersevenzip;
		if (uc $answersevenzip eq 'QUIT') {
			die "See you another time. Bye!";}
		elsif ((-e $answersevenzip) &&  (-d $answersevenzip)) {
			$sevenzipdir =$answersevenzip;
			last SEVENZIPDIR;}
		else {
			print "\nSorry it does not make it neither.\n";}}}
#now about 7-Zip executable
my $sevenzipexe = $sevenzipdir . "\\7z.exe";
if (!-e $sevenzipexe) {
	goto BACKFROMZIPEXE;}
### 7-zip executable availabe from: $sevenzipdir

#argument overwrite (to ignore or not fastq.gz already gunzipped)
my $overwrite = uc $ARGV{'--overwrite'};
if($overwrite ne  'NO' && $overwrite ne  'YES') {
	print "You did not provide one of YES/NO value to the argument --overwrite.\nFor right now we will consider it is a NO.\nYou will be asked again if there is some needs to modify this.\n";
	$overwrite = "NO";}
### Overwriting set to (can be modified later on): $overwrite

#dealing with output folder and its content
my $outputdir = $ARGV{'--outputfolder'};
#next is to eventually switch to windows format (slaches to backslaches) 
while($outputdir =~ s/\//\\/){}
#removing quote and double quote
while($outputdir =~ s/\'//) {}
while($outputdir =~ s/\"//) {}
if ((!-e $outputdir) || (!-d $outputdir)) {
	BACKOUTDIR:
	print "\n\nThe folder:\n\t$outputdir\nyou provided as location for gunziped FastQ.gz files:\n\t1. Does not exist OR\n\t2. Is not a folder OR\n\t3. You do not have rights to use it.\n\t4. Folder contains space/blank (So try simple \' or double \" quoting)\n\n";
	OUTPUTDIR:
	while (1>0) {
		print "\nYou can try again giving a new folder (or type \"Quit\" to quit):";
		my $answeroutdir = <STDIN>;
		chomp $answeroutdir;
		if (uc $answeroutdir eq 'QUIT') {
			die "See you another time. Bye!";}
		elsif ((-e $answeroutdir) &&  (-d $answeroutdir)) {
			$outputdir =$answeroutdir;
			last OUTPUTDIR;}
		else {
			print "\nSorry it does not make it neither.\n";}}}
#fetching all files in this folder
my @outputcontent;
if(opendir (OUTDIR,"$outputdir")) {
	@outputcontent = grep {$_ ne "." & $_ ne ".."} readdir OUTDIR;#fetching all files/folders in folder
	closedir OUTDIR;}
else {
	print "\nCannot open folder $outputdir to read from.\n";
	goto BACKOUTDIR;}
### Output folder identified as: $outputdir;
#fetching drive size and free left size
if ($outputdir =~ m/^([A-Z])\:/i) {
	$drivefastq = $1;
	my (undef, undef, undef, undef, undef, $total, $free) = Win32::DriveInfo::DriveSpace($drivefastq);
	$drivefastqtotalsize = $total;
	$drivefastqfreesize = $free;
	#print "\nFastq Drive: Size = $total, Free = $free\n";
	}
else {
	print "\nWarning: Not able to capture Fastq Drive size...\n";}
#looking for the report file and already present FastQ files
my $reportout;
my @fastqout;
my $k1 = 0;
while (defined($outputcontent[$k1])) {
	if(uc $outputcontent[$k1] eq 'FASTQREPORT.TXT') {
		$reportout = $outputdir . "\\FASTQREPORT.TXT";}
	if($outputcontent[$k1] =~ m/\.FASTQ$/i) {
		$fastqout[++$fastqout[0][0]][1] = $outputcontent[$k1];#fastq file name
		$fastqout[$fastqout[0][0]][2] =  $outputdir . "\\$outputcontent[$k1]";}#fastq file pathname
	++$k1;}
if (not defined($reportout)){#so nothing
	$reportout = $outputdir . "\\FASTQREPORT.TXT";}
open(REPORT,">>$reportout") ||
	die "Critical Error: Cannot create the output REPORT file: $reportout, $!";
print "\nStarting from now the run follow-up is recorded in the REPORT file:\n\t$reportout\n\n";
print REPORT "Date_Time\t$rundatetime\nCode\t$code\nOuputDir\t$outputdir\nWorkingDir\t$currentdir\n7-zipExec\t$sevenzipexe\nInitialOverwrite\t$overwrite\n";


#dealing with the Data file (should always be regenerated after run)
#so here deleting previous one

my $outdata  = $outputdir . "\\FASTQDATA.TXT";
if (-e $outdata) {
	if (unlink $outdata) {}
	else {
		print REPORT "RunStatus\tFailure\tCannot erase previous data file $outdata, $!\n";
		close REPORT;
		die "Cannot erase previous data file $outdata, $!\n";}}
if (open(DATA,">>$outdata")) {
	print DATA 	"OutputFilename\n";
	close DATA;}#we will fill it at end of process
else {
	print REPORT "RunStatus\tFailure\tCannot create new data file $outdata, $!\n";
	close REPORT;
	die "Cannot create new data file $outdata, $!\n";}
#fetching recursively fastq.gz in input folder(s)

my @folderarr;
my $pointerfolderarr = 0;
my $inputdir = $ARGV{'--inputfolder'};
my $regexp;
#next is to eventually switch to windows format (slaches to backslaches) 
while($inputdir =~ s/\//\\/){}
#removing quote and double quote
while($inputdir =~ s/\'//) {}
while($inputdir =~ s/\"//) {}
if ($inputdir =~ m/^(.+)\\\*$/) {#means all within a folder; removing \*
	$inputdir = $1;}
if ($inputdir =~ m/^(.+)\\$/) {#means all within a folder; removing last \
	$inputdir = $1;}
if (!-d $inputdir) {#so means error in dirname or using wild card * for subfolders
	if ($inputdir =~ m/^(.*)\\([^\\^\*]*)\*$/) {#so wild card is used for subfolder
		$inputdir = $1;
		$regexp = uc $2;
		my @tempdirarr;
		if (opendir (INDIR,"$inputdir")) { 
			@tempdirarr = grep {$_ ne "." & $_ ne ".."} readdir INDIR;#fetching all files/folders in folder
			closedir INDIR;}
		else {
			print REPORT "RunStatus\tFailure\tCannot read from main folder $inputdir, $!\n";
			close REPORT;
			die "Cannot read from main folder $inputdir, $!";}
		my $k2 = 0;
		while (defined($tempdirarr[$k2])) {
			my $checkdir = $inputdir . "\\$tempdirarr[$k2]";
			if ((-d $checkdir) && ($tempdirarr[$k2] =~ m/^$regexp/i)) {
				$folderarr[$pointerfolderarr] = $checkdir;
				++$pointerfolderarr;}
			++$k2;}}
	else {
		print REPORT "RunStatus\tFailure\tUnable to find input folder $inputdir, correct and try again, $!\n";
		close REPORT;
		die "Unable to find input folder $inputdir, correct and try again, $!";}}
else {# so only one folder to search 
	$folderarr[0] = $inputdir;}
if (not defined($folderarr[0])) {
	print REPORT "RunStatus\tFailure\tUnable to find any input folder from $inputdir, correct and try again, $!\n";
	close REPORT;
	die "Unable to find any input folder from $inputdir, correct and try again, $!";}
	
#not really fetching recursively

my @fastqgzarr;
find(\&recordentry, @folderarr);
if (not defined($fastqgzarr[0][0])) {
	print REPORT "RunStatus\tFailure\tUnable to identify any .fastq.gz file from input folder(s), $!\n";
	close REPORT;
	die "Unable to identify any .fastq.gz file from input folder(s), $!";}

#checking if no duplicates (if so removing)

$k1 = 1;
while ($k1 < $fastqgzarr[0][0]) {
	my $k2 = $k1+1;
	while ($k2 <= $fastqgzarr[0][0]) {
		# next is for windows...uppercase...
		if (uc $fastqgzarr[$k1][1] eq uc $fastqgzarr[$k2][1]) {
			$fastqgzarr[$k2][4] = 1;}#flag already seen
		++$k2;}
	++$k1;}
	
my @tempgzarr;#temporary array to remove the duplicates
$k1 = 1;
while ($k1 <= $fastqgzarr[0][0]) {
	if(not defined($fastqgzarr[$k1][4])) {
		$tempgzarr[++$tempgzarr[0][0]][1] = $fastqgzarr[$k1][1];
		$tempgzarr[$tempgzarr[0][0]][2] = $fastqgzarr[$k1][2];
		$tempgzarr[$tempgzarr[0][0]][3] = $fastqgzarr[$k1][3];}
	++$k1}
my $nbrdupli = $fastqgzarr[0][0] - $tempgzarr[0][0];#nbr of duplicates
undef @fastqgzarr;
@fastqgzarr = @tempgzarr;
undef @tempgzarr;
print "Identified $fastqgzarr[0][0] FastQ.gz file(s) (duplicate(s) removed = $nbrdupli)\n";
print REPORT "FastQgzFiles\t$fastqgzarr[0][0]\nDuplicates\t$nbrdupli\n";

# checking if some are already gunzip

$k1 = 1;
my $somedone = 0;#flag for some already gunzip
while ($k1 <= $fastqgzarr[0][0]) {
	my $k2 = 1;
	CATCHDONE:
	while (defined($fastqout[$k2][1])) {
		# next is for windows...uppercase...
		if (uc $fastqgzarr[$k1][3] eq uc $fastqout[$k2][1]) {
			$fastqgzarr[$k1][4] = 1;#reuse this box as undef @fastqgzarr in between
			++$somedone;#flag on
			last CATCHDONE;}
		++$k2;}
	++$k1;}
if ($somedone != 0) {#some are done so question about overwriting
	ANSWEROW:
	while (1>0) {#will run until YES or NO answer
		print "\nThere are some files already gunzipped in output folder.\nWould you like to overwrite (Yes/No):";
		my $answer = uc <STDIN>;
		chomp $answer;
		if (($answer eq 'YES') || ($answer  eq 'NO')) {
			$overwrite = $answer;
			last ANSWEROW;}
		else {
			print "\nBad answer(should be YES or NO). Try again or Ctrl-C to quit.\n";}}}
print REPORT "FinalOverwriting\t$overwrite\n";

#last but not least: should FastQ.gz source files be archived
my $gzarchdir = $ARGV{'--gzarchivingfolder'};
my $gzarchivingval = 0;
if ($gzarchdir ne 'NOGZARCHIVING') {
	if ((!-e $gzarchdir) || (!-d $gzarchdir)) {
		print "\n\nThe folder:\n\t$gzarchdir\nyou provided for archiving FastQ.gz source files:\n\t1. Does not exist OR\n\t2. Is not a folder OR\n\t3. You do not have rights to use it.\n\t4.Folder contains space/blank (So try simple \' or double \" quoting)\n\n";
		GZARCHDIR:
		while (1>0) {
			print "\nYou can try again giving a new folder (or type \"Skip\" to skip archiving):";
			my $answergzarch = <STDIN>;
			chomp $answergzarch;
			if (uc $answergzarch eq 'SKIP') {
				$gzarchivingval = 0;
				last GZARCHDIR;}
			elsif ((-e $answergzarch) &&  (-d $answergzarch)) {
				$gzarchdir =$answergzarch;
				$gzarchivingval = 1;
				last GZARCHDIR;}
			else {
				print "\nSorry it does not make it neither.\n";}}}
	else {
		$gzarchivingval = 1;}}
else {
	$gzarchivingval = 0;}

if ($gzarchivingval == 1) {
#fetching drive size and free left size
	if ($gzarchdir =~ m/^([A-Z])\:/i) {
		$drivefastqgz = $1;
		my (undef, undef, undef, undef, undef, $total, $free) = Win32::DriveInfo::DriveSpace($drivefastqgz);
		$drivefastqgztotalsize = $total;
		$drivefastqgzfreesize = $free;
		#print "\nFastqgz Drive: Size = $total, Free = $free\n";
		}
	else {
		print "\nWarning: Not able to capture Fastq Drive size...\n";}}
		
#last add-on: evaluation of drive space left for decompressed FastQ files and for archiving FastQ.gz files
$totalfastqsize = $totalfastqgzsize * $ratiogznotgz;
#checking if decompression is OK
my $finalleftspace = $drivefastqfreesize - $totalfastqsize;
my $evalleftspace = $finalleftspace / $drivefastqtotalsize;
if ($evalleftspace < 0){
	$evalleftspace = 0;}
my $pctevalleftspace = sprintf("%.1f", ($evalleftspace * 100));
my $gbevalleftspace = sprintf("%.1f",($finalleftspace / 1000000000));
if ($evalleftspace <= $sizestop) {
	print "\nWARNING!!! Decompressing FastQ.gz files will leave only $pctevalleftspace\% free space\nmeans $gbevalleftspace Gb on target drive $drivefastq.\nWe do recommend to stop here process.\n";
	ANSWERFASTQSPACE:
	while (1 > 0) {
		print "\nWould you like to continue (YES/NO):";
		my $answerstop = <STDIN>;
		chomp $answerstop;
		if (uc $answerstop eq 'NO') {
			die "See you next time. Bye!";}
		elsif (uc $answerstop eq 'YES') {
			while (1 > 0) {
			print "\nAre sure you like to continue (YES/NO):";
			my $answerstop2 = <STDIN>;
			chomp $answerstop2;
			if (uc $answerstop2 eq 'NO') {
				die "See you next time. Bye!";}
			elsif (uc $answerstop2 eq 'YES') {
				last ANSWERFASTQSPACE;}
			else {
				print "\nBad answer. I want a YES or NO. Try again.\n";}}}
		else {
			print "\nBad answer. I want a YES or NO. Try again.\n";}}}
else {
	print "\nFor Info. Decompressing FastQ.gz files will leave $pctevalleftspace\% free space\nmeans $gbevalleftspace Gb on target drive $drivefastq.\n";}
#checking if archiving is OK
my $finalleftspacegz = $drivefastqgzfreesize - $totalfastqgzsize;
my $evalleftspacegz = $finalleftspacegz / $drivefastqgztotalsize;
if ($evalleftspacegz < 0){
	$evalleftspacegz = 0;}
my $pctevalleftspacegz = sprintf("%.1f", ($evalleftspacegz * 100));
my $gbevalleftspacegz = sprintf("%.1f",($finalleftspacegz / 1000000000));
if ($evalleftspacegz <= $sizestop) {
	print "\nWARNING!!! Archiving FastQ.gz files will leave only $pctevalleftspacegz\% free space\nmeans $gbevalleftspacegz Gb on target drive $drivefastqgz.\nWe do recommend to stop here process.\n";
	ANSWERFASTQSPACEGZ:
	while (1 > 0) {
		print "\nWould you like to continue (YES/NO):";
		my $answerstopgz = <STDIN>;
		chomp $answerstopgz;
		if (uc $answerstopgz eq 'NO') {
			die "See you next time. Bye!";}
		elsif (uc $answerstopgz eq 'YES') {
			while (1 > 0) {
			print "\nAre sure you like to continue (YES/NO):";
			my $answerstop2gz = <STDIN>;
			chomp $answerstop2gz;
			if (uc $answerstop2gz eq 'NO') {
				die "See you next time. Bye!";}
			elsif (uc $answerstop2gz eq 'YES') {
				last ANSWERFASTQSPACEGZ;}
			else {
				print "\nBad answer. I want a YES or NO. Try again.\n";}}}
		else {
			print "\nBad answer. I want a YES or NO. Try again.\n";}}}
else {
	print "\nFor Info. Archiving FastQ.gz files will leave $pctevalleftspacegz\% free space\nmeans $gbevalleftspacegz Gb on target drive $drivefastqgz.\n";}
#print "\n\t$totalfastqgzsize\n\t$totalfastqsize\n\t$drivefastq\n\t$drivefastqgz\n\t$drivefastqtotalsize\n\t$drivefastqgztotalsize\n\t$drivefastqfreesize\n\t$drivefastqgzfreesize\n";

#so lets go for gunzip

print REPORT "Date_Time\tArchiveFile\tInfo\n";
$k1 =1;
while ($k1 <= $fastqgzarr[0][0]) {
	if (defined($fastqgzarr[$k1][4])) {
		if (uc $overwrite eq 'YES') {# so force overwriting -aoa switch
			system "\"$sevenzipexe\" e \"$fastqgzarr[$k1][2]\" -o\"$outputdir\" -aoa";
			my $showtime = getdate();
			print "$showtime Overwrite done for  $fastqgzarr[$k1][2]\n";
			print REPORT "$showtime\t$fastqgzarr[$k1][1]\tExtracted(Overwritten)\n";}
		else {
			my $showtime = getdate();
			print "$showtime $fastqgzarr[$k1][2] skipped\n";
			print REPORT "$showtime\t$fastqgzarr[$k1][1]\tSkipped(AlreadyExists)\n";}}
	else {
		system "\"$sevenzipexe\" e \"$fastqgzarr[$k1][2]\" -o\"$outputdir\"";
		my $showtime = getdate();
		print "$showtime Creation done for  $fastqgzarr[$k1][2]\n";
		print REPORT "$showtime\t$fastqgzarr[$k1][1]\tExtracted(CreatedNew)\n";}
	++$k1;}
	
#last part is to collect in a data file all FastQ in the outpit folder
my @finaloutfiles;
my $countfastq = 0;
if(open(DATA,">>$outdata")) { #should be (tested previously)
	if (opendir (OUTDIR,"$outputdir")) {
		@finaloutfiles = grep {$_ ne "." & $_ ne ".."} readdir OUTDIR;#fetching all files/folders in folder
		closedir OUTDIR;}
	else {
		print REPORT "RunStatus\tFailure\tUnable read from output folder $outputdir, $!\n";
		close REPORT;
		close DATA;
		die "Unable read from output folder $outputdir, $!\n";}
	my $k2 = 0;
	while(defined($finaloutfiles[$k2])) {
		if ($finaloutfiles[$k2] =~ m/\.FASTQ$/i) {
			++$countfastq;
			print DATA "$finaloutfiles[$k2]\n";}
		++$k2;}
	close DATA;}
else {
	print REPORT "RunStatus\tFailure\tUnable to write in output DATA file $outdata, $!\n";
	close REPORT;
	die "Unable to write in output DATA file $outdata, $!\n";}

# Now the archiving of source FastQ.gz files if requested
if ($gzarchivingval == 1) {
	$k1 =1;
	while ($k1 <= $fastqgzarr[0][0]) {
		my $tocopy = $fastqgzarr[$k1][2];
		my $copy = 	$gzarchdir . "\\$fastqgzarr[$k1][1]";
		if (!-e $copy) {#not yet archived
			copy($tocopy, $copy);}
		++$k1;}
	my $showtime = getdate();
	print REPORT "$showtime\tFastQ.gz Source files archived in $gzarchdir\n";}	

#finalizing the job
my $showtime = getdate();
print REPORT "$showtime\tJob completed\nFastqFiles\t$countfastq\nRunStatus\tSuccess\n";
close REPORT;

print "\n\nJob completed by $showtime (started by $rundatetime).\n$countfastq FastQ files are in output folder $outputdir as well as a REPORT and a DATA file summarizing process.\n\nSee you next time.\n\t$code\n";

#function used in File::Find fior recursive
sub recordentry {
	my $infile = $_;
    my $fullname = $File::Find::name;
    #next is to be sure everything is windows compatible with backslaches
    while ($fullname =~ s/\//\\/) {}
    if($infile =~ m/\.FASTQ\.GZ$/i) {
		$fastqgzarr[++$fastqgzarr[0][0]][1] = $infile;
		$fastqgzarr[$fastqgzarr[0][0]][2] = $fullname;
		my $sizegz = -s $fullname;
		$totalfastqgzsize = $totalfastqgzsize + $sizegz;
		if ($infile =~ m/^(.+)\.GZ$/i) {#corresponding name gunzip
			$fastqgzarr[$fastqgzarr[0][0]][3] = $1;}}
	return();}
###########OK
sub getdate {
    #sub to capture GMT date and time
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = gmtime;#catch date starting process
    $year = $year + 1900;#$year was number of years since 1900
    $mon = $mon + 1;#first day is zero!!!
    if ($mon < 10) {
	$mon = "0" . $mon;}
    if ($mday < 10) {
	$mday = "0" . $mday;}
    if ($hour < 10) {
	$hour = "0" . $hour;}
    if ($min < 10) {
	$min = "0" . $min;}
    if ($sec < 10) {
	$sec = "0" . $sec;}
    my $date = "$year$mon$mday";
    my $time = "$hour$min$sec";
    my $xdatetime = $date ."_$time";
    return $xdatetime;}
#677968693279877869823280736982826932696779678132535748555051505432666947666976#
################################################################################

=head1 NAME

FetchFastQgs_v1i1.pl

=head1 HELP

This code has been developped on a Windows 10 64bit platform.

This codes requires Perl installed as well as some Perl modules as well
as 7-Zip for Windows 64bit platforms.

Scope:

This code catches all FastqQ.gz files recursively from one location (folder)
provided as argument --inputfolder and gunzip these files in a unique folder
(provided as argument --outputfolder). Optional argument --gzarchivingfolder
can be used to record source FastQ.gz files in a single location.

Important: The output folder MUST exist prior running this code

Remark: Use wildcard *: e.g. /OGM-23136142/* will match all FastQ.gz files
under /OGM-23136142 folder while /OGM-23136142/S5* will match only FastQ.gz
files in sub-folders with names starting with S5.

Optional: (argument --overwrite <Yes or No> Default is No
Means: if FastQ exists in output folder do not gunzip again.

VERY IMPORTANT: 7-Zip does not extract under the given filename of the .gz
file but using the filename embedded in the archive itself ... So no way to
manipulate filenames of .gz files

For additionnal info. contact the code Owner/Author.

=head1 VERSION

This documentation refers to FetchFastQgs_v1i1.pl (version 1, issue 1)

=head1  USAGE

	NGSvsPCRFluo.pl --inputfolder [=] <inputfolder> --outputfolder [=] <outputfolder> [options]
	
	Important: folder names may be impacted by the quoting.
	
	Example of command line (that works):
	
	perl FetchFastQgz_v1i1.pl
	--sevenzip C:\7Zipexe\7-Zip
	--inputfolder C:\GeneticsCHU\FetchFastQgz\TestInputFastQ
	--outputfolder C:\GeneticsCHU\FetchFastQgz\TestOutputFastQ 
	--gzarchivingfolder C:\GeneticsCHU\FetchFastQgz\TestgzArchives 
	--overwrite YES

=head1 REQUIRED ARGUMENTS

=over

=item --inputfolder [=] <inputdir>

Path to folder to search recursively FastQ.gz files.

=for Euclid:
	inputdir.type: string
	
=item --outputfolder [=] <outputdir>

Path to folder used for recording output FastQ files

=for Euclid:
	outputdir.type: string
	
=item --sevenzip [=] <sevenzipdir>

Path to folder where is located the 7z.exe executable (decompression).
You can download and install 7-zip from the followin location:

	http://www.7-zip.org/download.html

=for Euclid:
	sevenzipdir.type: string	
	
For more info. contact the code OWNER.

=back

=head1 OPTIONS

=item --gzarchivingfolder [=] <gzarchivingdir>

Path to a folder to record FastQ.gz source files (if not given, no archiving)

=for Euclid:
	gzarchivingdir.type: string
	gzarchivingdir.default: 'NOGZARCHIVING'
	
=item --overwrite [=] <overwrite>

Option to overwrite or not (yes or no; default is no)

=for Euclid:
	overwrite.type: string
	overwrite.default: 'NO'

=over

=back
	
=item --version

=item --usage

=item --help

=item --man

=back

=head1 AUTHOR

LECOCQ Pierre 59072327136 (Pierre.Lecocq@NGYX.eu)

=head1 BUGS

If bug is identified please contact code Owner/Author.

=head1 COPYRIGHT

Copyright (c) 2016FEB29, code Owner: LECOCQ Pierre 59072327136 BE/BEL.
All Rights Reserved.

This program is not free software. It may not be used , redistributed
and/or modified without code Owner/Author authorisation. Exception to 
the previous is made for active members of the "Service de Génétique du 
Centre Hospitalier Universitaire de l'Université de Liège BE/BEL".

677968693279877869823280736982826932696779678132535748555051505432666947666976
