From b3128fbb48f967057cd057f2fa9d23714ffdb055 Mon Sep 17 00:00:00 2001
From: kohleman <kohleman>
Date: Thu, 15 Dec 2016 13:39:47 +0000
Subject: [PATCH] handle the case of re-registering a single lane

SVN: 37511
---
 .../source/BDS/analysis_bcl2fastq.bds               | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/deep_sequencing_unit/source/BDS/analysis_bcl2fastq.bds b/deep_sequencing_unit/source/BDS/analysis_bcl2fastq.bds
index 3d5ddc8329d..7085666c1b9 100755
--- a/deep_sequencing_unit/source/BDS/analysis_bcl2fastq.bds
+++ b/deep_sequencing_unit/source/BDS/analysis_bcl2fastq.bds
@@ -632,8 +632,6 @@ void rsyncDemultiplexedFiles (int [] laneCount) {
             string newFolderName = "Undetermined_" + cleanString(fcName) + "_" + lane
             #Undetermined_000000000_AH4PH_1
             string newFolderPath = searchFolder + "/" + newFolderName
-            newFolderPath.mkdir()
-            print("Created $newFolderPath\n")
 
             # Assuming it is only one lane
             if (listOfLanes.size() == 1 && listOfLanes[0] == 1) {
@@ -643,9 +641,15 @@ void rsyncDemultiplexedFiles (int [] laneCount) {
                 filesPerLane = searchFolder.dir("*L00" + lane + "*.fastq.gz")
             }
 
+            newFolderPath.mkdir()
+            print("Created $newFolderPath\n")
+
             for (string fastqFile : filesPerLane) {
-                sys mv "$searchFolder/$fastqFile" "$searchFolder/$newFolderName"
-                sys ln -s "$searchFolder/$newFolderName/$fastqFile" "$searchFolder/$fastqFile"
+                string moveAndLinkID task ( canFail := true, cpus := 1 ){
+                    # sys echo "$searchFolder/$fastqFile" "$searchFolder/$newFolderName" 
+                    sys [[ -f "$searchFolder/$fastqFile" ]] && mv "$searchFolder/$fastqFile" "$searchFolder/$newFolderName/"
+                    sys [[ ! -f "$searchFolder/$fastqFile" ]] && ln -s "$searchFolder/$newFolderName/$fastqFile" "$searchFolder/$fastqFile"
+                }
             }
             sys chmod -R 774 "$newFolderPath"
 
@@ -674,7 +678,6 @@ void rsyncDemultiplexedFiles (int [] laneCount) {
                          "$nohupFile", \
                          "$unalignedData/$sampleFolder", \
                          "$unalignedData/$marker$sampleFolder")
-
             }
     }
 }
-- 
GitLab