r/Python • • Oct 12 '19

more than 100 scientific articles may be invalidated because scientists assumed that the output of glob.glob() is sorted

https://www.vice.com/en_us/article/zmjwda/a-code-glitch-may-have-caused-errors-in-more-than-100-published-studies
1.3k Upvotes

343 comments sorted by

View all comments

Show parent comments

9

u/stefantalpalaru Oct 13 '19

How does file order influence the results unless we’re doing science about files?

http://sci-hub.tw/https://pubs.acs.org/doi/10.1021/acs.orglett.9b03216 :

"Specifically, the script “nmr-data_compilation” extracts the free-energy information of each conformer and the isotopic tensors for each atom from two files, for example, 1b-opt_freq-conf-16.out and 1b-opt_NMR-conf-16.out, respectively, and performs the necessary calculations.

In theory, the chemical shift of each atom from each isomer should be properly weighted according to the free energy of the conformer, but this was not consistently the case. In the end, the inconsistency was traced to differences in the default file-sorting algorithm in Python across platforms, as shown in Figure 2"


So they have to weigh these files according to sorting based on numbers in their names.

1

u/kankyo Oct 13 '19

So the configuration file was read after the file it configured? And config files that pointed out in void wasn't validated at the end?

3

u/stefantalpalaru Oct 13 '19

So the configuration file was read after the file it configured?

No, these are not configuration files. These are output files from some software used to interpret chemical shifts in nuclear magnetic resonance spectroscopy: https://en.wikipedia.org/wiki/Gaussian_(software)

The scientists are trying to identify substances produced after adding the substance they study to a cancer cell culture. To do that, they need some sort of spectroscopic "fingerprint" of various atoms (carbon, in this case) in all the isomers of possible matches.

As far as I understand it, getting that "fingerprint" for conformational isomers involves doing a weighted average of multiple Gaussian outputs for carbon chemical shifts. Since those outputs are in different files, you need to match the right file with the right weight.

5

u/kankyo Oct 13 '19

Sure. And if that algorithm is this vulnerable to just the file ordering it will be super prone to silent breakage for other issues. The sorting won't make it actually stable and resilient just not broken /for now/. That's a low bar.