Skip to content

Commit 1cb0eaf

Browse files
authored
Add output message for findseq + don't create empty selection when seq was not found (#141)
* Don't create empty selection if nothing was found * Add default message when sequence was found
1 parent 64aa06e commit 1cb0eaf

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

findseq.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ def findseq(needle, haystack, selName=None, het=0, firstOnly=0):
7777
if selName == None:
7878
rSelName = "foundSeq" + str(random.randint(0, 32000))
7979
selName = rSelName
80-
elif selName == "sele":
81-
rSelName = "sele"
8280
else:
8381
rSelName = selName
8482

@@ -376,6 +374,13 @@ def findseq(needle, haystack, selName=None, het=0, firstOnly=0):
376374
if int(firstOnly):
377375
break
378376
cmd.delete("__h")
377+
cnt = cmd.count_atoms(rSelName)
378+
if not cnt:
379+
print("Sequence was not found")
380+
cmd.delete(rSelName)
381+
return None
382+
383+
print(f'findseq: selection "{rSelName}" defined with {cnt} atoms.')
379384
return rSelName
380385

381386
cmd.extend("findseq", findseq)

0 commit comments

Comments
 (0)