From a8e816627c5dfc9a9cf435753d955b645d679f10 Mon Sep 17 00:00:00 2001 From: Vineet Bansal Date: Fri, 29 Sep 2023 09:52:32 -0400 Subject: [PATCH] fix for specificity calculation for sam format (similar to commit 98bc2 for csv format --- include/genomics/printer.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/include/genomics/printer.hpp b/include/genomics/printer.hpp index ccdc7a2..8d520ec 100644 --- a/include/genomics/printer.hpp +++ b/include/genomics/printer.hpp @@ -135,9 +135,14 @@ namespace genomics { // because the match may well have been found using // an alternate PAM. The relevant PAM to consider for // CFD calculations is found at the end of the match. - std::string pam = match_sequence.substr(20, 3); - - if ((match.mismatches == 0) && (pam.substr(1, 2) == "GG")) + std::string pam; + if (match_sequence.length() < 20) { + pam = ""; + } else { + pam = match_sequence.substr(20, 3); + } + + if ((match.mismatches == 0) && (pam.length() == 3) && (pam.substr(1, 2) == "GG")) perfect_match = true; coordinates c;