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
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
data for dbxrefs and postprocess it. By returning everything in json format the
need for normalization and special parsing of the data is reduced.
# Getting started for development (Setup)
Getting started for development (Setup)
---------------------------------------
Prerequisites:
* git
* python3
Supported bioinformatic databases:
Supported databases:
* Ontologies
* Gene Ontology
* Enzyme
* Gene Identifier
* Uniprot
* Taxonomy
* SequenceOntology
* RFAM
* Pubmed
* Protein Families
* PDB
* InterPro
* GeneID
* Gene Ontology
* HTTP
Checkout the repository:
~~~~
git clone git@git.computational.bio.uni-giessen.de:SOaAS/dbxref.git
~~~~
Checkout the repository::
Setup a virtualenv for development and install it in editable mode:
git clone git@git.computational.bio.uni-giessen.de:SOaAS/dbxref.git
~~~~
# install in development environment
virtualenv --python=python3 venv; source venv/bin/activate;
pip install -e .
Setup a virtualenv for development and install it in editable mode::
# run tests
python3 setup.py test
# install in development environment
virtualenv --python=python3 venv; source venv/bin/activate;
pip install -e .
# compile documentation
python3 setup.py build_sphinx
~~~~
# run tests
python3 setup.py test
Use the application:
# compile documentation
python3 setup.py build_sphinx
~~~~
dbxref resolve GO:0097281
~~~~
Use the application::
dbxref resolve GO:0097281
......@@ -10,7 +10,10 @@ def _load_providers(path):
data = []
with open(path) as 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):
index = {}
......@@ -24,10 +27,10 @@ def normalize_index(index):
return {k.lower():v for (k,v) in index.items()}
def has_provider(provider):
return _has_provider(load_providers(), provider)
return _has_provider(load_indexed_providers(), provider)
def _has_provider(providers, provider):
return provider.lower() in providers
def get_provider(provider):
return load_providers()[provider.lower()]
return load_indexed_providers()[provider.lower()]
#!/usr/bin/env python3
import argparse
from argparse import RawTextHelpFormatter
import os
import logging
from dbxref import resolver
from dbxref import resolver, config
from pbr.version import VersionInfo
import json
__version__ = VersionInfo('dbxref').semantic_version().release_string()
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)
subparsers = parser.add_subparsers()
info_parser = subparsers.add_parser('info')
info_parser.set_defaults(func=info)
#TODO implement
resolve_parser = subparsers.add_parser('resolve')
resolve_parser.add_argument('dbxrefs', nargs=argparse.REMAINDER)
......@@ -26,7 +29,7 @@ def main():
retrieve_parser.add_argument('--verbose', '-v', action='store_true', default=False, help="Show debug output")
args = parser.parse_args()
config = {} # TODO implement
config = {} # implement when needed
if ('verbose' in vars(args) and args.verbose):
logging.basicConfig(level=logging.INFO)
args.parser = parser
......@@ -35,9 +38,15 @@ def main():
def help(args, config):
args.parser.print_help()
def info(args, config):
#TODO implement
print ('info')
def info(args, cfg):
print ('dbxref Version ' + __version__)
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):
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 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()
from setuptools import setup
setup(
name='dbxref',
version='0.1.0',
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',
],
},
setup_requires=['pbr'],
pbr=True
)
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