chemicalchecker.database.datasource.Datasource

class Datasource(**kwargs)[source]

Bases: Base

Datasource table class.

Parameters:
  • name (str) – primary key, simple unique name for the Datasource.

  • url (str) – the download link.

  • user (str) – few downloads require credentials.

  • password (str) – few downloads require credentials.

  • description (str) – free text description of the resource.

  • filename (str) – optional, a molrepo name. NB this name is the value of Molrepo.molrepo_name also is defininf the Parser that will be used.

  • calcdata (bool) – the datasource is actually from one of the calculated data.

A simple constructor that allows initialization from kwargs.

Sets attributes on the constructed instance using the names and values in kwargs.

Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.

Methods

add

Add a new row to the table.

download

Download the Datasource.

download_hpc

Run HPC jobs downloading the resources.

from_csv

Add entries from CSV file.

get

Get Datasources associated to the given dataset.

test_all_downloaded

Check if all Datasources have been downloaded.

test_all_valid_url

Check if all Datasources urls are valid.

Attributes

available

Check if Datasource is available.

calcdata

data_path

Check if Datasource is available.

datasets

datasource_name

description

filename

is_db

metadata

molrepos

password

registry

url

username

valid_url

Check if Datasource url is valid.

__repr__()[source]

String representation.

static add(kwargs)[source]

Add a new row to the table.

Parameters:

kwargs (dict) – The data in dictionary format.

property available

Check if Datasource is available.

property data_path

Check if Datasource is available.

download(force=False)[source]

Download the Datasource.

force(bool): Force download overwriting previous download.

static download_hpc(job_path, only_essential=False, **kwargs)[source]

Run HPC jobs downloading the resources.

Parameters:
  • job_path (str) – Path (usually in scratch) where the script files are generated.

  • only_essential (bool) – Download only the essential datasources (default: False).

static from_csv(filename)[source]

Add entries from CSV file.

Parameters:

filename (str) – Path to a CSV file.

static get(name=None)[source]

Get Datasources associated to the given dataset.

Parameters:

name (str) – The Datasource name, e.g “chebi”

static test_all_downloaded(only_essential=False)[source]

Check if all Datasources have been downloaded.

Parameters:

only_essential (bool) – Check only datasources that are essential

static test_all_valid_url()[source]

Check if all Datasources urls are valid.

property valid_url

Check if Datasource url is valid.