Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cfankep/psotdb
  • SOaAS/psotdb
2 results
Show changes
Commits on Source (11)
Showing
with 218 additions and 47 deletions
Database Manager
================
This tool provide the preparation of Databases for several bioinformaticians tools.
The preparated databases can be used on the working computer or can be saved on the cloud Server(Amazon Web Service S3)
so that other computer can be able to download the data from there. It's also possible to delete some undesirable
databases on the working computer and/or in the Cloud.
Supported Databases with associated tools:
* Uniprot-Swissprot [Blast, Ghostx]
* CARD [Blast, Ghostx]
* Pfam [hmmer]
Installation
------------
Prerequisites:
* Python (Version >= 3.7)
* Git
Install for user::
pip install git+https://git.computational.bio.uni-giessen.de/cfankep/psotdb.git
Install for developer::
#checkout repository
git clone git+https://git.computational.bio.uni-giessen.de/cfankep/psotdb.git
#install
pip3 install -e .
Using Database Manager
----------------------
For the general help use::
dbman --help
Checkout which databases are available::
# in the S3 directory
dbman list_remote_databases
# in the local directory
dbman list_local_databases
Checkout which databases with associated transformations are available::
dbman list_recipes
Prepare databases::
# check the available optional parameters
dbman prepare -h
# run the standard preparation
dbman prepare example/database exemple/tool
Transfer databases from the working computer to s3 Cloud::
# check the available optional parameters
dbman upload -h
# run the standard transfer
dbman upload example/database exemple/tool*
Transfer databases from s3 Cloud to working computer::
# check the available optional parameters
dbman download -h
# run the standard download
dbman download example/database exemple/tool*
Delete undesirable databases::
# from the local directory
dbman delete example/database example/tool* local
# from the s3 cloud directory
dbman delete example/database example/tool* s3
remplace the standard directory to save the data::
# change local directory with the environment variable
export DBMAN_DBDIR = example/path
# change remote directory with the environment variable
export DBMAN_S3DIR = example/path
The standard directories(local and remote) can also be change with optional parameters.
(*) For upload, download and delete of the raw databank instead of 'example/tool' enter 'raw'.
Metadata-Version: 1.0
Name: dbman
Version: 0.0.1.dev14
Summary: Download, convert and upload databases to cloud server
Home-page: UNKNOWN
Author: Rudel Fankep
Author-email: Rudel.C.NKouamedjo-fankep@bio.uni-giessen.de
License: MIT
Project-URL: Source Code, https://git.computational.bio.uni-giessen.de/cfankep/psotdb.git
Description: Download, convert and upload databases to cloud server
Keywords: tools, databases
Platform: UNKNOWN
README.rst
requirements.txt
setup.cfg
setup.py
test.py
testfile.txt
dbman/__init__.py
dbman/main.py
dbman.egg-info/PKG-INFO
dbman.egg-info/SOURCES.txt
dbman.egg-info/dependency_links.txt
dbman.egg-info/entry_points.txt
dbman.egg-info/not-zip-safe
dbman.egg-info/pbr.json
dbman.egg-info/requires.txt
dbman.egg-info/top_level.txt
dbman/scripts/blast_db.sh
dbman/scripts/delete_remote_file.sh
dbman/scripts/download_db.sh
dbman/scripts/download_json.sh
dbman/scripts/ghostx_db.sh
dbman/scripts/hmmer_pfam.sh
dbman/scripts/prepare_card.sh
dbman/scripts/prepare_pfam.sh
dbman/scripts/prepare_swissprot.sh
dbman/scripts/upload_db.sh
dbman/scripts/upload_json.sh
local_databases/dbman_metadata.json
local_databases/swissprot_2019_06_blast/uniprot_sprot.fasta.phr
local_databases/swissprot_2019_06_blast/uniprot_sprot.fasta.pin
local_databases/swissprot_2019_06_blast/uniprot_sprot.fasta.psq
\ No newline at end of file
[console_scripts]
dbman = dbman.main:main
{"git_version": "2b012ee", "is_release": false}
\ No newline at end of file
wget
dbman
File added
File added
......@@ -9,10 +9,14 @@ import wget
from datetime import date
import tarfile
import json
import pkg_resources
def myparser():
parser = argparse.ArgumentParser(description='Download, convert and share the data to working computer', prog='PSOT_database_maker')
parser = argparse.ArgumentParser(description='Download, convert and upload databases to cloud server', prog='Database Manager')
parser.set_defaults(func=help)
subparsers = parser.add_subparsers(title='Subcommands', description='Authorized Subcommands', help='Additional help')
......@@ -59,7 +63,13 @@ def myparser():
list_recipes_parser = subparsers.add_parser('list_recipes', help='print databases with the possible Tool/s')
list_recipes_parser.set_defaults(func=list_recipes)
return parser.parse_args()
args = parser.parse_args()
args.parser = parser
return args
def help(args):
args.parser.print_help()
def get_local_databases_directory(args):
......@@ -75,8 +85,8 @@ def get_remote_databases_directory(args):
web_dir = 's3://db_storage'
if args.store:
web_dir = args.store
elif 'S3_DBDIR' in os.environ:
web_dir = os.environ['S3_DBDIR']
elif 'DBMAN_S3DIR' in os.environ:
web_dir = os.environ['DBMAN_S3DIR']
return web_dir
......@@ -196,7 +206,7 @@ def get_path_local_json(args):
def get_path_remote_json(args):
return path_maker(get_remote_databases_directory(args), 'dbman_remote_metadata.json.tar.gz')
return path_maker(get_remote_databases_directory(args), 'dbman_remote_metadata.json')
def get_local_metadata(args):
......@@ -217,7 +227,7 @@ def save_local_metadata(args, metaliste):
def get_remote_metadata(args):
if get_path_remote_json(args) in get_remote_files():
subprocess.run(['./download_db.sh', get_path_remote_json(args), get_local_databases_directory(args), 'dbman_remote_metadata.json.tar.gz'])
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/download_json.sh"), get_path_remote_json(args), get_local_databases_directory(args)])
with open(path_maker(get_local_databases_directory(args), 'dbman_remote_metadata.json')) as f:
metadata = json.load(f)
os.remove(path_maker(get_local_databases_directory(args), 'dbman_remote_metadata.json'))
......@@ -227,10 +237,10 @@ def get_remote_metadata(args):
def save_remote_metadata(args, metaliste):
with open('dbman_remote_metadata.json', 'w') as f:
with open(path_maker(get_local_databases_directory(args), 'dbman_remote_metadata.json'), 'w') as f:
json.dump(metaliste, f)
subprocess.run(['./upload_db.sh', './', 'dbman_remote_metadata.json.tar.gz', 'dbman_remote_metadata.json', get_remote_databases_directory(args)])
os.remove('dbman_remote_metadata.json')
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/upload_json.sh"), get_local_databases_directory(args), 'dbman_remote_metadata.json', get_remote_databases_directory(args)])
os.remove(path_maker(get_local_databases_directory(args), 'dbman_remote_metadata.json'))
def get_remote_filename(args, version):
......@@ -246,7 +256,7 @@ def get_tar_filename(args, version):
def create_tar_file_and_upload(args, version):
subprocess.run(['./upload_db.sh', get_local_databases_directory(args), get_tar_filename(args, version), get_tool_directory_name(args, version), get_remote_databases_directory(args)])
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/upload_db.sh"), get_local_databases_directory(args), get_tar_filename(args, version), get_tool_directory_name(args, version), get_remote_databases_directory(args)])
def prepare(args):
......@@ -317,7 +327,7 @@ def download(args):
if version != 'error':
if not os.path.isdir(get_path_tool_directory(args, version)):
download_file = path_maker(get_remote_databases_directory(args), get_tar_filename(args, version))
subprocess.run(['./download_db.sh', download_file, get_local_databases_directory(args), get_tar_filename(args, version)])
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/download_db.sh"), download_file, get_local_databases_directory(args), get_tar_filename(args, version)])
local_metadata = get_local_metadata(args)
for dictionnary in get_remote_metadata(args):
if dictionnary['name'] == args.database and dictionnary['tool'] == args.tool and dictionnary['version'] == version:
......@@ -337,36 +347,40 @@ def download(args):
def delete(args):
if args.database in data.keys():
if args.tool in data[args.database]['tool'].keys() or args.tool == "raw":
if args.place == 'local':
version = get_local_json_version(args)
dbman_dir = get_local_databases_directory(args)
directory_to_delete = path_maker(dbman_dir, get_tool_directory_name(args, version))
if os.path.isdir(directory_to_delete):
shutil.rmtree(directory_to_delete)
metadata = get_local_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_local_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
elif args.place == 's3':
version = get_remote_json_version(args)
web_store = get_remote_databases_directory(args)
web_file = path_maker(web_store, get_tar_filename(args, version))
if web_file in get_remote_files():
subprocess.run(['./delete_remote_file.sh', web_file])
metadata = get_remote_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_remote_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + web_store)
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + web_store)
frage = input('Do you want to continue (Y/N)? ')
if frage.lower() == 'y':
if args.place == 'local':
version = get_local_json_version(args)
dbman_dir = get_local_databases_directory(args)
directory_to_delete = path_maker(dbman_dir, get_tool_directory_name(args, version))
if os.path.isdir(directory_to_delete):
shutil.rmtree(directory_to_delete)
metadata = get_local_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_local_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + os.path.abspath(dbman_dir))
elif args.place == 's3':
version = get_remote_json_version(args)
web_store = get_remote_databases_directory(args)
web_file = path_maker(web_store, get_tar_filename(args, version))
if web_file in get_remote_files():
subprocess.run([pkg_resources.resource_filename(__name__, "scripts/delete_remote_file.sh"), web_file])
metadata = get_remote_metadata(args)
for position in range(0, len(metadata)):
if metadata[position]['name'] == args.database and metadata[position]['tool'] == args.tool and metadata[position]['version'] == version:
del metadata[position]
break
save_remote_metadata(args, metadata)
print("The {} files were successfully delete from: ".format(get_tool_directory_name(args, version)) + web_store)
else:
print("The {} files aren't existing in: ".format(get_tool_directory_name(args, version)) + web_store)
else:
print('delete canceled')
else:
print('Tool error. There are following possibility: {}'.format([tool for tool in data[args.database]['tool'].keys()]))
else:
......@@ -390,18 +404,18 @@ def list_remote_databases(args):
print('\n{}[{}] Version: {} erstellt am: {}'.format(dic_fichier['name'], dic_fichier['tool'], dic_fichier['version'], dic_fichier['created']))
data = {'swissprot': {'prepare': './prepare_swissprot.sh',
'tool': {'blast': './blast_db.sh', 'ghostx': './ghostx_db.sh'},
data = {'swissprot': {'prepare': pkg_resources.resource_filename(__name__, "scripts/prepare_swissprot.sh"),
'tool': {'blast': pkg_resources.resource_filename(__name__, "scripts/blast_db.sh"), 'ghostx': pkg_resources.resource_filename(__name__, "scripts/ghostx_db.sh")},
'filename': 'uniprot_sprot.fasta',
'version': get_swissprot_version
},
'pfam': {'prepare': './prepare_pfam.sh',
'tool': {'hmmer': './hmmer_pfam.sh'},
'pfam': {'prepare': pkg_resources.resource_filename(__name__, "scripts/prepare_pfam.sh"),
'tool': {'hmmer': pkg_resources.resource_filename(__name__, "scripts/hmmer_pfam.sh")},
'filename': 'Pfam-A.hmm',
'version': get_pfam_version
},
'card': {'prepare': './prepare_card.sh',
'tool': {'blast': './blast_db.sh', 'ghostx': './ghostx_db.sh'},
'card': {'prepare': pkg_resources.resource_filename(__name__, "scripts/prepare_card.sh"),
'tool': {'blast': pkg_resources.resource_filename(__name__, "scripts/blast_db.sh"), 'ghostx': pkg_resources.resource_filename(__name__, "scripts/ghostx_db.sh")},
'filename': 'protein_fasta_protein_homolog_model.fasta',
'version': get_card_version
}
......
File moved
File moved
#!/bin/bash
REMOTE_FILE=$1
LOCAL_DATABASE_DIRECTORY=$2
cd $LOCAL_DATABASE_DIRECTORY
s3cmd get $REMOTE_FILE
cd -
\ No newline at end of file
File moved
File moved
File moved