bmrb-io / PyNMRSTAR

A Python module for reading, writing, and manipulating NMR-STAR files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

loop with no data warnings

locsmith opened this issue · comments

Is it possible to silence warning of loops with no data ? These are quite legal star constructs (? i believe?)

PyNMR-STAR uses the standard Python logging module to log these warnings. You can configure their behavior (including diverting them to a specific file, silencing them, etc.) using the configuration options available in the logging module.

As an example, to increase the log level (and suppress these warnings) the following (prior to parsing a loop) should suffice:

import logging
logging.getLogger().setLevel(logging.ERROR)

Empty loops are technically forbidden in NMR-STAR, though they are allowed in STAR. In practice, files with empty loops do exist, which is why the issue is only warned about, as opposed to being an actual exception.

Hey Gary,

I suspect you may run into a few other corner cases where the behavior of this library isn't ideal for pure STAR parsing (versus NMR-STAR parsing), though I would certainly to like facilitate, to the extent possible, the use of this library for working with NEF, so I appreciate you bringing any of these issues to my attention.

It may be worth me creating a special NEFEntry class (and similar for Saveframes and Loops) in the future to enable using the library for this purpose without needing workarounds.

I believe that you are correct regarding filters - you should be able to create a filter that will filter out the specific message being discussed here. (Alternatively, and certainly more hacky, is to reset the log level to whatever you desire after parsing an Entry - since PyNMRSTAR throws an exception for any true exceptions, and only logs warnings, so this will almost never lead to the suppression of anything meaningful during parsing.)