Skip to content

MAST parsing fails with motif IDs #1980

Closed

Description

@victorlin

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

  1. Download MAST output file: http://web.mit.edu/meme_v4.11.4/share/doc/examples/mast_example_output_files/mast.txt
  2. 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.

Activity

  1. peterjc commented on Mar 25, 2019

    @peterjc
    Member

    Sounds sensible, but not my area - @mdehoon or @barwil ?

  2. victorlin commented on Mar 26, 2019

    @victorlin
    ContributorAuthor

    I'm thinking to have a more robust way to detect the motif section and contents. Then, if ID and/or ALT ID are present, they can be parsed and added as attributes to each Bio.motifs.meme.Motif.

  3. mdehoon commented on Mar 27, 2019

    @mdehoon
    Contributor

    @victorlin could you prepare a pull request with a fix?

  4. added a commit that references this issue on Mar 28, 2019
  5. victorlin commented on May 27, 2019

    @victorlin
    ContributorAuthor

    Closed by #1986.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions