Commit a12602d6 authored by Lukas Jelonek's avatar Lukas Jelonek
Browse files

Merge branch 'develop' into 'master'

Develop

See merge request SOaAS/dbxref!3
parents 941bb534 2733b102
# DB XREF resolver and retriever tool DB XREF resolver and retriever tool
===================================
A tool that resolves database cross references (dbxrefs). It can return a list of A tool that resolves database cross references (dbxrefs). It can return a list of
locations where the cross reference points to in different formats, like HTML, locations where the cross reference points to in different formats, like HTML,
...@@ -9,40 +10,47 @@ The intended audience for this tool are bioinformatician that need to collect ...@@ -9,40 +10,47 @@ The intended audience for this tool are bioinformatician that need to collect
data for dbxrefs and postprocess it. By returning everything in json format the data for dbxrefs and postprocess it. By returning everything in json format the
need for normalization and special parsing of the data is reduced. need for normalization and special parsing of the data is reduced.
# Getting started for development (Setup) Getting started for development (Setup)
---------------------------------------
Prerequisites: Prerequisites:
* git * git
* python3 * python3
Supported bioinformatic databases: Supported databases:
* Ontologies * Enzyme
* Gene Ontology * Gene Identifier
* Uniprot
* Taxonomy
* SequenceOntology
* RFAM
* Pubmed
* Protein Families
* PDB
* InterPro
* GeneID
* Gene Ontology
* HTTP
Checkout the repository:
~~~~ Checkout the repository::
git clone git@git.computational.bio.uni-giessen.de:SOaAS/dbxref.git
~~~~
Setup a virtualenv for development and install it in editable mode: git clone git@git.computational.bio.uni-giessen.de:SOaAS/dbxref.git
~~~~ Setup a virtualenv for development and install it in editable mode::
# install in development environment
virtualenv --python=python3 venv; source venv/bin/activate;
pip install -e .
# run tests # install in development environment
python3 setup.py test virtualenv --python=python3 venv; source venv/bin/activate;
pip install -e .
# compile documentation # run tests
python3 setup.py build_sphinx python3 setup.py test
~~~~
Use the application: # compile documentation
python3 setup.py build_sphinx
~~~~ Use the application::
dbxref resolve GO:0097281
~~~~ dbxref resolve GO:0097281
...@@ -10,7 +10,10 @@ def _load_providers(path): ...@@ -10,7 +10,10 @@ def _load_providers(path):
data = [] data = []
with open(path) as data_file: with open(path) as data_file:
data = yaml.load(data_file) data = yaml.load(data_file)
return normalize_index(index_providers(data)) return data
def load_indexed_providers():
return normalize_index(index_providers(load_providers()))
def index_providers(providers): def index_providers(providers):
index = {} index = {}
...@@ -24,10 +27,10 @@ def normalize_index(index): ...@@ -24,10 +27,10 @@ def normalize_index(index):
return {k.lower():v for (k,v) in index.items()} return {k.lower():v for (k,v) in index.items()}
def has_provider(provider): def has_provider(provider):
return _has_provider(load_providers(), provider) return _has_provider(load_indexed_providers(), provider)
def _has_provider(providers, provider): def _has_provider(providers, provider):
return provider.lower() in providers return provider.lower() in providers
def get_provider(provider): def get_provider(provider):
return load_providers()[provider.lower()] return load_indexed_providers()[provider.lower()]
#!/usr/bin/env python3 #!/usr/bin/env python3
import argparse import argparse
from argparse import RawTextHelpFormatter
import os import os
import logging import logging
from dbxref import resolver from dbxref import resolver, config
from pbr.version import VersionInfo
import json import json
__version__ = VersionInfo('dbxref').semantic_version().release_string()
def main(): def main():
parser = argparse.ArgumentParser(description='Lookup locations of database cross references and retrieve them as json') parser = argparse.ArgumentParser(description='Version ' + __version__ + '\nLookup locations of database cross references and retrieve them as json', formatter_class=RawTextHelpFormatter)
parser.set_defaults(func=help) parser.set_defaults(func=help)
subparsers = parser.add_subparsers() subparsers = parser.add_subparsers()
info_parser = subparsers.add_parser('info') info_parser = subparsers.add_parser('info')
info_parser.set_defaults(func=info) info_parser.set_defaults(func=info)
#TODO implement
resolve_parser = subparsers.add_parser('resolve') resolve_parser = subparsers.add_parser('resolve')
resolve_parser.add_argument('dbxrefs', nargs=argparse.REMAINDER) resolve_parser.add_argument('dbxrefs', nargs=argparse.REMAINDER)
...@@ -26,7 +29,7 @@ def main(): ...@@ -26,7 +29,7 @@ def main():
retrieve_parser.add_argument('--verbose', '-v', action='store_true', default=False, help="Show debug output") retrieve_parser.add_argument('--verbose', '-v', action='store_true', default=False, help="Show debug output")
args = parser.parse_args() args = parser.parse_args()
config = {} # TODO implement config = {} # implement when needed
if ('verbose' in vars(args) and args.verbose): if ('verbose' in vars(args) and args.verbose):
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
args.parser = parser args.parser = parser
...@@ -35,9 +38,15 @@ def main(): ...@@ -35,9 +38,15 @@ def main():
def help(args, config): def help(args, config):
args.parser.print_help() args.parser.print_help()
def info(args, config): def info(args, cfg):
#TODO implement print ('dbxref Version ' + __version__)
print ('info') print ('')
print ('Supported dbxref databases:')
providers = config.load_providers()
for provider in providers:
print (' ' + provider['name'])
print (' Prefixes: ' + str.join(', ', [x for x in provider['prefixes']]))
print (' Formats : ' + str.join(', ', [x for x in provider['resources']]))
def resolve(args, config): def resolve(args, config):
print(json.dumps(resolver.resolve(resolver.convert_to_dbxrefs(args.dbxrefs), check_existence=args.no_check))) print(json.dumps(resolver.resolve(resolver.convert_to_dbxrefs(args.dbxrefs), check_existence=args.no_check)))
......
[metadata]
name = dbxref
author = Lukas Jelonek
author-email = Lukas.Jelonek@computational.bio.uni-giessen.de
description = A library for resolving database cross references
description-file = README.rst
project_urls =
Source Code = https://git.computational.bio.uni-giessen.de/SOaAS/dbxref
keywords = dbxref
license = MIT
[files]
packages = dbxref
[entry_points]
console_scripts =
dbxref = dbxref.main:main
from setuptools import setup, find_packages from setuptools import setup
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
setup( setup(
name='dbxref', setup_requires=['pbr'],
version='0.1.0', pbr=True
description='A library for resolving database cross references',
long_description=long_description,
url='https://git.computational.bio.uni-giessen.de/SOaAS/dbxref',
author='Lukas Jelonek',
author_email='Lukas.Jelonek@computational.bio.uni-giessen.de',
keywords='dbxref',
packages=find_packages(exclude=['contrib', 'docs', 'tests']),
package_data={'dbxref':['*.yaml']},
install_requires=[
'requests',
'cachecontrol',
'pyyaml',
'lockfile',
'lxml'
],
entry_points={
'console_scripts': [
'dbxref=dbxref.main:main',
],
},
) )
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment