Skip to content

Commit bef1790

Browse files
authored
Prevent malformed issue when using PDB without defined chain names. (#124)
* Update findseq.py * Spelling fix
1 parent 159d474 commit bef1790

File tree

1 file changed

+25
-21
lines changed

1 file changed

+25
-21
lines changed

findseq.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,31 @@
88
99
PARAMS:
1010
needle (string)
11-
the sequence of amino acids to match and select
12-
in the haystack. This can be a sequence of amino
13-
acids, or a string-style regular expression. See
14-
examples.
11+
the sequence of amino acids to match and select
12+
in the haystack. This can be a sequence of amino
13+
acids, or a string-style regular expression. See
14+
examples.
1515
16-
hastack (string or PyMOL selection)
17-
name of the PyMOL object/selection in which
18-
to find the needle.
16+
haystack (string or PyMOL selection)
17+
name of the PyMOL object/selection in which
18+
to find the needle.
1919
2020
selName (string; defaults to None)
21-
This is the name of the selection to return. If selName
22-
is left blank (None), then the selection name will be
23-
foundSeqXYZ where XYZ is some random number; if selName is
24-
"sele" the usual PyMOL "(sele)" will be used; and, lastly,
25-
if selName is anything else, that name will be used verbatim.
21+
This is the name of the selection to return. If selName
22+
is left blank (None), then the selection name will be
23+
foundSeqXYZ where XYZ is some random number; if selName is
24+
"sele" the usual PyMOL "(sele)" will be used; and, lastly,
25+
if selName is anything else, that name will be used verbatim.
2626
2727
het (0 or 1; defaults to 0)
28-
This boolean flag allows (1) or disallows (0) heteroatoms
29-
from being considered.
28+
This boolean flag allows (1) or disallows (0) heteroatoms
29+
from being considered.
3030
3131
firstOnly (0 or 1; defaults to 0)
32-
Subsequences or motifs might be repeated, this controls how we
33-
consider multiple matches. If firstOnly is False (0) then we return
34-
all found subsequences; if firstOnly is True (1), then we just return
35-
the first found sequence.
32+
Subsequences or motifs might be repeated, this controls how we
33+
consider multiple matches. If firstOnly is False (0) then we return
34+
all found subsequences; if firstOnly is True (1), then we just return
35+
the first found sequence.
3636
3737
RETURNS:
3838
a newly created selection with the atoms you sought. If there are
@@ -358,10 +358,14 @@ def findseq(needle, haystack, selName=None, het=0, firstOnly=0):
358358
i_chains = chains[start:stop]
359359
# are all residues from one chain?
360360
if len(set(i_chains)) != 1:
361-
# now they are not, this match is not really a match, skip it
362-
continue
361+
# now they are not, this match is not really a match, skip it
362+
continue
363363
chain = i_chains[0]
364-
cmd.select(rSelName, rSelName + " or (__h and i. " + str(IDs[start]) + "-" + str(IDs[stop - 1]) + " and c. " + chain + " )")
364+
# Only apply chains to selection algebra if there are defined chains.
365+
if chain:
366+
cmd.select(rSelName, rSelName + " or (__h and i. " + str(IDs[start]) + "-" + str(IDs[stop - 1]) + " and c. " + chain + " )")
367+
else:
368+
cmd.select(rSelName, rSelName + " or (__h and i. " + str(IDs[start]) + "-" + str(IDs[stop - 1]) + ")")
365369
if int(firstOnly):
366370
break
367371
cmd.delete("__h")

0 commit comments

Comments
 (0)