From 5dba02ed45a3647e879b5c07af546cc0f655cc4e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Sat, 19 Apr 2025 02:34:49 +0000 Subject: [PATCH] refactor: replace multiple `==` checks with `in` To check if a variable is equal to one of many values, combine the values into a tuple and check if the variable is contained `in` it instead of checking for equality against each of the values. This is faster, less verbose, and more readable. --- ancestral_state.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ancestral_state.py b/ancestral_state.py index a113d9e..3aacf2e 100644 --- a/ancestral_state.py +++ b/ancestral_state.py @@ -52,11 +52,11 @@ def polarize(ref, alt, anc, samples): d = '0' for s in samples: gt = s.split(':')[0] - if gt == '.' or gt == './.': + if gt in ('.', './.'): pol.append('NN') elif gt == a + '/' + a: pol.append('AA') - elif (gt == a + '/' + d) or (gt == d + '/' + a): + elif gt in (a + '/' + d, d + '/' + a): pol.append('AD') elif gt == d + '/' + d: pol.append('DD')