From 831ad0cd1af490b93a0e36fd42c3e5d20dac960c Mon Sep 17 00:00:00 2001 From: ebanks Date: Fri, 22 Apr 2011 13:23:33 +0000 Subject: [PATCH] Quit immediately with an error message if any of the individual steps fails. git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5677 348d0f76-0448-11de-a6fe-93d51630548a --- perl/liftOverVCF.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/perl/liftOverVCF.pl b/perl/liftOverVCF.pl index a03a4fe16..7039e111f 100755 --- a/perl/liftOverVCF.pl +++ b/perl/liftOverVCF.pl @@ -40,7 +40,7 @@ my $cmd = "java -jar $gatk/dist/GenomeAnalysisTK.jar -T LiftoverVariants -R $old if ($recordOriginalLocation) { $cmd .= " -recordOriginalLocation"; } -system($cmd); +system($cmd) == 0 or quit("The liftover step failed. Please correct the necessary errors before retrying."); # we need to sort the lifted over file now print "\nRe-sorting the vcf...\n"; @@ -62,12 +62,12 @@ close(UNSORTED); close(SORTED); $cmd = "grep \"^#\" -v $unsorted_vcf | sort -n -k2 -T $tmp | $gatk/perl/sortByRef.pl --tmp $tmp - $newRef.fasta.fai >> $sorted_vcf"; -system($cmd); +system($cmd) == 0 or quit("The sorting step failed. Please correct the necessary errors before retrying."); # Filter the VCF for bad records print "\nFixing/removing bad records...\n"; $cmd = "java -jar $gatk/dist/GenomeAnalysisTK.jar -T FilterLiftedVariants -R $newRef.fasta -B:variant,vcf $sorted_vcf -o $out"; -system($cmd); +system($cmd) == 0 or quit("The filtering step failed. Please correct the necessary errors before retrying."); # clean up unlink $unsorted_vcf; @@ -76,3 +76,8 @@ my $sorted_index = "$sorted_vcf.idx"; unlink $sorted_index; print "\nDone!\n"; + +sub quit { + print "\n$_[0]\n"; + exit(1); +}