From 222e757140d92f5c83203b46e756e90444758bfb Mon Sep 17 00:00:00 2001 From: deeenes Date: Thu, 12 Jan 2023 20:53:02 +0100 Subject: [PATCH] load atomic mass data from web.archive.org (fixes #4) --- src/lipyd/mass.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lipyd/mass.py b/src/lipyd/mass.py index afbbfcb..c786fd7 100644 --- a/src/lipyd/mass.py +++ b/src/lipyd/mass.py @@ -124,8 +124,8 @@ def setup(self): self.setup_isotopes() - @staticmethod - def load_masses(url): + @classmethod + def load_masses(cls, url): """ Downloads an HTML table from CIAAW webpage and extracts the atomic mass or weight information. @@ -140,7 +140,7 @@ def load_masses(url): Dict of masses or weights. """ - c = _curl.Curl(url, silent = False) + c = _curl.Curl(cls._archive_url(url), silent = False) req_masses = c.result with warnings.catch_warnings(): @@ -195,7 +195,7 @@ def load_freq_iso(self): Stores the result in :py:attr:`.freqIso` attribute of the module. """ - c = _curl.Curl(self.url_abundances, silent = False) + c = _curl.Curl(self._archive_url(self.url_abundances), silent = False) req_abundances = c.result.split('\n') # fixing erroneous HTML from CIAAW: @@ -247,6 +247,12 @@ def load_freq_iso(self): self.freq_iso = freq_iso + @staticmethod + def _archive_url(url): + + return 'https://web.archive.org/web/20171003133929/%s' % url + + def setup_mass_first_iso(self): """ Obtains the masses of the most abundant isotope for each element.