LOR.collect_codes

LOR.collect_codes(prefix, confirmation_required=True, verbose=False, raise_error=False)[source]

Collect data of PRIDE/LOR codes for the given prefix.

Parameters:
  • prefix (str) – The prefix of LOR codes to collect.

  • confirmation_required (bool) – Whether user confirmation is required; if confirmation_required=True (default), prompts the user for confirmation before proceeding with data collection.

  • verbose (bool | int) – Whether to print relevant information to the console; defaults to False.

  • raise_error (bool) – Whether to raise the provided exception; if raise_error=False (default), the error will be suppressed.

Returns:

A dictionary containing the LOR codes for the given prefix, or None if no data is available.

Return type:

dict | None

Examples:

>>> from pyrcs.line_data import LOR  # from pyrcs import LOR

>>> lor = LOR()

>>> lor_codes_cy = lor.collect_codes(prefix='CY', verbose=True)
Proceed with collecting data of "LOR (CY)"?
 [No]|Yes: yes
Collecting the data ... Done.

>>> assert isinstance(lor_codes_cy, dict)
>>> list(lor_codes_cy.keys())
['CY', 'Notes', 'Last updated date']

>>> cy_codes = lor_codes_cy['CY']
>>> type(cy_codes)
pandas.DataFrame
>>> cy_codes.head()
     Code  ...                       RA Note
0   CY240  ...           Caerwent branch RA4
1  CY1540  ...  Pembroke - Pembroke Dock RA6
[2 rows x 5 columns]

>>> lor_codes_nw = lor.collect_codes(prefix='NW', verbose=True)
Proceed with collecting data of "LOR (NW)"?
 [No]|Yes: yes
Collecting the data ... Done.

>>> assert isinstance(lor_codes_nw, dict)
>>> list(lor_codes_nw.keys())
['NW', 'Notes', 'Last updated date']

>>> nw_codes = lor_codes_nw['NW']
>>> type(nw_codes)
pandas.DataFrame
>>> nw_codes.head()
     Code  ... RA Note
0  NW0001  ...
1  NW1001  ...
2  NW1002  ...
3  NW1003  ...
4  NW1004  ...
[5 rows x 5 columns]

>>> lor_codes_xr = lor.collect_codes(prefix='XR')
Proceed with collecting data of "LOR (XR)"?
 [No]|Yes: yes
Collecting the data ... Done.

>>> type(lor_codes_xr)
dict
>>> list(lor_codes_xr.keys())
['XR', 'Last updated date']

>>> xr_codes = lor_codes_xr['XR']
>>> type(xr_codes)
dict
>>> list(xr_codes.keys())
['Current codes', 'Current codes note', 'Past codes', 'Past codes note']

>>> xr_codes['Past codes']
    Code  ... RA Note
0  XR001  ...
1  XR002  ...
[2 rows x 5 columns]

>>> xr_codes['Current codes']
    Code  ...                     RA Note
0  XR001  ...  Originally reported as RA4
1  XR002  ...  Originally reported as RA4
[2 rows x 5 columns]