Skip to content

Commit b293731

Browse files
committed
make regex static and initliaze once
1 parent 5430735 commit b293731

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

include/SingleCellProtocols.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ namespace alevin{
223223

224224
// Custom geometry specification using regex for extraction
225225
struct CustomGeo {
226-
// store regex for reads 1 and 2
226+
// store regex string for reads 1 and 2
227227
static std::string reg[2];
228228
// store positions of matches for bc and umi
229229
static std::vector<int> b[2], u[2];
@@ -237,6 +237,8 @@ namespace alevin{
237237
boost::smatch match[2];
238238
// store the success of regex search
239239
bool rgx_search[2];
240+
// store the regex
241+
static boost::regex rgx[2];
240242
// required
241243
static uint32_t barcodeLength, umiLength;
242244
BarcodeEnd end;

src/AlevinUtils.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,9 +445,8 @@ namespace alevin {
445445
std::string& bc){
446446
std::string barcode="";
447447
for(int r=0; r < 2; r++) {
448-
boost::regex rgx(pt.reg[r]);
449-
pt.rgx_search[r] = (r == 0) ? boost::regex_search(read1,pt.match[r],rgx) :
450-
boost::regex_search(read2,pt.match[r],rgx); // using std::string instead of read1/2 results in blank umi. strange!
448+
pt.rgx_search[r] = (r == 0) ? boost::regex_search(read1,pt.match[r],pt.rgx[r]) :
449+
boost::regex_search(read2,pt.match[r],pt.rgx[r]); // using std::string instead of read1/2 results in blank umi. strange!
451450
if(!pt.b[r].empty()) { // if read r has barcode
452451
if(pt.rgx_search[r]){ // if rgx search was successful
453452
for(int i : pt.b[r]) {
@@ -1473,7 +1472,8 @@ namespace alevin {
14731472
}
14741473
// std::cout << "reg[0]: " << customGeo.reg[0] << std::endl;
14751474
// std::cout << "reg[1]: " << customGeo.reg[1] << std::endl;
1476-
1475+
customGeo.rgx[0] = customGeo.reg[0];
1476+
customGeo.rgx[1] = customGeo.reg[1];
14771477
// validate that BC and UMI lengths are OK
14781478
uint32_t maxBC{31};
14791479
uint32_t maxUMI{31};

src/SingleCellProtocols.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,6 @@ namespace alevin{
3838
extern uint32_t CustomGeo::barcodeLength, CustomGeo::umiLength;
3939
// bool alevin::protocols::CustomGeo::bioReadFound;
4040
extern bool CustomGeo::bioReadFound;
41-
41+
extern boost::regex CustomGeo::rgx[2];
4242
}// protocols
4343
}//alevin

0 commit comments

Comments
 (0)