From 700bfa35e4032ef19a9cab2fb4bdda1fb7e1f0a6 Mon Sep 17 00:00:00 2001
From: bow <bow@bow.web.id>
Date: Sun, 15 Feb 2015 23:36:13 +0100
Subject: [PATCH] Precompile regex for splitting read IDs

---
 .../src/main/scala/nl/lumc/sasc/biopet/tools/FastqSync.scala | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSync.scala b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSync.scala
index 43ac955e4..b16e205e7 100644
--- a/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSync.scala
+++ b/public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/tools/FastqSync.scala
@@ -90,9 +90,12 @@ class FastqSync(val root: Configurable) extends BiopetJavaCommandLineFunction {
 
 object FastqSync extends ToolCommand {
 
+  /** Regex for capturing read ID ~ taking into account its read pair mark (if present) */
+  private val idRegex = "[_/][12]\\s??|\\s".r
+
   /** Implicit class to allow for lazy retrieval of FastqRecord ID without any read pair mark */
   private implicit class FastqPair(fq: FastqRecord) {
-    lazy val fragId = fq.getReadHeader.split("[_/][12]\\s??|\\s")(0)
+    lazy val fragId = idRegex.split(fq.getReadHeader)(0)
   }
 
   /**
-- 
GitLab