Exemplo n.º 1
0
def _get_api(
    consumer_key: Optional[str] = None,
    consumer_secret: Optional[str] = None,
    access_token: Optional[str] = None,
    access_token_secret: Optional[str] = None,
) -> Optional[tweepy.API]:
    consumer_key = pystow.get_config("bioversions",
                                     "consumer_key",
                                     passthrough=consumer_key)
    consumer_secret = pystow.get_config("bioversions",
                                        "consumer_secret",
                                        passthrough=consumer_secret)
    access_token = pystow.get_config("bioversions",
                                     "access_token",
                                     passthrough=access_token)
    access_token_secret = pystow.get_config("bioversions",
                                            "access_token_secret",
                                            passthrough=access_token_secret)

    if consumer_key and consumer_secret and access_token and access_token_secret:
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_token_secret)

        # Create API object
        api = tweepy.API(auth)
        return api

    return None
Exemplo n.º 2
0
def ndex(username, password):
    """Upload to NDEx."""
    try:
        from ndex2 import NiceCXBuilder
    except ImportError:
        click.secho('Need to `pip install ndex2` before uploading to NDEx', fg='red')
        return

    miriam_validator = MiriamValidator()
    positive_mappings = load_mappings()
    cx = NiceCXBuilder()
    cx.set_name('Biomappings')
    cx.add_network_attribute('description', 'Manually curated mappings (skos:exactMatch) between biological entities.')
    cx.add_network_attribute('reference', 'https://github.com/biomappings/biomappings')
    cx.add_network_attribute('rights', 'Waiver-No rights reserved (CC0)')

    context = {'orcid': 'https://identifiers.org/orcid:'}
    for mapping in positive_mappings:
        for prefix in (mapping['source prefix'], mapping['target prefix']):
            if miriam_validator.namespace_embedded(prefix):
                prefix = prefix.upper()
            context[prefix] = f'https://identifiers.org/{prefix}:'
    cx.set_context(context)

    cx.add_network_attribute('version', get_git_hash())
    authors = sorted(set(
        mapping['source']
        for mapping in positive_mappings
        if mapping['source'].startswith('orcid:')
    ))
    cx.add_network_attribute('author', authors, type='list_of_string')

    for mapping in tqdm(positive_mappings, desc='Loading NiceCXBuilder'):
        source = cx.add_node(
            represents=mapping['source name'],
            name=miriam_validator.get_curie(mapping["source prefix"], mapping["source identifier"]),
        )
        target = cx.add_node(
            represents=mapping['target name'],
            name=miriam_validator.get_curie(mapping["target prefix"], mapping["target identifier"]),
        )
        edge = cx.add_edge(
            source=source,
            target=target,
            interaction=mapping['relation'],
        )
        cx.add_edge_attribute(edge, 'type', mapping['type'])
        cx.add_edge_attribute(edge, 'provenance', mapping['source'])

    nice_cx = cx.get_nice_cx()
    nice_cx.update_to(
        uuid=BIOMAPPINGS_NDEX_UUID,
        server=pystow.get_config('ndex', 'server', 'http://public.ndexbio.org'),
        username=pystow.get_config('ndex', 'username', username),
        password=pystow.get_config('ndex', 'password', password),
    )
Exemplo n.º 3
0
def upload():
    """Generate a CX graph and upload to NDEx."""
    cx = NiceCXBuilder()
    cx.set_name('Bioregistry')
    cx.add_network_attribute(
        'description',
        'An integrative meta-registry of biological databases, ontologies, and nomenclatures',
    )
    cx.add_network_attribute('author', 'Charles Tapley Hoyt')
    cx.set_context({
        'bioregistry.registry': 'https://bioregistry.io/metaregistry/',
        'bioregistry': 'https://bioregistry.io/registry/',
    })

    metaregistry = bioregistry.read_metaregistry()
    registry = bioregistry.read_registry()

    registry_nodes = {
        metaprefix: make_registry_node(cx, metaprefix)
        for metaprefix in metaregistry
    }
    resource_nodes = {
        prefix: make_resource_node(cx, prefix)
        for prefix in registry
    }

    for prefix, entry in registry.items():
        # Who does it provide for?
        provides = bioregistry.resolve.get_provides_for(prefix)
        if isinstance(provides, str):
            provides = [provides]
        for target in provides or []:
            cx.add_edge(
                source=resource_nodes[prefix],
                target=resource_nodes[target],
                interaction='provides',
            )

        # Which registries does it map to?
        for metaprefix in metaregistry:
            if metaprefix not in entry:
                continue
            cx.add_edge(
                source=resource_nodes[prefix],
                target=registry_nodes[metaprefix],
                interaction='listed',
            )

    nice_cx = cx.get_nice_cx()
    nice_cx.update_to(
        uuid=NDEX_UUID,
        server='http://public.ndexbio.org',
        username=pystow.get_config('ndex', 'username'),
        password=pystow.get_config('ndex', 'password'),
    )
