From ad9322c4f26045f9d80d8680043579f48509363a Mon Sep 17 00:00:00 2001
From: ameyner2 <alison.meynert@igmm.ed.ac.uk>
Date: Fri, 18 Oct 2019 19:10:30 +0100
Subject: [PATCH] Fixed filename fixing

---
 submit_bcbio_trio_wes.sh | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/submit_bcbio_trio_wes.sh b/submit_bcbio_trio_wes.sh
index 9fd1274..a03a424 100755
--- a/submit_bcbio_trio_wes.sh
+++ b/submit_bcbio_trio_wes.sh
@@ -41,10 +41,12 @@ then
 
   # fix VCF output file names
   cd $OUTPUT_DIR/${DATE}_${PROJECT_ID}_${FAMILY_ID}
-  if [ -e ${PROJECT_ID}${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz ]
+  if [ ! -e ${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz ]
   then
-    mv ${PROJECT_ID}${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz ${PROJECT_ID}_${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz
-    mv ${PROJECT_ID}${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz.tbi ${PROJECT_ID}_${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz.tbi
+    PREFIX=`echo $FAMILY_ID | cut -d '_' -f 1`
+    SUFFIX=`echo $FAMILY_ID | cut -d '_' -f 2`
+    mv ${PREFIX}${SUFFIX}-gatk-haplotype-annotated.vcf.gz ${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz
+    mv ${PREFIX}${SUFFIX}-gatk-haplotype-annotated.vcf.gz.tbi ${FAMILY_ID}-gatk-haplotype-annotated.vcf.gz.tbi
   fi
 
 else
-- 
GitLab