From b858a9d73e4f24e4e1f268cad7445cd46f3783f3 Mon Sep 17 00:00:00 2001
From: "Gervaise H. Henry" <gervaise.henry@utsouthwestern.edu>
Date: Sun, 28 Feb 2021 16:23:05 -0600
Subject: [PATCH] Disconnect confidence from species and seq type inference

---
 rna-seq.nf | 69 +++++++++++++++++++++++++++++-------------------------
 1 file changed, 37 insertions(+), 32 deletions(-)

diff --git a/rna-seq.nf b/rna-seq.nf
index eb7e075..cb1e7f4 100644
--- a/rna-seq.nf
+++ b/rna-seq.nf
@@ -741,6 +741,11 @@ process seqwho {
       seqtypeConfidenceR2="1"
     fi
 
+    speciesErrorSeqwho=false
+    speciesErrorSeqwho_details=""
+    seqtypeError=false
+    seqtypeError_details=""
+
     # convert numeric confidence to string
     if [ \${speciesConfidenceR1} == "1" ]
     then
@@ -768,46 +773,46 @@ process seqwho {
     fi
     echo -e "LOG: confidence converted to string" >> ${repRID}.seqwho.log
 
-    # detect errors
-    speciesErrorSeqwho=false
-    speciesErrorSeqwho_details=""
-    seqtypeError=false
-    seqtypeError_details=""
-    if [ "\${confidenceR1}" == "high" ] && [ "\${confidenceR2}" == "high" ]
+    # set species
+    if [ "\${speciesR1}" == "\${speciesR2}" ]
     then
-      echo -e "LOG: high confidence inference detected" >> ${repRID}.seqwho.log
-      if [ "\${speciesR1}" == "\${speciesR2}" ]
+      speciesInfer=\${speciesR1}
+      if [ "\${speciesInfer}" == "human" ]
       then
-        speciesInfer=\${speciesR1}
-        if [ "\${speciesInfer}" == "human" ]
-        then
-          speciesInfer="Homo sapiens"
-        elif [ "\${speciesInfer}" == "mouse" ]
-        then
-          speciesInfer="Mus musculus"
-        fi
-        echo -e "LOG: concordant species inference: \${speciesInfer}" >> ${repRID}.seqwho.log
-      else
-        speciesErrorSeqwho=true
-        speciesErrorSeqwho_details="**Infered species does not match for R1 and R2:** Infered R1 = \${speciesR1} and infered R2 = \${speciesR2}"
-        echo -e "LOG: inference error: \${speciesErrorSeqwho_details}" >> ${repRID}.seqwho.log
+        speciesInfer="Homo sapiens"
+      elif [ "\${speciesInfer}" == "mouse" ]
+      then
+        speciesInfer="Mus musculus"
       fi
-      if [ "\${seqtypeR1}" == "\${seqtypeR2}" ]
+      echo -e "LOG: concordant species inference: \${speciesInfer}" >> ${repRID}.seqwho.log
+    else
+      speciesErrorSeqwho=true
+      speciesErrorSeqwho_details="**Infered species does not match for R1 and R2:** Infered R1 = \${speciesR1} and infered R2 = \${speciesR2}"
+      echo -e "LOG: inference error: \${speciesErrorSeqwho_details}" >> ${repRID}.seqwho.log
+    fi
+
+    # set seq type
+    if [ "\${seqtypeR1}" == "\${seqtypeR2}" ]
+    then
+      if [ "\${seqtypeR1}" == "rnaseq" ]
       then
-        if [ "\${seqtypeR1}" == "rnaseq" ]
-        then
-          seqtpeInfer="rnaseq"
-          echo -e "LOG: concordant rnaseq seq type inference detected" >> ${repRID}.seqwho.log
-        else
-          seqtypeError=true
-          seqtypeError_details="**Infered sequencing type is not mRNA-seq:** Infered = \${seqtypeR1}"
-          echo -e "LOG: inference error: \${seqtypeError_details}" >> ${repRID}.seqwho.log
-        fi
+        seqtpeInfer="rnaseq"
+        echo -e "LOG: concordant rnaseq seq type inference detected" >> ${repRID}.seqwho.log
       else
         seqtypeError=true
-        seqtypeError_details="**Infered sequencing type does not match for R1 and R2:** Infered R1 = \${seqtypeR1} and infered R2 = \${seqtypeR2}"
+        seqtypeError_details="**Infered sequencing type is not mRNA-seq:** Infered = \${seqtypeR1}"
         echo -e "LOG: inference error: \${seqtypeError_details}" >> ${repRID}.seqwho.log
       fi
+    else
+      seqtypeError=true
+      seqtypeError_details="**Infered sequencing type does not match for R1 and R2:** Infered R1 = \${seqtypeR1} and infered R2 = \${seqtypeR2}"
+      echo -e "LOG: inference error: \${seqtypeError_details}" >> ${repRID}.seqwho.log
+    fi
+
+    # detect confidence errors
+    if [ "\${confidenceR1}" == "high" ] && [ "\${confidenceR2}" == "high" ]
+    then
+      echo -e "LOG: high confidence inference detected" >> ${repRID}.seqwho.log
     else
       speciesErrorSeqwho=true
       speciesErrorSeqwho_details=\$(echo "**Infered species and or sequencing type confidence is low:**\\n")
-- 
GitLab