File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 33#include < cassert>
44#include < stdexcept>
55#include < climits>
6+ #ifdef HAVE_C11
7+ #include < regex>
8+ #endif
69
710// 4 billion
811#define END_MAX 4000000000
@@ -275,6 +278,16 @@ int32_t GenomicRegion::DistanceBetweenEnds(const GenomicRegion &gr) const {
275278 return ;
276279 } else {
277280 chr = hdr.Name2ID (tchr); // bam_name2id(hdr.get(), tchr.c_str());
281+
282+ // if tchr was not found in sequence dictionary, it's possible that we're
283+ // specifying our contigs in b37 style whereas dict is hg** style;
284+ // let's attempt to automatically convert [0-9XY]+ -> chr[0-9XY]+
285+ #ifdef HAVE_C11
286+ static std::regex b37_regex (" [0-9XY]+" );
287+ if (chr == -1 && std::regex_match (tchr, b37_regex)) {
288+ chr = hdr.Name2ID (" chr" + tchr);
289+ }
290+ #endif
278291 }
279292 }
280293}
You can’t perform that action at this time.
0 commit comments