Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
edd143bc
Commit
edd143bc
authored
May 14, 2013
by
Jerome Mariette
Browse files
No commit message
No commit message
parent
97b3b8a6
Changes
2
Hide whitespace changes
Inline
Side-by-side
workflows/components/sffExtract.py
View file @
edd143bc
...
...
@@ -27,50 +27,12 @@ from weaver.function import ShellFunction
from
weaver.abstraction
import
Map
class
SFF
E
xtract
(
Analysis
):
class
SFF
e
xtract
(
Component
):
def
define_parameters
(
self
,
input_files
,
archive_name
=
None
):
def
define_parameters
(
self
,
input_files
):
self
.
input_files
=
InputFileList
(
input_files
,
Formats
.
SFF
)
self
.
archive_name
=
archive_name
self
.
fastq_files
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.fastq'
,
self
.
input_files
),
Formats
.
FASTQ
)
self
.
stdouts
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.stdout'
,
self
.
input_files
))
def
define_analysis
(
self
):
self
.
name
=
"Convert"
self
.
description
=
"Convert sff file in fastq format."
self
.
software
=
"sff_extract.py"
self
.
options
=
"-c"
def
post_process
(
self
):
import
re
extract_regex
=
re
.
compile
(
"Converted (.*) reads into (.*) sequences."
)
clips_regexp
=
re
.
compile
(
"After applying left clips, (.*) sequences \(=(.*)%\) start with these bases:"
)
for
stdout
in
self
.
stdouts
:
found
=
False
nb_reads
,
nb_seq
,
cliped
,
perc_cliped
,
seq_cliped
=
0
,
0
,
0
,
0
,
""
for
line
in
open
(
stdout
).
readlines
():
mr
=
extract_regex
.
match
(
line
)
cr
=
clips_regexp
.
match
(
line
)
if
found
:
seq_cliped
=
line
.
strip
()
found
=
False
if
mr
!=
None
:
nb_reads
,
nb_seq
=
mr
.
group
(
1
),
mr
.
group
(
2
)
if
cr
!=
None
:
cliped
,
perc_cliped
=
cr
.
group
(
1
),
cr
.
group
(
2
)
found
=
True
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"nb_reads"
,
nb_reads
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"nb_seq"
,
nb_seq
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"cliped"
,
cliped
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"perc_cliped"
,
perc_cliped
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"seq_cliped"
,
seq_cliped
)
self
.
_create_and_archive
(
self
.
fastq_files
,
self
.
archive_name
)
def
get_version
(
self
):
cmd
=
[
self
.
get_exec_path
(
"sff_extract.py"
),
"--version"
]
p
=
Popen
(
cmd
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
return
stdout
.
split
()[
1
]
def
process
(
self
):
sff_extract
=
ShellFunction
(
self
.
get_exec_path
(
"sff_extract.py"
)
+
" -c $1 -s $2 > $3"
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
...
...
workflows/components/sffExtractA.py
0 → 100644
View file @
edd143bc
#
# Copyright (C) 2012 INRA
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import
os
from
subprocess
import
Popen
,
PIPE
from
jflow.component
import
Component
from
jflow.iotypes
import
OutputFileList
,
InputFileList
,
Formats
from
jflow.abstraction
import
MultiMap
from
ng6.analysis
import
Analysis
from
weaver.function
import
ShellFunction
from
weaver.abstraction
import
Map
class
SFFExtract
(
Analysis
):
def
define_parameters
(
self
,
input_files
,
archive_name
=
None
):
self
.
input_files
=
InputFileList
(
input_files
,
Formats
.
SFF
)
self
.
archive_name
=
archive_name
self
.
fastq_files
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.fastq'
,
self
.
input_files
),
Formats
.
FASTQ
)
self
.
stdouts
=
OutputFileList
(
self
.
get_outputs
(
'{basename_woext}.stdout'
,
self
.
input_files
))
def
define_analysis
(
self
):
self
.
name
=
"Convert"
self
.
description
=
"Convert sff file in fastq format."
self
.
software
=
"sff_extract.py"
self
.
options
=
"-c"
def
post_process
(
self
):
import
re
extract_regex
=
re
.
compile
(
"Converted (.*) reads into (.*) sequences."
)
clips_regexp
=
re
.
compile
(
"After applying left clips, (.*) sequences \(=(.*)%\) start with these bases:"
)
for
stdout
in
self
.
stdouts
:
found
=
False
nb_reads
,
nb_seq
,
cliped
,
perc_cliped
,
seq_cliped
=
0
,
0
,
0
,
0
,
""
for
line
in
open
(
stdout
).
readlines
():
mr
=
extract_regex
.
match
(
line
)
cr
=
clips_regexp
.
match
(
line
)
if
found
:
seq_cliped
=
line
.
strip
()
found
=
False
if
mr
!=
None
:
nb_reads
,
nb_seq
=
mr
.
group
(
1
),
mr
.
group
(
2
)
if
cr
!=
None
:
cliped
,
perc_cliped
=
cr
.
group
(
1
),
cr
.
group
(
2
)
found
=
True
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"nb_reads"
,
nb_reads
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"nb_seq"
,
nb_seq
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"cliped"
,
cliped
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"perc_cliped"
,
perc_cliped
)
self
.
_add_result_element
(
os
.
path
.
basename
(
stdout
),
"seq_cliped"
,
seq_cliped
)
self
.
_create_and_archive
(
self
.
fastq_files
,
self
.
archive_name
)
def
get_version
(
self
):
cmd
=
[
self
.
get_exec_path
(
"sff_extract.py"
),
"--version"
]
p
=
Popen
(
cmd
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
return
stdout
.
split
()[
1
]
def
process
(
self
):
sff_extract
=
ShellFunction
(
self
.
get_exec_path
(
"sff_extract.py"
)
+
" -c $1 -s $2 > $3"
,
cmd_format
=
'{EXE} {IN} {OUT}'
)
sff_extract
=
MultiMap
(
sff_extract
,
self
.
input_files
,
[
self
.
fastq_files
,
self
.
stdouts
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment