SysBioChalmers / RAVEN

The RAVEN Toolbox for genome scale model reconstruction, curation and analysis.
http://sysbiochalmers.github.io/RAVEN/
Other
100 stars 52 forks source link

importModel() randomly failing if path contains non-ASCII characters #562

Open edkerk opened 2 days ago

edkerk commented 2 days ago

Discussed in https://github.com/SysBioChalmers/RAVEN/discussions/561

Originally posted by JBiaggi October 2, 2024 Hello! I recently reinstalled RAVEN using MATLAB (2024b) Add-Ons. Ever since I'm having this problem with importModel(): sometimes it works, sometimes it doesn't. Usually what happens is: when I run the code for the first time, I get this error message:

importModel('iYali.xml')
No model returned.

Error using dispEM (line 49)
There is a problem with the SBML file. Try using the SBML Validator at http://sbml.org/Facilities/Validator

Error in importModel (line 136)
    dispEM(EM);

Then I run the code again, and the function works! The SBML Validators reports that everything is fine with the model. Could you help me fix this problem somehow?

Kind regards

edkerk commented 2 days ago

I encountered a similar issue in the last few days, where it also appears random when importModel works and when it doesn't. Although in my case it often works the first time, but not the second and later times, until it randomly seems to work again.

In my case, it seems to only occur for files that are in a shared OneDrive folder (not my own folder, example path: C:\Users\eduard\*University name*\*Other user* - *folder name*\ ). The spaces in the path don't seem to be the problem, because then it should never work, and not randomly. When I copy-paste the same file outsite the OneDrive-tracked folder, it seems to function fine (but this could of course also be random).

What happens if you run dbstop in importModel at 133 before running importModel, and when the function halts next time you run: [modelSBML,tmp] = TranslateSBML_RAVEN(fileName,0,0,[1 1]); tmp.message? The output I get is File unreadable., which I haven't figured out yet what it exactly means, but the problem does seem to come from libSBML.

I run MATLAB 2024a, with RAVEN installed via Git, on a Windows 10 computer.

edkerk commented 2 days ago

I think it has something to do with having Unicode characters in the path or filename, see here.

I have this bug when the file is located in a folder named tåst/, but not when located in a folder named test/. I don't know how to resolve this. @jbiaggi Does this also explain your case?

JBiaggi commented 1 day ago

The files I'm having problem with are also in a One Drive folder. The folder name is OneDrive - Tallinna Tehnikaülikool so maybe the 'ü' in the university's name may be causing the Unicode filename issue. I moved the same model file to another location where it doesn't have any special characters, ran importModel() three times, and it worked every time.

edkerk commented 1 day ago

It is odd that this seems to happen at random. I checked the string that MATLAB is parsing to libSBML in both successful and failing cases, and it was identical (as one would expect).

The only solution I can then think of is to have the SBML file first copied to a temporary folder (if the source folder has non-ASCII characters), before calling libSBML. Something similar is done in getBlast in cases where the path contains spaces.

edkerk commented 1 day ago

If you run tempname, does the path that is returned contain any non-ASCII characters?

edkerk commented 10 hours ago

The workaround involving a temporary file is implemented as part of #559.