Description: Fix Python3.12 string syntax
Bug-Debian: https://bugs.debian.org/1085772
Author: Andreas Tille <tille@debian.org>
Last-Update: 2024-06-09

--- a/pbsuite/utils/BamStat.py
+++ b/pbsuite/utils/BamStat.py
@@ -72,7 +72,7 @@ def expandMd(md):
     Turns abbreviated MD into a full array
     """
     ret = []
-    for i in re.findall("\d+|\^?[ATCGN]+", md):
+    for i in re.findall(r"\d+|\^?[ATCGN]+", md):
         if i.startswith('^'):
             ret.extend(list(i[1:]))
         elif i[0] in ["A","T","C","G","N"]:
--- a/pbsuite/utils/FileHandlers.py
+++ b/pbsuite/utils/FileHandlers.py
@@ -46,7 +46,7 @@ class FastaFile(dict):
             buffer.append( ">" + key + "\n" + wrap(self[key]).strip())
         return "\n".join(buffer)
 
-splRE = re.compile("\s+")
+splRE = re.compile(r"\s+")
 class QualFile(dict):
     
     def __init__(self, fileName, convert=True):
@@ -57,7 +57,7 @@ class QualFile(dict):
         self.fileHandler.close()
     
     def __parse(self):
-        splRE = re.compile("\s+")
+        splRE = re.compile(r"\s+")
         for line in self.fileHandler.readlines():
             if line.startswith('>'):
                 curName = line.strip()[1:]
@@ -84,7 +84,7 @@ class QualFile(dict):
             self[curName].write(line.strip() + " ")
         
         for key in self:
-            self[key] = list(map(int, re.split("\s+", self[key].getvalue().strip())))
+            self[key] = list(map(int, re.split(r"\s+", self[key].getvalue().strip())))
     
     def toString(self):
         buffer = []
@@ -472,7 +472,7 @@ qname tname score pctsimilarity qstrand
 tstrand tstart tend tseqlength [mapqv ncells npaths]
 """
 
-subreadGrab = re.compile(".*/(\d+)_(\d+)$")
+subreadGrab = re.compile(r".*/(\d+)_(\d+)$")
 
 class M4File(list):
 
@@ -496,7 +496,7 @@ class M4File(list):
 class M4Line():
     
     def __init__(self, line):
-        data = re.split("\s+",line)
+        data = re.split(r"\s+",line)
         
         self.qname          = data[0]
         self.tname          = data[1]
@@ -606,7 +606,7 @@ class M5File(list):
 class M5Line():
     
     def __init__(self, line):
-        data = re.split("\s+",line)
+        data = re.split(r"\s+",line)
 
         self.qname      = data[0]
         self.qseqlength = int(data[1])
--- a/pbsuite/utils/VCFIO.py
+++ b/pbsuite/utils/VCFIO.py
@@ -107,10 +107,10 @@ class VCFFile():
         
 
 
