Repository navigation
Use XML parsing for MAST output files - #2082
Conversation
source: latest meme release (meme-5.0.5/tests/mast) download: http://meme-suite.org/meme-software/5.0.5/meme-5.0.5.tar.gz
|
@victorlin I would suggest to store record.alphabet = xml_tree.find('alphabet').get('name') |
Use string for alphabet instead of Bio.Alphabet
mdehoon
left a comment
There was a problem hiding this comment.
Looks OK to me, once the appveyor and travis errors have been fixed.
previously was functionally sufficient since hit_motif is guaranteed to have the value of hit_motifs[-1] after the last list comprehension. but obviously it is bad practice.
The previous try/except on `xml_tree.getroot().get('version')` was
useless since an absence of the attribute yields None rather than
raising an error. A try/except on `xml_tree = ET.parse(handle)` is more
meaningful as we can except a ParseError there.
Combining __read_version() and __read_database_and_motifs() into
__read_metadata(). The names were due to functionality from the
plain-text parser which is now irrelevant.
Codecov Report
@@ Coverage Diff @@
## master #2082 +/- ##
==========================================
- Coverage 84.92% 82.34% -2.58%
==========================================
Files 318 317 -1
Lines 51050 50953 -97
==========================================
- Hits 43353 41959 -1394
- Misses 7697 8994 +1297
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #2082 +/- ##
==========================================
- Coverage 84.92% 84.92% -0.01%
==========================================
Files 318 318
Lines 51050 51001 -49
==========================================
- Hits 43353 43311 -42
+ Misses 7697 7690 -7
Continue to review full report at Codecov.
|
|
If I am reading this correctly, the Would it be better to keep the plain text parser as |
|
@peterjc Which version of Mast does the plain-text parser support? |
|
According to the test files: |
|
I think we had this discussion in #1988. In summary, the MAST program (latest 5.0.5) currently outputs 3 different files: If we want to retain both parsers, maybe having a parameter would be better: from Bio.motifs import mast
mast.parse(open('mast.txt'))
mast.parse(open('mast.xml'), format='xml')but different format names for Bio.motifs.parse/read: from Bio import motifs
motifs.parse(open('mast.txt'), 'mast')
motifs.parse(open('mast.xml'), 'mast-xml')
motifs.read(open('mast.txt'), 'mast')
motifs.read(open('mast.xml'), 'mast-xml') |
|
Yes, you're right - @mdehoon said he was OK with replacing the text parser with the XML parser, #1988 (comment) I've hardly used the MAST output, so have no personal experience to guide me here. |
|
I would keep the XML parser only. Parsing plain-text output is not a good idea to begin with, and we should not encourage it. |
|
OK, but this needs a |
|
Should this wait until there is an updated XML parser for MEME as well, since it is part of the same package? |
|
I think we could merge XML for MAST only, and then add XML for MEME later. The longer we leave a pull request, the more likely to get merge conflicts (there is one now already). Are you happy with doing a |
|
@peterjc I did a merge in d9b8fc8. Is there somewhere I should look for other merge conflicts? If you're referencing the |
|
Github says there is no merge conflict anymore :) |
|
I suggest we do a squash-and-merge (since the rebase is non-trivial), suggested commit comment: Then AFTER than, @victorlin can try deleting and re-forking his repository as the simplest way to sort out his master branch - although there other ways to achieve that. And, we can update the |
|
Suggested entry for
Suggested entry for
How do these sound? |
|
Those sound good. Do you want to add them to this branch (without changing anything else like trying another rebase)? |
|
Done. |
|
OK to squash-and-merge @mdehoon? Suggested commit message: #2082 (comment) |
|
@peterjc OK |
|
Thank you both 👍 |
This pull request re-implements the current functionality of Bio/motifs/mast.py using the
xmlmodule to parse the XML output instead of the plain-text output from MAST. It also includes updated test files from MEME source.Notable differences:
read()should be a valid XML stream instead of formatted text stream.alphabet_name_mapglobal variable: used for mapping alphabet names to respective Bio.Alphabet class. It seems that Bio.Alphabet was deprecated for letters in Stop using Alphabet objects in Bio.motifs #2066, but I'm unsure which letters to use in replacement. @mdehoon ?__read_section_i()and__read_section_ii()condensed into__read_sequences(): there are no "sections" in the XML file. Also removed__read_section_iii()as it had no extracting functionality.__make_diagram()used to generate diagram string found in text files.Record.strand_handlingrequired for creation of diagram string.Suggested improvements for the future:
Record.sequencesandRecord.diagrams.ref #1988, #1980
Related: http://web.mit.edu/meme/current/bin/mast_xml_to_txt
I hereby agree to dual licence this and any previous contributions under both
the Biopython License Agreement AND the BSD 3-Clause License.
I have read the
CONTRIBUTING.rstfile, have runflake8locally, andunderstand that AppVeyor and TravisCI will be used to confirm the Biopython unit
tests and style checks pass with these changes.
I have added my name to the alphabetical contributors listings in the files
NEWS.rstandCONTRIB.rstas part of this pull request, am listedalready, or do not wish to be listed. (This acknowledgement is optional.)