Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dbman
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SOaAS
dbman
Commits
be780604
Commit
be780604
authored
4 years ago
by
Lukas Jelonek
Browse files
Options
Downloads
Patches
Plain Diff
Add diamond database creation\nFix bug\nImprove logging
parent
c4d8ffab
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dbman/helper.py
+1
-1
1 addition, 1 deletion
dbman/helper.py
dbman/main.py
+6
-3
6 additions, 3 deletions
dbman/main.py
dbman/recipes/create_diamond_dbs.py
+30
-0
30 additions, 0 deletions
dbman/recipes/create_diamond_dbs.py
with
37 additions
and
4 deletions
dbman/helper.py
+
1
−
1
View file @
be780604
...
...
@@ -45,7 +45,7 @@ def create_metadata(name,
def
save_metadata
(
metadata
,
path
=
"
./metadata.json
"
):
with
open
(
path
,
"
w
"
)
as
metadata_file
:
logging
.
info
(
"
Writing metadata
"
+
json
.
dumps
(
metadata
))
logging
.
debug
(
"
Writing metadata
to
'
%s
'"
,
os
.
path
.
abspath
(
path
))
json
.
dump
(
metadata
,
metadata_file
)
def
load_metadata
(
path
=
"
./metadata.json
"
):
...
...
This diff is collapsed.
Click to expand it.
dbman/main.py
+
6
−
3
View file @
be780604
...
...
@@ -8,6 +8,7 @@ import pathlib
import
prettytable
import
shutil
import
pkg_resources
import
shutil
import
dbman.helper
as
h
def
main
():
...
...
@@ -91,7 +92,7 @@ def prepare(args):
if
not
transform_recipe
:
logging
.
warn
(
"
Recipe
'
%s - %s
'
does not exits
"
,
args
.
tool
,
args
.
tool
)
return
db_info
=
_getdb
(
_local_databases
(
args
),
args
.
database
,
args
.
tool
)
db_info
=
_getdb
(
_local_databases
(
args
),
args
.
database
,
'
download
'
)
if
not
db_info
or
args
.
force_download
:
logging
.
info
(
"
Database
'
%s
'
not found. Downloading it.
"
,
args
.
database
)
db_info
=
run_in_tempdir
(
func
=
lambda
:
h
.
run_external_tool
(
download_recipe
[
'
script
'
],
download_recipe
[
'
params
'
]
if
'
params
'
in
download_recipe
else
None
),
...
...
@@ -136,10 +137,10 @@ def _rename_directory_after_metadata(path):
oldpath
=
pathlib
.
Path
(
path
)
newpath
=
oldpath
.
parent
.
parent
.
joinpath
(
newname
)
if
newpath
.
exists
():
import
shutil
shutil
.
rmtree
(
str
(
newpath
))
logging
.
debug
(
"
Renaming
'
%s
'
to
'
%s
'"
,
oldpath
,
newpath
)
oldpath
.
rename
(
newpath
)
metadata
[
'
location
'
]
=
str
(
newpath
.
absolute
())
return
metadata
def
run_in_tempdir
(
func
=
None
,
success
=
None
,
fail
=
None
):
...
...
@@ -163,10 +164,12 @@ def run_in_tempdir(func=None, success=None, fail=None):
def
_recipes
(
args
):
recipes
=
{
'
card
'
:
{
'
download
'
:
{
'
script
'
:
_pkgres
(
'
recipes/download_card.py
'
)},
'
blast
'
:
{
'
script
'
:
_pkgres
(
'
recipes/create_blast_dbs.py
'
)}
'
blast
'
:
{
'
script
'
:
_pkgres
(
'
recipes/create_blast_dbs.py
'
)},
'
diamond
'
:
{
'
script
'
:
_pkgres
(
'
recipes/create_diamond_dbs.py
'
)},
},
'
swissprot
'
:
{
'
download
'
:
{
'
script
'
:
_pkgres
(
'
recipes/download_uniprotkb.py
'
),
'
params
'
:
[
'
--database
'
,
'
swissprot
'
,
'
--type
'
,
'
fasta
'
]},
'
blast
'
:
{
'
script
'
:
_pkgres
(
'
recipes/create_blast_dbs.py
'
)},
'
diamond
'
:
{
'
script
'
:
_pkgres
(
'
recipes/create_diamond_dbs.py
'
)},
}
}
return
recipes
...
...
This diff is collapsed.
Click to expand it.
dbman/recipes/create_diamond_dbs.py
0 → 100755
+
30
−
0
View file @
be780604
#!/usr/bin/env python
import
dbman.helper
as
h
import
subprocess
import
sys
import
os
import
json
from
pathlib
import
Path
metadata
=
h
.
load_metadata
(
'
./.source_metadata.json
'
)
fasta_parts
=
[
p
for
p
in
metadata
[
'
parts
'
]
if
'
fasta
'
in
p
[
'
tags
'
]
and
'
protein
'
in
p
[
'
tags
'
]]
new_parts
=
[]
for
part
in
fasta_parts
:
type
=
None
for
file
in
part
[
'
files
'
]:
name
=
Path
(
file
).
stem
command
=
'
diamond makedb --db {} --in {}
'
.
format
(
name
,
file
)
cp
=
subprocess
.
run
(
command
,
shell
=
True
)
if
(
cp
.
returncode
!=
0
):
sys
.
exit
(
cp
)
files
=
[
f
.
name
for
f
in
os
.
scandir
(
'
.
'
)
if
f
.
name
.
startswith
(
name
+
'
.
'
)
and
not
f
.
name
.
endswith
(
'
.fasta
'
)]
tags
=
[
'
diamond_db
'
]
tags
.
extend
(
part
[
'
tags
'
])
tags
.
remove
(
'
fasta
'
)
new_parts
.
append
({
'
files
'
:
files
,
'
tags
'
:
tags
})
h
.
create_metadata
(
metadata
[
'
name
'
],
'
diamond
'
,
metadata
[
'
description
'
],
metadata
[
'
version
'
],
other
=
{
'
parts
'
:
new_parts
})
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment