Closed locsmith closed 3 years ago
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.
Hi John
Thank you for your reply, Comments below
On 22 Jun 2021, at 17:25, Jon Wedell @.***> wrote:
PyNMR-STAR uses the standard Python logging module https://docs.python.org/3/howto/logging.html 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.
Yes that makes sense, though actually I am passing NEF files so as with pure STAR files empty loops are fine. I am really using pynmrstar as a star parser…
With the logging can you switch off individual log messages or would I need to switch off a whole slew by setting the level? I think the answer maybe filters?
regards Gary
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/uwbmrb/PyNMRSTAR/issues/101#issuecomment-866135270, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA3TPGP27O2WIAI2FYCCYCTTUC2OZANCNFSM47ABTCTA.
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.)
Is it possible to silence warning of loops with no data ? These are quite legal star constructs (? i believe?)