Research Organization Registry (ROR) data¶
from alexandria3k.data_sources import ror
- class data_sources.ror.Ror(ror_file, sample=<function Ror.<lambda>>, attach_databases=None)¶
Create an object containing ROR meta-data that supports queries over its (virtual) table and the population of an SQLite database with its data.
- Parameters
ror_file (str) – Path to a zip file containing the research organization data, e.g. “v1.17.1-2022-12-16-ror-data.zip”
sample (callable, optional) – A callable to row sampling, defaults to lambda n: True. The population or query method will call this argument for each record with the record’s data as its argument. When the callable returns True the record will get processed, when it returns False the record will get skipped.
attach_databases (list, optional) – A list of colon-joined tuples specifying a database name and its path, defaults to None. The specified databases are attached and made available to the query and the population condition through the specified database name.
- populate(database_path, columns=None, condition=None)¶
Populate the specified SQLite database using the data specified in the object constructor’s call. The database is created if it does not exist. If it exists, the tables to be populated are dropped (if they exist) and recreated anew as specified.
- Parameters
database_path (str) – The path specifying the SQLite database to populate.
columns (list, optional) – A list of strings specifying the columns to populate, defaults to None. The strings are of the form table_name.column_name or table_name.*.
condition (str, optional) – SQL expression specifying the rows to include in the database’s population, defaults to None. The expression can contain references to the table’s columns, to tables in attached databases prefixed by their name, and tables in the database being populated prefixed by populated. Implicitly, if a main table is populated, its details tables will only get populated with the records associated with the corresponding main table’s record.
- query(query, partition=False)¶
Run the specified query on the virtual database using the data specified in the object constructor’s call.
- Parameters
query (str) – An SQL SELECT query specifying the required data.
partition (bool, optional) – When true the query will run separately in each container, defaults to False. Queries involving table joins will run substantially faster if access to each table’s records is restricted with an expression table_name.container_id = CONTAINER_ID, and the partition argument is set to true. In such a case the query is repeatedly run over each database partition (compressed JSON file) with CONTAINER_ID iterating sequentially to cover all partitions. The query’s result is the concatenation of the individual partition results. Running queries with joins without partitioning will often result in quadratic (or worse) algorithmic complexity.
- Returns
An iterable over the query’s results.
- Return type
iterable
Generated schema¶
CREATE TABLE research_organizations(
id INTEGER PRIMARY KEY,
ror_path,
name,
status,
established,
grid,
address_city,
address_state,
address_postcode,
address_country_code,
address_lat,
address_lng
);
CREATE TABLE ror_types(
id,
ror_id,
type
);
CREATE TABLE ror_links(
id,
ror_id,
link
);
CREATE TABLE ror_aliases(
id,
ror_id,
alias
);
CREATE TABLE ror_acronyms(
id,
ror_id,
acronym
);
CREATE TABLE ror_relationships(
id,
ror_id,
type,
ror_path
);
CREATE TABLE ror_funder_ids(
id,
ror_id,
funder_id
);
CREATE TABLE ror_wikidata_ids(
id,
ror_id,
wikidata_id
);
CREATE TABLE ror_isnis(
id,
ror_id,
isni
);