Comments (6)
Dear Masashi,
This is definitely a bug, you shouldn't see the "internaluse..." value. I will work today to fix it. Thank you for the report. Feel free to reach out with any other feedback on how we can improve the PyNMRSTAR library.
Thanks,
Jon
from pynmrstar.
Dear Masashi,
I cannot reproduce the error using the most recent versions of the PyNMR-STAR library (either v2 or v3 branch):
>>> import pynmrstar
>>> a = pynmrstar.Entry.from_string("""data_nef_D_800107
...
... save_nef_nmr_meta_data
... _Entry.Sf_category entry_information
... _Entry.Sf_framecode nef_nmr_meta_data
... _Entry.NMR_STAR_version 3.2.1.18
... _Entry.Source_data_format nmr_exchange_format
... _Entry.Source_data_format_version 1.1
... _Entry.Generated_software_name PDBStat
... _Entry.Generated_software_version 5.20-exp
... _Entry.Generated_date 2020-01-28T16:40:10
... _Entry.UUID 1580226010
... _Entry.Related_coordinate_file_name .
... _Entry.ID 2PNG
... #
... _pdbx_nmr_assigned_chem_shift_list.entry_id ?
... _pdbx_nmr_assigned_chem_shift_list.id ?
... _pdbx_nmr_assigned_chem_shift_list.data_file_name 2png.nef
... #
... save_""")
Traceback (most recent call last):
File "<stdin>", line 20, in <module>
File "/Users/jon/PycharmProjects/PyNMRSTAR/pynmrstar.py", line 1838, in from_string
return cls(the_string=the_string)
File "/Users/jon/PycharmProjects/PyNMRSTAR/pynmrstar.py", line 1599, in __init__
parser.parse(star_buffer.read(), source=self.source)
File "/Users/jon/PycharmProjects/PyNMRSTAR/pynmrstar.py", line 890, in parse
curframe.add_tag(curtag, self.token, self.get_line_number())
File "/Users/jon/PycharmProjects/PyNMRSTAR/pynmrstar.py", line 2625, in add_tag
(self.tag_prefix, prefix))
ValueError: One saveframe cannot have tags with different categories (or tags that don't match the set category)! '_Entry' vs '_pdbx_nmr_assigned_chem_shift_list'.
Can you please provide the version you are using print(pynmrstar.__version__)
and the exact code that is triggering this exception?
Thanks!
from pynmrstar.
Hi Jon,
The above message is expected one from the issue. I am using 2.6.4.1 and it was deployed sometime via pip command. So, I need to update the library?
Thank you and stay safe,
from pynmrstar.
Dear Masashi,
I reviewed the commit logs, and it doesn't appear that the behavior of this particular code has changed since 2.6.4.1 Something else must be triggering the incorrect error message. (Though I still suggest upgrading if you are able.)
Could you attach the file where this bug triggers (in case there is an issue with characters in the file that GitHub has stripped out) and the specific code that triggers it?
Hope you are both well and safe also.
Thanks,
Jon
from pynmrstar.
Dear Jon,
Thank you for your comment. I found that this problem was related to NEFtranslator implementation originally developed by Kumaran.
def read_input_file(self, in_file):
""" Read input NEF/NMR-STAR file.
@param in_file: input NEF/NMR-STAR file path
@return: status, Entry/Saveframe/Loop data type or message, data object
"""
is_ok = True
star_data = None
try:
print ('Entry')
star_data = pynmrstar.Entry.from_file(in_file)
msg = 'Entry'
except ValueError as e:
print (e)
try:
print ('Saveframe')
star_data = pynmrstar.Saveframe.from_file(in_file)
msg = 'Saveframe'
except ValueError as e:
print (e)
try:
print ('Loop')
star_data = pynmrstar.Loop.from_file(in_file)
msg = 'Loop'
except ValueError as e:
print (e)
is_ok = False
msg = str(e) # '%s contains no valid saveframe or loop. PyNMRSTAR ++ Error - %s' % (os.path.basename(in_file), str(e))
except Exception as e:
is_ok = False
msg = str(e)
return is_ok, msg, star_data
The output was:
Entry
One saveframe cannot have tags with different categories (or tags that don't match the set category)! '_Entry' vs '_pdbx_nmr_assigned_chem_shift_list'.
Saveframe
("Only 'save_NAME' is valid in the body of a NMR-STAR file. Found 'data_nef_D_800107'.", 1)
Loop
("Invalid token found in saveframe 'internaluseyoushouldntseethis_frame': 'data_nef_D_800107'", 1)
NEFtranslator tries to read file as Entry, it fails, as Saveframe, and finally, as Loop. PyNMRSTAR library throws proper error message when parser class matches with the file. But, I received the last error message. Now, I could resolve this problem by changing my implementation which retains exceptions as e1, e2, and e3, respectively.
Could you please clarify the error message in pynmrstar.Loop class?
Best regards,
Masashi
from pynmrstar.
Dear Masashi,
Thank you for these additional details. I have improved the error message when attempting to parse a loop object from a block of text which is not a loop. If you update to version 2.6.5.1 of the library you should see the improved behavior.
Thanks for the report!
Take care,
Jon
from pynmrstar.
Related Issues (20)
- Files without categories read ok HOT 2
- loop with no data warnings HOT 3
- A typo in error message HOT 2
- pynmrstar library should not use logging.basicConfig HOT 3
- odd behaviour of frame_codes HOT 2
- pynmrstar should use its own logger?! HOT 4
- get Loop tags without category HOT 5
- read rows in loops as a dictionary HOT 11
- should PyNMRSTAR describe itself as a star file parser HOT 7
- ValueError: You cannot have two loops with the same category in one saveframe HOT 21
- When checking `empty` property in a loop, ignore Entry_ID and similar tags HOT 1
- Document that python 3 is required in metadata so pip for python 2 will not go after newer versions HOT 1
- Show a better error message when a user attempts to render a file with an empty string
- Data loss occurred while output if proper key tag was missing HOT 2
- Release 3? HOT 4
- When validating an entry, ensure that saveframe pointers point to saveframes of the correct category HOT 2
- If loading an entry fails with a 403, implement an exponential back off and retry rather than throwing an IOError
- Change write_to_file() defaults to preserve empty tags and loops HOT 1
- Problem frame without tags won't print loop HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pynmrstar.