Exemplo n.º 4
0
def get_xml_root(version: Optional[str] = None) -> ElementTree.Element:
    """Get the DrugBank XML parser root.

    Takes between 35-60 seconds.
    """
    from drugbank_downloader import parse_drugbank
    return parse_drugbank(
        version=version,
        username=pystow.get_config('pyobo', 'drugbank_username'),
        password=pystow.get_config('pyobo', 'drugbank_password'),
    )
Exemplo n.º 5
0
def _get_client(token: Optional[str] = None) -> Optional[WebClient]:
    token = pystow.get_config("bioversions",
                              "slack_api_token",
                              passthrough=token)
    if token is None:
        return None
    return WebClient(token=token)
Exemplo n.º 6
0
    def __init__(self,
                 access_token: Optional[str] = None,
                 sandbox: bool = False):
        """Initialize the Zenodo class.

        :param access_token: The Zenodo API. Read with :mod:`pystow` from zenodo/api_token
            of zenodo/sandbox_api_token if in sandbox mode.
        :param sandbox: If true, run in the Zenodo sandbox.
        """
        self.sandbox = sandbox
        if self.sandbox:
            self.base = "https://sandbox.zenodo.org"
            self.token_key = "sandbox_api_token"
        else:
            self.base = "https://zenodo.org"
            self.token_key = "api_token"

        # Base URL for the API
        self.api_base = self.base + "/api"

        # Base URL for depositions, relative to the API base
        self.depositions_base = self.api_base + "/deposit/depositions"

        self.access_token = pystow.get_config("zenodo",
                                              self.token_key,
                                              passthrough=access_token,
                                              raise_on_missing=True)
Exemplo n.º 7
0
def _get_api(
    consumer_key: Optional[str] = None,
    consumer_secret: Optional[str] = None,
    access_token: Optional[str] = None,
    access_token_secret: Optional[str] = None,
) -> Optional[tweepy.API]:
    consumer_key = pystow.get_config('bioversions', 'consumer_key', consumer_key)
    consumer_secret = pystow.get_config('bioversions', 'consumer_secret', consumer_secret)
    access_token = pystow.get_config('bioversions', 'access_token', access_token)
    access_token_secret = pystow.get_config('bioversions', 'access_token_secret', access_token_secret)

    if consumer_key and consumer_secret and access_token and access_token_secret:
        auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_token_secret)

        # Create API object
        api = tweepy.API(auth)
        return api
Exemplo n.º 8
0
def _get_host() -> Optional[str]:
    """Find the host with :func:`pystow.get_config`.

    Has two possibilities:

    1. The PyBEL config entry ``PYBEL_REMOTE_HOST``, loaded in :mod:`pybel.constants`
    2. The environment variable ``PYBEL_REMOTE_HOST``
    """
    return pystow.get_config('pybel', 'remote_host')
Exemplo n.º 9
0
def get_sqlalchemy_uri() -> str:
    """Get the SQLAlchemy URI."""
    rv = pystow.get_config('pyobo', 'sqlalchemy_uri')
    if rv is not None:
        return rv

    default_db_path = PYOBO_MODULE.join('pyobo.db')
    default_value = f'sqlite:///{default_db_path.as_posix()}'
    return default_value
Exemplo n.º 10
0
def get_sqlalchemy_uri() -> str:
    """Get the SQLAlchemy URI."""
    rv = pystow.get_config("pyobo", "sqlalchemy_uri")
    if rv is not None:
        return rv

    default_db_path = PYOBO_MODULE.join("pyobo.db")
    default_value = f"sqlite:///{default_db_path.as_posix()}"
    return default_value
Exemplo n.º 11
0
def ensure_zenodo(key: str, data: Data, paths: Union[str, Iterable[str]],
                  **kwargs) -> requests.Response:
    """Create a Zenodo record if it doesn't exist, or update one that does."""
    deposition_id = pystow.get_config("zenodo", key)
    if deposition_id is not None:
        return update_zenodo(deposition_id, paths, **kwargs)

    res = create_zenodo(data, paths, **kwargs)
    # Write the ID to the key in the local configuration
    # so it doesn't need to be created from scratch next time
    pystow.write_config("zenodo", key, str(res.json()["id"]))
    return res
Exemplo n.º 12
0
 def test_env_cast(self):
     """Test casting works properly when getting from the environment."""
     with mock_envvar("TEST_VAR", "1234"):
         self.assertEqual("1234", pystow.get_config("test", "var"))
         self.assertEqual("1234", pystow.get_config("test",
                                                    "var",
                                                    dtype=str))
         self.assertEqual(1234, pystow.get_config("test", "var", dtype=int))
         with self.assertRaises(ValueError):
             pystow.get_config("test", "var", dtype=bool)
         with self.assertRaises(TypeError):
             pystow.get_config("test", "var", dtype=object)
Exemplo n.º 13
0
def _get_password() -> Optional[str]:
    return pystow.get_config('pybel', 'remote_password')
Exemplo n.º 14
0
def build_engine_session(
    connection: str,
    echo: bool = False,
    autoflush: Optional[bool] = None,
    autocommit: Optional[bool] = None,
    expire_on_commit: Optional[bool] = None,
    scopefunc=None,
) -> Tuple:
    """Build an engine and a session.

    :param connection: An RFC-1738 database connection string
    :param echo: Turn on echoing SQL
    :param autoflush: Defaults to True if not specified in kwargs or configuration.
    :param autocommit: Defaults to False if not specified in kwargs or configuration.
    :param expire_on_commit: Defaults to False if not specified in kwargs or configuration.
    :param scopefunc: Scoped function to pass to :func:`sqlalchemy.orm.scoped_session`
    :rtype: tuple[Engine,Session]

    From the Flask-SQLAlchemy documentation:

    An extra key ``'scopefunc'`` can be set on the ``options`` dict to
    specify a custom scope function.  If it's not provided, Flask's app
    context stack identity is used. This will ensure that sessions are
    created and removed with the request/response cycle, and should be fine
    in most cases.
    """
    if connection is None:
        raise ValueError('can not build engine when connection is None')

    engine = create_engine(connection, echo=echo)

    autoflush = pystow.get_config('pybel',
                                  'manager_autoflush',
                                  passthrough=autoflush,
                                  dtype=bool,
                                  default=True)
    autocommit = pystow.get_config('pybel',
                                   'manager_autocommit',
                                   passthrough=autocommit,
                                   dtype=bool,
                                   default=False)
    expire_on_commit = pystow.get_config(
        'pybel',
        'manager_autoexpire',
        passthrough=expire_on_commit,
        dtype=bool,
        default=True,
    )

    logger.debug('auto flush: %s, auto commit: %s, expire on commmit: %s',
                 autoflush, autocommit, expire_on_commit)

    #: A SQLAlchemy session maker
    session_maker = sessionmaker(
        bind=engine,
        autoflush=autoflush,
        autocommit=autocommit,
        expire_on_commit=expire_on_commit,
    )

    #: A SQLAlchemy session object
    session = scoped_session(
        session_maker,
        scopefunc=scopefunc,
    )

    return engine, session
Exemplo n.º 15
0
    'DATA_DIRECTORY',
    'BIOREGISTRY_PATH',
    'METAREGISTRY_PATH',
    'BIOREGISTRY_MODULE',
    'EnsureEntry',
]

HERE = pathlib.Path(os.path.abspath(os.path.dirname(__file__)))
DATA_DIRECTORY = HERE / 'data'
BIOREGISTRY_PATH = DATA_DIRECTORY / 'bioregistry.json'
METAREGISTRY_PATH = DATA_DIRECTORY / 'metaregistry.json'
COLLECTIONS_PATH = DATA_DIRECTORY / 'collections.json'

BIOREGISTRY_MODULE = pystow.module('bioregistry')
EnsureEntry = Any

DOCS = os.path.abspath(os.path.join(HERE, os.pardir, os.pardir, 'docs'))
DOCS_DATA = os.path.join(DOCS, '_data')
DOCS_IMG = os.path.join(DOCS, 'img')

