You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
meme file parsing fails with current version of meme #1988
>>> from Bio import motifs
>>> handle = open('meme.txt')
>>> record = motifs.parse(handle, 'meme')
>>>
Actual behaviour
>>> from Bio import motifs
>>> handle = open('meme.txt')
>>> record = motifs.parse(handle, 'meme')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/motifs/__init__.py", line 78, in parse
record = meme.read(handle)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/motifs/meme.py", line 40, in read
__read_datafile(record, handle)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/Bio/motifs/meme.py", line 176, in __read_datafile
raise ValueError("Line does not start with 'DATAFILE':\n%s" % line)
ValueError: Line does not start with 'DATAFILE':
PRIMARY SEQUENCES= Klf1.100.fa
This is with meme version 5.0.5 (the latest version).
Note that meme generates an XML file as well as a human-readable text file. The meme parser in Biopython is currently designed for parsing the text file, which is fragile to any changes to the text file format. I suggest we switch to parsing the XML file instead.
i.e. Goal is to recommend parsing the XML, and formally deprecate the plain text parser? Much like with BLAST (although we've not quite killed the plain text parser). Sounds sensible.
I have been using the xml module from Python's standard library to parse the MAST output file. It's been straightforward and I believe all the information from the plain text file can be extracted from the XML as well. It would just be a matter of rewriting the read() functions in mast.py and meme.py while using the classes already defined.
Actually, it seems that XML output for MAST was introduced in version 4.4.0. Users who want to parse results from older versions of MAST would have to use the plain text parser. I'm not sure if MEME output was once plain text only.
Instead of replacing the plain text parser, should we maintain it and have an option to detect if the filename ends in .txt or .xml then parse accordingly?
That will make things easier. Is there a way to generate XML output files using the same data as the plain text output in Tests/motifs? That way we can be sure the same functionality is preserved with the new parser.
It looks like at least some of those test data were coming from meme itself (you can find the exact command that was used in the output files, and some of the input files can be found by googling). However I wouldn't be too strict about using the exact same test data.
If still needs to be fixed I am able to do it. I previously have made a program to alter the text input so the error doesn't occur, so I am pretty familiar with the issue.
Activity
peterjc commentedon Mar 29, 2019
i.e. Goal is to recommend parsing the XML, and formally deprecate the plain text parser? Much like with BLAST (although we've not quite killed the plain text parser). Sounds sensible.
Cross reference PR #1986, #1958
victorlin commentedon Apr 15, 2019
I have been using the
xmlmodule from Python's standard library to parse the MAST output file. It's been straightforward and I believe all the information from the plain text file can be extracted from the XML as well. It would just be a matter of rewriting theread()functions inmast.pyandmeme.pywhile using the classes already defined.victorlin commentedon Apr 15, 2019
Actually, it seems that XML output for MAST was introduced in version 4.4.0. Users who want to parse results from older versions of MAST would have to use the plain text parser. I'm not sure if MEME output was once plain text only.
Instead of replacing the plain text parser, should we maintain it and have an option to detect if the filename ends in
.txtor.xmlthen parse accordingly?mdehoon commentedon Apr 16, 2019
@victorlin MEME 4.4.0 is nine years old. I don't think we need to support it.
victorlin commentedon Apr 16, 2019
That will make things easier. Is there a way to generate XML output files using the same data as the plain text output in
Tests/motifs? That way we can be sure the same functionality is preserved with the new parser.mdehoon commentedon Apr 27, 2019
It looks like at least some of those test data were coming from meme itself (you can find the exact command that was used in the output files, and some of the input files can be found by googling). However I wouldn't be too strict about using the exact same test data.
joshuacook487 commentedon Oct 13, 2019
If still needs to be fixed I am able to do it. I previously have made a program to alter the text input so the error doesn't occur, so I am pretty familiar with the issue.
peterjc commentedon Oct 14, 2019
It looks like with #1986 and #2082 merged this issue can be closed?
victorlin commentedon Oct 14, 2019
@peterjc those 2 PRs updated the MAST parser. MEME parsing as of now seems to still be based on the text file which is prone to errors.
Looks like it would be better to switch to XML only for MEME as well – I can help rewrite the parser accordingly.
peterjc commentedon Oct 14, 2019
Ah - an important distinction. Volunteering to work on XML for MEME sounds good!
victorlin commentedon Aug 25, 2021
@peterjc @mdehoon with the above PR mergred, this issue can be closed.
mdehoon commentedon Aug 25, 2021
@victorlin Thanks