Closed LeeBergstrand closed 10 years ago
they are part of an optional output E
From: Lee Bergstrand [mailto:notifications@github.com] Sent: Friday, April 11, 2014 7:12 PM To: carden24/Bioinformatic_scripts Subject: [Bioinformatic_scripts] Precompile regex's (HMM.search.and.parse.and.extract.py) (#1)
Since you are using the same regex's over and over you should precomplile these regexs at the top of the script using re.compile. This way the computer doesn't have to recompile the same regex over and over. Example Regex from you code:
hmmshortname = re.sub('.','',model, re.I)
shortname = re.sub('.','',query, re.I)
Instead you should use:
hmmSuffixRegex = re.compile('.')
querySuffixREgex = re.compile('.')
at the top of the script and then inside each method:
hmmshortname = hmmSuffixRegex.sub(repl, query, count=0)
shortname = querySuffixREgex.sub(repl, query, count=0)
Reference:
https://docs.python.org/2/library/re.html#re.compile https://docs.python.org/2/library/re.html#re.RegexObject.sub
— Reply to this email directly or view it on GitHubhttps://github.com/carden24/Bioinformatic_scripts/issues/1.
The precompiled regex patterns are now part of the script. Thanks Mr Lee
Since you are using the same regex's over and over you should precomplile these regexs at the top of the script using re.compile. This way the computer doesn't have to recompile the same regex over and over. Example Regex from you code:
Instead you should use:
at the top of the script and then inside each method:
Reference:
https://docs.python.org/2/library/re.html#re.compile https://docs.python.org/2/library/re.html#re.RegexObject.sub