#: The URL of the remote Bioregistry site
BIOREGISTRY_REMOTE_URL = pystow.get_config('bioregistry',
                                           'url') or 'https://bioregistry.io'

#: Resolution is broken on identifiers.org for the following
IDOT_BROKEN = {
    'gramene.growthstage',
    'oma.hog',
    'obi',
}
Exemplo n.º 16
0
2. Sell your soul to the American government
"""

import datetime
import json
import os
from typing import Any, Callable, Iterable, List, Mapping, Set

import pystow
import requests
from cachier import cachier
from tqdm import tqdm

from ..struct import Term

ICD_CLIENT_ID = pystow.get_config("pyobo", "icd_client_id")
ICD_CLIENT_SECRET = pystow.get_config("pyobo", "icd_client_secret")

TOKEN_URL = "https://icdaccessmanagement.who.int/connect/token"  # noqa:S105

ICD_BASE_URL = "https://id.who.int/icd"

ICD11_TOP_LEVEL_URL = f"{ICD_BASE_URL}/entity"
ICD10_TOP_LEVEL_URL = f"{ICD_BASE_URL}/release/10/2016"


def get_icd(url: str) -> requests.Response:
    """Get an ICD API endpoint."""
    return requests.get(url, headers=get_icd_api_headers())

Exemplo n.º 17
0
2. Sell your soul to the American government
"""

import datetime
import json
import os
from typing import Any, Callable, Iterable, List, Mapping, Set

import pystow
import requests
from cachier import cachier
from tqdm import tqdm

from ..struct import Term

ICD_CLIENT_ID = pystow.get_config('pyobo', 'icd_client_id')
ICD_CLIENT_SECRET = pystow.get_config('pyobo', 'icd_client_secret')

TOKEN_URL = 'https://icdaccessmanagement.who.int/connect/token'  # noqa:S105

ICD_BASE_URL = 'https://id.who.int/icd'

ICD11_TOP_LEVEL_URL = f'{ICD_BASE_URL}/entity'
ICD10_TOP_LEVEL_URL = f'{ICD_BASE_URL}/release/10/2016'


def get_icd(url: str) -> requests.Response:
    """Get an ICD API endpoint."""
    return requests.get(url, headers=get_icd_api_headers())

Exemplo n.º 18
0
def _get_client(token: Optional[str] = None) -> Optional[WebClient]:
    token = pystow.get_config('bioversions', 'slack_api_token', token)
    if token is not None:
        return WebClient(token=token)
Exemplo n.º 19
0
# -*- coding: utf-8 -*-
"""Connection configuration for PyBEL."""

import logging

import pystow

__all__ = [
    'connection',
    'PYBEL_MINIMUM_IMPORT_VERSION',
    'PYBEL_HOME',
]

logger = logging.getLogger(__name__)

#: The last PyBEL version where the graph data definition changed
PYBEL_MINIMUM_IMPORT_VERSION = 0, 14, 0

PYBEL_HOME = pystow.join('pybel')
DEFAULT_CACHE_NAME = 'pybel_{}.{}.{}_cache.db'.format(
    *PYBEL_MINIMUM_IMPORT_VERSION)
DEFAULT_CACHE_PATH = pystow.join('pybel', name=DEFAULT_CACHE_NAME)
#: The default cache connection string uses sqlite.
DEFAULT_CACHE_CONNECTION = 'sqlite:///' + DEFAULT_CACHE_PATH.as_posix()

connection = pystow.get_config(
    'pybel',
    'connection',
    default=DEFAULT_CACHE_CONNECTION,
)
Exemplo n.º 20
0
def _get_user() -> Optional[str]:
    return pystow.get_config('pybel', 'remote_user')
Exemplo n.º 21
0
    def test_get_config(self):
        """Test lookup not existing."""
        self.assertIsNone(pystow.get_config(self.test_section, "key"))
        self.assertEqual(
            "1234", pystow.get_config(self.test_section, "key",
                                      default="1234"))

        value = "not_value"
        self.assertEqual(
            value,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough=value))

        self.assertEqual(
            1,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough=1))
        self.assertEqual(
            1,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="1",
                              dtype=int))

        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="1",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="yes",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="Yes",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="YES",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="True",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="TRUE",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="T",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough="t",
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough=True,
                              dtype=bool),
        )
        self.assertEqual(
            True,
            pystow.get_config(self.test_section,
                              self.test_option,
                              passthrough=1,
                              dtype=bool))
