Giter VIP home page Giter VIP logo

Comments (6)

jonwedell avatar jonwedell commented on September 9, 2024

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.

jonwedell avatar jonwedell commented on September 9, 2024

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.

yokochi47 avatar yokochi47 commented on September 9, 2024

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.

jonwedell avatar jonwedell commented on September 9, 2024

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.

yokochi47 avatar yokochi47 commented on September 9, 2024

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.

jonwedell avatar jonwedell commented on September 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.