From 255cbd1ca4ea8ca547113972dfd7678b1bbc48ab Mon Sep 17 00:00:00 2001 From: Ethan Leyden <113561319+etleyden@users.noreply.github.com> Date: Sun, 20 Oct 2024 21:50:45 -0400 Subject: [PATCH] Abbreviated exit condition in pfeature_comp.py Excessive if statements were reduced a shorter/simpler solution. --- Standalone/pfeature_comp.py | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/Standalone/pfeature_comp.py b/Standalone/pfeature_comp.py index d062ae3..d0ef5b1 100644 --- a/Standalone/pfeature_comp.py +++ b/Standalone/pfeature_comp.py @@ -2139,24 +2139,12 @@ def readseq(file,out): for i in range (1,len(seq)+1): seqid.append("Seq_"+str(i)) for i in seq: - if 'B' in i: + NNAA = 'BJOUZX' # Non-natural amino acids + for j in NNAA: + if j in i print('\nError: The input sequences contain non-natural amino acids. Kindly check the sequence.\n') - sys.exit() - if 'J' in i: - print('\nError: The input sequences contain non-natural amino acids. Kindly check the sequence.\n') - sys.exit() - if 'O' in i: - print('\nError: The input sequences contain non-natural amino acids. Kindly check the sequence.\n') - sys.exit() - if 'U' in i: - print('\nError: The input sequences contain non-natural amino acids. Kindly check the sequence.\n') - sys.exit() - if 'Z' in i: - print('\nError: The input sequences contain non-natural amino acids. Kindly check the sequence.\n') - sys.exit() - if 'X' in i: - print('\nError: The input sequences contain non-natural amino acids. Kindly check the sequence.\n') - sys.exit() + print(f'Sequence (contains {j}): {i}') + sys.exit() df4 = pd.DataFrame(seq) df4.to_csv(out,index=None,header=False) ##############################################################################