Exemplo n.º 22
0
def ndex(username, password):
    """Upload to NDEx."""
    try:
        from ndex2 import NiceCXBuilder
    except ImportError:
        click.secho('Need to `pip install ndex2` before uploading to NDEx',
                    fg='red')
        return

    cx = NiceCXBuilder()
    cx.set_name('ComPath')
    cx.add_network_attribute('description',
                             'Manually curated mappings between pathways.')
    cx.add_network_attribute('reference',
                             'https://github.com/compath/compath-resources')
    cx.add_network_attribute('rights', 'Waiver-No rights reserved (CC0)')

    context = {'orcid': 'https://identifiers.org/orcid:'}
    mappings = get_df(include_special=True,
                      include_decopath=True,
                      include_reactome_hierarchy=True)
    for _, mapping in mappings.iterrows():
        for prefix in (mapping['Source Resource'], mapping['Target Resource']):
            if prefix in {'decopath', 'pathbank'}:
                continue
            context[prefix] = bioregistry.get_miriam_url_prefix(prefix)
    cx.set_context(context)

    cx.add_network_attribute('version', get_git_hash())
    cx.add_network_attribute('author', [
        'Daniel Domingo-Fernández',
        'Carlos Bobis-Álvarez',
        'Josep Marín-Llaó',
        'Yojana Gadiya',
        'Sarah Mubeen',
        'Charles Tapley Hoyt',
    ],
                             type='list_of_string')

    for _, mapping in tqdm(mappings.iterrows(), desc='Loading NiceCXBuilder'):
        source = cx.add_node(
            represents=mapping['Source Name'],
            name=f'{mapping["Source Resource"]}:{mapping["Source ID"]}',
        )
        target = cx.add_node(
            represents=mapping['Target Name'],
            name=f'{mapping["Target Resource"]}:{mapping["Target ID"]}',
        )
        cx.add_edge(
            source=source,
            target=target,
            interaction=mapping['Mapping Type'],
        )

    nice_cx = cx.get_nice_cx()
    nice_cx.update_to(
        uuid=COMPATH_NDEX_UUID,
        server=pystow.get_config('ndex',
                                 'server',
                                 default='http://public.ndexbio.org'),
        username=pystow.get_config('ndex', 'username', passthrough=username),
        password=pystow.get_config('ndex', 'password', passthrough=password),
    )
Exemplo n.º 23
0
import unittest

import pystow

from ..manager import Manager

__all__ = [
    'TEST_CONNECTION',
    'TemporaryCacheMixin',
    'TemporaryCacheClsMixin',
    'FleetingTemporaryCacheMixin',
]

logger = logging.getLogger(__name__)

TEST_CONNECTION = pystow.get_config('pybel', 'test_connection')


class TemporaryCacheMixin(unittest.TestCase):
    """A test case that has a connection and a manager that is created for each test function."""

    def setUp(self):
        """Set up the test function with a connection and manager."""
        if TEST_CONNECTION:
            self.connection = TEST_CONNECTION
        else:
            self.fd, self.path = tempfile.mkstemp()
            self.connection = 'sqlite:///' + self.path
            logger.info('Test generated connection string %s', self.connection)

        self.manager = Manager(connection=self.connection, autoflush=True)
Exemplo n.º 24
0
import json

import click
import pystow
import requests
from more_click import verbose_option

from bioregistry.constants import BIOREGISTRY_MODULE
from bioregistry.external.utils import list_to_map

__all__ = [
    'get_bioportal',
]

BIOPORTAL_PATH = BIOREGISTRY_MODULE.join(name='bioportal.json')
BIOPORTAL_API_KEY = pystow.get_config('bioportal', 'api_key')
BASE_URL = 'https://data.bioontology.org'


def query(url: str, **params) -> requests.Response:
    """Query the given endpoint on BioPortal."""
    if BIOPORTAL_API_KEY is None:
        raise ValueError('missing API key for bioportal')
    params.setdefault('apikey', BIOPORTAL_API_KEY)
    return requests.get(f'{BASE_URL}/{url}', params=params)


def get_bioportal(force_download: bool = True, mappify: bool = False):
    """Get the BioPortal registry."""
    if BIOPORTAL_PATH.exists() and not force_download:
        with BIOPORTAL_PATH.open() as file:
