mirror of
https://github.com/biopython/biopython.git
synced 2025-10-20 21:53:47 +08:00
Handle possible non-existent attributes in clusterbuster.py (#5074)
* Handle possible non-existent attrs in clusterbuster.py In commit bc0d58b, support was added for gap and weight paramters, but since these two attributes are not guaranteed to exist by parse and read methods, an AttributeError could be raised for non-clusterbuster motifs. An attribute check was added to allow motifs lacking gap and weight to be formatted properly. Co-authored-by: Ee Shan Liau Shirley <69098782+shirleyliau@users.noreply.github.com> * Add names to CONTRIB.rst * Use try-except to handle missing attributes Co-authored-by: Ee Shan Liau Shirley <69098782+shirleyliau@users.noreply.github.com> * Avoid CB output when an attribute is None In the previous commit, the skipping mechanism was switched to try-except blocks, and the cases when an attribute is None are no longer dealt with. This patch re-introduced `if m.weight` to prevent empty export fields in such cases. Co-authored-by: Ee Shan Liau Shirley <69098782+shirleyliau@users.noreply.github.com> --------- Co-authored-by: Ee Shan Liau Shirley <69098782+shirleyliau@users.noreply.github.com>
This commit is contained in:
@ -88,10 +88,20 @@ def write(motifs, precision=0):
|
||||
lines = []
|
||||
for m in motifs:
|
||||
lines.append(f">{m.name}\n")
|
||||
if m.weight:
|
||||
lines.append(f"# WEIGHT: {m.weight}\n")
|
||||
if m.gap:
|
||||
lines.append(f"# GAP: {m.gap}\n")
|
||||
try:
|
||||
weight = m.weight
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
if weight:
|
||||
lines.append(f"# WEIGHT: {weight}\n")
|
||||
try:
|
||||
gap = m.gap
|
||||
except AttributeError:
|
||||
pass
|
||||
else:
|
||||
if gap:
|
||||
lines.append(f"# GAP: {gap}\n")
|
||||
for ACGT_counts in zip(
|
||||
m.counts["A"], m.counts["C"], m.counts["G"], m.counts["T"]
|
||||
):
|
||||
|
@ -118,6 +118,7 @@ please open an issue on GitHub or mention it on the mailing list.
|
||||
- Dimitris Kalafatis <https://github.com/dimi1729>
|
||||
- Edward Haigh <lambda at edwardhaigh dot com>
|
||||
- Edward Liaw <https://github.com/edliaw>
|
||||
- Ee Shan Shirley Liau <https://github.com/shirleyliau>
|
||||
- Emmanuel Noutahi <https://github.com/maclandrol>
|
||||
- Eric Rasche <https://github.com/erasche>
|
||||
- Eric Talevich <https://github.com/etal>
|
||||
@ -364,6 +365,7 @@ please open an issue on GitHub or mention it on the mailing list.
|
||||
- Yair Benita <Y.Benita at domain pharm.uu.nl>
|
||||
- Yanbo Ye <https://github.com/lijax>
|
||||
- Yasar L. Ahmed <https://github.com/pyahmed>
|
||||
- Yen-Chung Chen <https://github.com/chenyenchung>
|
||||
- Yi Hsiao <https://github.com/hsiaoyi0504>
|
||||
- Yiming Qu <https://github.com/whatever60>
|
||||
- Yogesh Kulkarni <https://https://github.com/yogeshhk>
|
||||
|
Reference in New Issue
Block a user