Repository navigation
Closed
Description
Setup
I am reporting a problem with Biopython version, Python version, and operating
system as follows:
import sys; print(sys.version)
import platform; print(platform.python_implementation()); print(platform.platform())
import Bio; print(Bio.__version__)3.6.5 (default, Apr 10 2018, 00:31:24)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)]
CPython
Linux-3.10.0-862.9.1.el7.x86_64-x86_64-with-redhat-7.5-Maipo
1.73
Behaviour tested on MAST versions 4.11.4 and 5.0.4.
Expected behaviour
CODE BLOCK:
from Bio.motifs import mast
with open("mast.txt") as f:
record = mast.read(f)
There should be no errors in reading the file.
Actual behaviour
---------------------------------------------------------------------------
StopIteration Traceback (most recent call last)
<ipython-input-2-32471794492c> in <module>
1 with open("mast.txt") as f:
----> 2 record = mast.read(f)
3
~/.local/share/virtualenvs/icgc-gFC-9hmH/lib/python3.6/site-packages/Bio/motifs/mast.py in read(handle)
53 record = Record()
54 __read_version(record, handle)
---> 55 __read_database_and_motifs(record, handle)
56 __read_section_i(record, handle)
57 __read_section_ii(record, handle)
~/.local/share/virtualenvs/icgc-gFC-9hmH/lib/python3.6/site-packages/Bio/motifs/mast.py in __read_database_and_motifs(record, handle)
91 if 'MOTIF WIDTH' in line:
92 break
---> 93 line = next(handle)
94 if '----' not in line:
95 raise ValueError("Line does not contain '----':\n%s" % line)
StopIteration:
Steps to reproduce
- Download MAST output file: http://web.mit.edu/meme_v4.11.4/share/doc/examples/mast_example_output_files/mast.txt
- Run the CODE BLOCK
mast.py#L94 seems to check for a specific column arrangement beginning with MOTIF followed by WIDTH. However, MAST has an option to take motif ID and ALT ID, which is not parsed correctly with the current implementation.
This should be an easy fix. Let me know if my assumptions are correct and I can help implement.
Metadata
Metadata
Assignees
Labels
No labels
Activity
peterjc commentedon Mar 25, 2019
Sounds sensible, but not my area - @mdehoon or @barwil ?
victorlin commentedon Mar 26, 2019
I'm thinking to have a more robust way to detect the motif section and contents. Then, if
IDand/orALT IDare present, they can be parsed and added as attributes to eachBio.motifs.meme.Motif.mdehoon commentedon Mar 27, 2019
@victorlin could you prepare a pull request with a fix?
Detect motif IDs in MAST parser
Detect motif IDs in MAST parser
Detect motif IDs in MAST parser
victorlin commentedon May 27, 2019
Closed by #1986.
Use XML parsing for MAST output files (#2082)