From cf7f9a21b8d639245c60da9f30745e4332e4d079 Mon Sep 17 00:00:00 2001
From: "Brankovics, Balazs" <balazs.brankovics@wur.nl>
Date: Fri, 31 Mar 2023 14:07:44 +0200
Subject: [PATCH] bug fixed to allow AS:i:0 as valid score

---
 src/sam-keep-best.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/sam-keep-best.pl b/src/sam-keep-best.pl
index 199778f..1a353d3 100755
--- a/src/sam-keep-best.pl
+++ b/src/sam-keep-best.pl
@@ -422,7 +422,7 @@ sub update_pair {
     my %hit = %$hitref;
 
     if ($term eq 'AS:i') {
-	unless ($hit{'AS:i'}) {
+	unless (defined $hit{'AS:i'}) {
 	    # Make SAM output invalid to make the mistake obvious and die with error
 	    print "ERROR: Aborted, due to missing alignment score ('AS:i:<int>' column). Check STDERR for more info.\n";
 	    die "ERROR: Hit does not have an alignment score ('AS:i:<int>' column).\n" .
@@ -431,7 +431,7 @@ sub update_pair {
 	}
 	$pair->{$term} += $hit{$term};
     } elsif ($term eq 'BS:f') {
-	unless ($hit{'BS:f'}) {
+	unless (defined $hit{'BS:f'}) {
 	    # Make SAM output invalid to make the mistake obvious and die with error
 	    print "ERROR: Aborted, due to missing bitscore ('BS:f:<num>' column). Check STDERR for more info.\n";
 	    die "ERROR: Hit does not have a bitscore ('BS:f:<num>' column).\n" .
-- 
GitLab