Skip to content

Commit

Permalink
Update imports and capitalization of strings
Browse files Browse the repository at this point in the history
  • Loading branch information
cthoyt committed Aug 21, 2018
1 parent 87b7b77 commit ca209e3
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/bio2bel_chebi/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

import datetime
import logging

import pandas as pd
import time
from tqdm import tqdm

import pandas as pd
from bio2bel import AbstractManager
from bio2bel.manager.flask_manager import FlaskMixin
from bio2bel.manager.namespace_manager import BELNamespaceManagerMixin
from pybel import BELGraph
from pybel.constants import IDENTIFIER, NAME, NAMESPACE
from pybel.manager.models import NamespaceEntry
from tqdm import tqdm

from .constants import MODULE_NAME
from .models import Accession, Base, Chemical, Relation, Synonym
from .parser.accession import get_accession_df
Expand Down Expand Up @@ -146,11 +146,10 @@ def get_or_create_chemical(self, chebi_id, **kwargs):
self.chebi_id_to_chemical[chebi_id] = chemical
return chemical

def get_chemical_by_chebi_id(self, chebi_id):
def get_chemical_by_chebi_id(self, chebi_id: str) -> Optional[Chemical]:
"""Get a chemical from the database.
:param str chebi_id: ChEBI database identifier
:rtype: Optional[Chemical]
:param chebi_id: ChEBI database identifier
"""
chemical = self.session.query(Chemical).filter(Chemical.chebi_id == chebi_id).one_or_none()

Expand Down Expand Up @@ -351,13 +350,13 @@ def get_chemical_from_data(self, data):
"""
namespace = data.get(NAMESPACE)

if namespace not in {'CHEBI', 'CHEBIID'}:
if namespace.lower() not in {'chebi', 'chebiid'}:
return

identifier = data.get(IDENTIFIER)
name = data.get(NAME)

if namespace == 'CHEBI':
if namespace.lower() == 'chebi':
if identifier is not None:
return self.get_chemical_by_chebi_id(identifier)

Expand All @@ -367,7 +366,7 @@ def get_chemical_from_data(self, data):
else:
raise ValueError

elif namespace == 'CHEBIID':
elif namespace.lower() == 'chebiid':
return self.get_chemical_by_chebi_id(name)

def enrich_chemical_hierarchy(self, graph):
Expand Down

0 comments on commit ca209e3

Please sign in to comment.