-METARE = re.compile(('##\s*(?P<key>\w+)\s*=\s*\<\s*ID\s*=\s*(?P<id>\w+)\s*'
-                     ',\s*(Number\s*=\s*(?P<number>[0-9.])\s*,'
-                     '\s*Type\s*=\s*(?P<type>\w+)\s*,)?'
-                     '\s*Description\s*=\s*"(?P<description>.*)"\s*\>\s*'),\
+METARE = re.compile((r'##\s*(?P<key>\w+)\s*=\s*\<\s*ID\s*=\s*(?P<id>\w+)\s*'
+                     r',\s*(Number\s*=\s*(?P<number>[0-9.])\s*,'
+                     r'\s*Type\s*=\s*(?P<type>\w+)\s*,)?'
+                     r'\s*Description\s*=\s*"(?P<description>.*)"\s*\>\s*'),\
                      re.IGNORECASE)
 
 class META():
--- a/pbsuite/utils/jellyoutputrename.py
+++ b/pbsuite/utils/jellyoutputrename.py
@@ -19,7 +19,7 @@ for entry in fasta:
 
 liftOver = json.load(open(sys.argv[2],'r'))
 jellyFasta = FastaFile(sys.argv[3])
-regex = re.compile("ref\d{7}")
+regex = re.compile(r"ref\d{7}")
 for key in liftOver:
     myRefs = set()
     for id, strand, size in liftOver[key]:
--- a/pbsuite/banana/MakeOverlapTable.py
+++ b/pbsuite/banana/MakeOverlapTable.py
@@ -7,7 +7,7 @@ from collections import deque
 from pbsuite.utils.setupLogging import *
 from pbsuite.jelly.Support import AlignmentConnector, SUPPORTFLAGS
 
-subreadGrab = re.compile(".*/(\d+)_(\d+)$")
+subreadGrab = re.compile(r".*/(\d+)_(\d+)$")
 
 def natural_sort(l): 
     """
@@ -23,7 +23,7 @@ def natural_sort(l):
 class M4Line():
     
     def __init__(self, line):
-        data = re.split("\s+",line)
+        data = re.split(r"\s+",line)
         
         self.qname          = data[0]
         self.tname          = data[1]
--- a/pbsuite/banana/MakeReciprocal.py
+++ b/pbsuite/banana/MakeReciprocal.py
@@ -9,7 +9,7 @@ USAGE = """%prog <chunk> <stride>
 Run this in the directory where you've made a whole bunch of alignment chunks.
 For any Chunk A that has been Mapped to B, we'll make the reciprocal of B mapped to A"""
 
-subreadGrab = re.compile(".*/(\d+)_(\d+)$")
+subreadGrab = re.compile(r".*/(\d+)_(\d+)$")
 
 class M4File(list):
 
@@ -33,7 +33,7 @@ class M4File(list):
 class M4Line():
     
     def __init__(self, line):
-        data = re.split("\s+",line)
+        data = re.split(r"\s+",line)
         
         self.qname          = data[0]
         self.tname          = data[1]
--- a/pbsuite/banana/OLCAssembly.py
+++ b/pbsuite/banana/OLCAssembly.py
@@ -274,7 +274,7 @@ class OLCAssembly:
             fout.close()
             
     def splitIIDs(self, m):
-        _exe("grep iid alignments.overlaps_realigned | cut -f2 -d\: > internal.ids")
+        _exe(r"grep iid alignments.overlaps_realigned | cut -f2 -d\: > internal.ids")
         fh = open("internal.ids",'r')
         n = fh.readlines()
         fh.close()
@@ -301,7 +301,7 @@ class OLCAssembly:
         TODO: Need to know the exception that's thrown when there are no contigOuts
         """
         logging.info("Renaming Contigs")
-        getContigName = re.compile("(\d+)_contig")
+        getContigName = re.compile(r"(\d+)_contig")
         contigNames = {}
         bank = amos.AmosBank("out.bank")
         
--- a/pbsuite/banana/chunkyBlasr.py
+++ b/pbsuite/banana/chunkyBlasr.py
@@ -120,7 +120,7 @@ class ChunkyBlasr():
         for chunk in glob.glob(os.path.join(self.refDir, self.refBase+"*_chunk_*")):
             logging.info("Filtering out reads < 500bp from %s" % chunk)
             r, o, e = _exe(("fastalength {0} | "
-                            "awk -F\  '{{if ($1 < 500) print $2}}' | "
+                            r"awk -F\  '{{if ($1 < 500) print $2}}' | "
                             "fastaremove {0} stdin > {0}.fasta").format(chunk))
             logging.debug("RETCODE - %d\nSTDOUT - %s\nSTDERR - %s" %(r,str(o),str(e)))
             if r != 0:
--- a/pbsuite/jelly/Setup.py
+++ b/pbsuite/jelly/Setup.py
@@ -13,7 +13,7 @@ If an <inputScaffolding.qual> exists bes
 we'll create and incorporate it into PBJelly. Otherwise, it is not necessary
 """
 
-refParser = re.compile("(.*)\|(ref\d{7})/?(\d+)?$")
+refParser = re.compile(r"(.*)\|(ref\d{7})/?(\d+)?$")
 
 class Setup():
     def __init__(self):
--- a/pbsuite/jelly/Stages.py
+++ b/pbsuite/jelly/Stages.py
@@ -79,7 +79,7 @@ def mapping(jobDirs, outDir, reference,
             logging.warning("Output File %s already exists and will be overwritten." % (outFile))
         
         #Build Blasr Command 
-        nprocRe = re.compile("--nproc (\d+)")
+        nprocRe = re.compile(r"--nproc (\d+)")
         np = nprocRe.findall(parameters + extras)
         if len(np) == 0:
             np = '1'
--- a/pbsuite/jelly/m4pie.py
+++ b/pbsuite/jelly/m4pie.py
@@ -14,7 +14,7 @@ WARNING! -- Input.bam should be produced
 """
     
 def extractTails(aligns, reads, outFq, minLength=100):
-    """
+    r"""
     0x1  -- template has multiple segments in sequencing
     0x40 -- first segment in template
     0x80 -- last segment in template
@@ -105,7 +105,7 @@ def uniteTails(origAligns, tailMapFn, ou
     
     prolog and eplog will only point to the primary and the primary will point to both
     """
-    datGrab = re.compile("^(?P<shift>\d+)(?P<log>[pe])(?P<length>\d+)__(?P<rn>.*)$")
+    datGrab = re.compile(r"^(?P<shift>\d+)(?P<log>[pe])(?P<length>\d+)__(?P<rn>.*)$")
     
     aligns = M4File(tailMapFn)
     mode = 'a' if inplace else 'w'
--- a/pbsuite/honey/Force.py
+++ b/pbsuite/honey/Force.py
@@ -520,7 +520,7 @@ def spotsSearch(bam, bed, args):
     return anyCoverage, ref, vars
 
 #Here are some helper methods for parsing force annotation results
-forceRe = re.compile("(?P<ref>True|False|\?)\[(?P<tails>.*)\|(?P<spots>.*)\]")
+forceRe = re.compile(r"(?P<ref>True|False|\?)\[(?P<tails>.*)\|(?P<spots>.*)\]")
 def parseForce(data):
     """
     turns the force output into a dict
--- a/pbsuite/honey/bampie.py
+++ b/pbsuite/honey/bampie.py
@@ -82,7 +82,7 @@ def callBlasr(inFile, refFile, params, n
 
 
 def extractTails(bam, outFq, minLength=100):
-    """
+    r"""
     0x1  -- template has multiple segments in sequencing
     0x40 -- first segment in template
     0x80 -- last segment in template
@@ -163,7 +163,7 @@ def uniteTails(mappedFiles, outBam="mult
     prolog and eplog will only point to the primary and the primary will point to both
     """
         
-    datGrab = re.compile("^(?P<maq>\d+)(?P<log>[pe])(?P<strand>[01])(?P<ref>.*):(?P<pos>\d+)__(?P<rn>.*)$")
+    datGrab = re.compile(r"^(?P<maq>\d+)(?P<log>[pe])(?P<strand>[01])(?P<ref>.*):(?P<pos>\d+)__(?P<rn>.*)$")
     bout = None
     for ibam, tbam in mappedFiles:
         sam = pysam.Samfile(tbam, 'r')
--- a/pbsuite/jelly/Extraction.py
+++ b/pbsuite/jelly/Extraction.py
@@ -56,7 +56,7 @@ class Extraction():
         """
         Build a TrimInfo namedtuple for this read
         """
-        getSub = re.compile("(.*)##(\d+)#(\d+)##$")
+        getSub = re.compile(r"(.*)##(\d+)#(\d+)##$")
         #Check for trims
         if readName.endswith('##'):#just endswith? not safe..
             logging.debug("%s -- Missed Adapter" % readName)
@@ -323,7 +323,7 @@ class Extraction():
         selection is a dictionary of { readNames : True } for lookup
         I'm trying to speed up Extraction as much as possible
         """
-        splRE = re.compile("\s+")
+        splRE = re.compile(r"\s+")
         fasta = FastaFile(fastaFn)
         qual = QualFile(qualFn, convert=False)
         logging.info("Selective loading from %d reads" % (len(list(fasta.values()))))
--- a/pbsuite/honey/realign.py
+++ b/pbsuite/honey/realign.py
@@ -196,7 +196,7 @@ def expandMd(md):
     Turns abbreviated MD into a full array
     """
     ret = []
-    for i in re.findall("\d+|\^?[ATCGN]+", md):
+    for i in re.findall(r"\d+|\^?[ATCGN]+", md):
         if i.startswith('^'):
             ret.extend(list(i[1:]))
         elif i[0] in ["A","T","C","G","N"]:
