Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
psot.repository
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
psot.repository
Commits
176b0270
Commit
176b0270
authored
8 years ago
by
Lukas Jelonek
Browse files
Options
Downloads
Patches
Plain Diff
[WIP] nextflow script generation
parent
6578edd8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bin/PSOT
+81
-9
81 additions, 9 deletions
bin/PSOT
with
81 additions
and
9 deletions
bin/PSOT
+
81
−
9
View file @
176b0270
...
...
@@ -2,13 +2,87 @@
import
argparse
from
config
import
load_config
parser
=
argparse
.
ArgumentParser
(
description
=
'
Make bioinformatic observations on aminoacid sequences
'
)
parser
.
add_argument
(
'
--fasta
'
,
'
-f
'
,
help
=
'
A fasta file with aminoacid sequences
'
)
parser
.
add_argument
(
'
--listanalyses
'
,
'
-l
'
,
action
=
'
store_true
'
,
help
=
'
Show available analysis steps
'
)
config
=
load_config
()
args
=
parser
.
parse_args
()
def
main
():
parser
=
argparse
.
ArgumentParser
(
description
=
'
Make bioinformatic observations on aminoacid sequences
'
)
config
=
load_config
()
subparsers
=
parser
.
add_subparsers
()
info_parser
=
subparsers
.
add_parser
(
'
info
'
)
info_parser
.
add_argument
(
'
--listanalyses
'
,
'
-l
'
,
action
=
'
store_true
'
,
help
=
'
Show available analysis steps
'
)
info_parser
.
set_defaults
(
func
=
info
)
analyze_parser
=
subparsers
.
add_parser
(
'
analyze
'
)
analyze_parser
.
add_argument
(
'
--fasta
'
,
'
-f
'
,
required
=
True
,
help
=
'
A fasta file with aminoacid sequences
'
)
analyze_parser
.
add_argument
(
'
--output
'
,
'
-o
'
,
required
=
True
,
help
=
'
The output directory for the json documents
'
)
analyze_parser
.
add_argument
(
'
--profile
'
,
'
-p
'
,
default
=
'
fast
'
,
help
=
'
The profile to use
'
)
analyze_parser
.
add_argument
(
'
--config
'
,
'
-c
'
,
help
=
'
The config to use
'
)
analyze_parser
.
set_defaults
(
func
=
analyze
)
args
=
parser
.
parse_args
()
args
.
func
(
args
)
def
info
(
args
):
show_analyses
()
def
analyze
(
args
):
print
()
modules
=
get_modules_for_profile
(
args
.
profile
)
generate_nextflow_script
(
modules
)
def
get_modules_for_profile
(
profile
):
# find profile by name
p
=
[
x
for
x
in
config
[
'
profiles
'
]
if
x
[
'
name
'
]
==
profile
][
0
]
# find all modules for profile from modules config section
m
=
[
x
for
x
in
config
[
'
modules
'
]
if
x
[
'
name
'
]
in
p
[
'
modules
'
]]
import
copy
modules
=
copy
.
deepcopy
(
m
)
# generate unique ids for module
for
module
in
modules
:
module
[
'
id
'
]
=
module
[
'
name
'
]
return
modules
def
generate_nextflow_script
(
modules
):
print
(
'''
params.file =
"
example/proteins.fas
"
Channel.fromPath(param.file).set{fasta}
'''
)
target_channels
=
[
"
for_
"
+
m
[
'
id
'
]
for
m
in
modules
]
print
(
'
fasta.join{
'
+
'
;
'
.
join
(
target_channels
)
+
'
}
'
)
from
string
import
Template
analysis_template
=
Template
(
'''
process ${id} {
input:
file fasta from for_${id}
output:
file
"
$${fasta}.${id}.results
"
into ${id}_results
script:
"""
${analysis_script} --fasta $$fasta --output $${fasta}.${id}.results
"""
}
'''
)
convert_template
=
Template
(
'''
process convert_${id}_to_json {
input:
file result from ${id}_results
output:
file
"
$${result}.json
"
into ${id}_json
script:
"""
${converter_script} --result $$result --output $${result}.json
"""
}
'''
)
for
m
in
modules
:
print
(
analysis_template
.
substitute
(
m
))
print
(
convert_template
.
substitute
(
m
))
def
show_analyses
():
print
(
'
Profiles:
'
)
...
...
@@ -22,8 +96,6 @@ def show_analyses():
print
(
'
Available modules for custom profile:
'
)
for
module
in
config
[
'
modules
'
]:
print
(
'
{0:<20} - {1}
'
.
format
(
module
[
'
name
'
],
module
[
'
info
'
]))
exit
(
0
)
if
args
.
listanalyses
:
show_analyses
()
if
__name__
==
"
__main__
"
:
main
()
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