Skip to content

Commit

Permalink
load atomic mass data from web.archive.org (fixes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
deeenes committed Jan 12, 2023
1 parent 6032322 commit 222e757
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/lipyd/mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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():
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 222e757

Please sign in to comment.