Exemplo n.º 25
0
def download_drugbank(
    username: Optional[str] = None,
    password: Optional[str] = None,
    version: Optional[str] = None,
    prefix: Union[None, str, Sequence[str]] = None,
    force: bool = False,
) -> Path:
    """Download the given version of DrugBank.

    :param username:
        The DrugBank username. If not passed, looks up in the environment
        ``DRUGBANK_USERNAME``. If not found, raises a ValueError.
    :param password:
        The DrugBank password. If not passed, looks up in the environment
        ``DRUGBANK_PASSWORD``. If not found, raises a ValueError.
    :param version:
        The DrugBank version. If not passed, uses :mod:`bioversions` to
        look up the most recent version.
    :param prefix:
        The prefix and subkeys passed to :func:`pystow.ensure` to specify
        a non-default location to download the data to.
    :param force:
        Should the data be re-downloaded, even if it exists?
    :returns: The path to the local DrugBank file after it's been downloaded

    :raises ImportError: If no version is specified and :mod:`bioversions`
        is not installed
    """
    if version is None:
        try:
            import bioversions
        except ImportError:
            raise ImportError(
                "must first `pip install bioversions` to get latest DrugBank version automatically"
            )
        else:
            version = bioversions.get_version("drugbank")

    url = (
        f'https://go.drugbank.com/releases/{version.replace(".", "-")}/downloads/all-full-database'
    )

    if prefix is None:
        prefix = ["drugbank"]
    elif isinstance(prefix, str):
        prefix = [prefix]

    username = get_config("drugbank",
                          "username",
                          passthrough=username,
                          raise_on_missing=True)
    password = get_config("drugbank",
                          "password",
                          passthrough=password,
                          raise_on_missing=True)

    return ensure(
        *prefix,
        version,
        url=url,
        name="full database.xml.zip",
        download_kwargs=dict(
            backend="requests",
            stream=True,
            auth=(username, password),
        ),
        force=force,
    )
Exemplo n.º 26
0
def ndex(username, password):
    """Upload to NDEx."""
    try:
        from ndex2 import NiceCXBuilder
    except ImportError:
        click.secho("Need to `pip install ndex2` before uploading to NDEx",
                    fg="red")
        return

    miriam_validator = MiriamValidator()
    positive_mappings = load_mappings()
    cx = NiceCXBuilder()
    cx.set_name("Biomappings")
    cx.add_network_attribute(
        "description",
        "Manually curated mappings (skos:exactMatch) between biological entities."
    )
    cx.add_network_attribute("reference",
                             "https://github.com/biomappings/biomappings")
    cx.add_network_attribute("rights", "Waiver-No rights reserved (CC0)")

    context = {"orcid": "https://identifiers.org/orcid:"}
    for mapping in positive_mappings:
        for prefix in (mapping["source prefix"], mapping["target prefix"]):
            if miriam_validator.namespace_embedded(prefix):
                prefix = prefix.upper()
            context[prefix] = f"https://identifiers.org/{prefix}:"
    cx.set_context(context)

    cx.add_network_attribute("version", get_git_hash())
    authors = sorted(
        set(mapping["source"] for mapping in positive_mappings
            if mapping["source"].startswith("orcid:")))
    cx.add_network_attribute("author", authors, type="list_of_string")

    for mapping in tqdm(positive_mappings, desc="Loading NiceCXBuilder"):
        source = cx.add_node(
            represents=mapping["source name"],
            name=miriam_validator.get_curie(mapping["source prefix"],
                                            mapping["source identifier"]),
        )
        target = cx.add_node(
            represents=mapping["target name"],
            name=miriam_validator.get_curie(mapping["target prefix"],
                                            mapping["target identifier"]),
        )
        edge = cx.add_edge(
            source=source,
            target=target,
            interaction=mapping["relation"],
        )
        cx.add_edge_attribute(edge, "type", mapping["type"])
        cx.add_edge_attribute(edge, "provenance", mapping["source"])

    nice_cx = cx.get_nice_cx()
    nice_cx.update_to(
        uuid=BIOMAPPINGS_NDEX_UUID,
        server=pystow.get_config("ndex",
                                 "server",
                                 default="http://public.ndexbio.org"),
        username=pystow.get_config("ndex", "username", passthrough=username),
        password=pystow.get_config("ndex", "password", passthrough=password),
    )