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
jflow
Commits
3dd46446
Commit
3dd46446
authored
Sep 03, 2014
by
Jerome Mariette
Browse files
check formats
parent
86b67132
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/jflow/parameter.py
View file @
3dd46446
...
@@ -28,8 +28,9 @@ import copy as _copy
...
@@ -28,8 +28,9 @@ import copy as _copy
from
urlparse
import
urlparse
from
urlparse
import
urlparse
from
jflow.config_reader
import
JFlowConfigReader
from
jflow.config_reader
import
JFlowConfigReader
# import custom types
# import custom types
and custom formats
from
workflows.types
import
*
from
workflows.types
import
*
from
workflows.formats
import
*
# define all input type available
# define all input type available
...
@@ -71,18 +72,6 @@ def inputfile(file):
...
@@ -71,18 +72,6 @@ def inputfile(file):
else
:
else
:
return
urlfile
(
file
)
return
urlfile
(
file
)
class
Formats
(
object
):
ANY
=
"any"
BAM
=
"bam"
FASTQ
=
"fastq"
FASTA
=
"fasta"
SFF
=
"sff"
QUAL
=
"qual"
FLOW
=
"flow"
HTML
=
"html"
class
MultipleParameters
(
object
):
class
MultipleParameters
(
object
):
def
__init__
(
self
,
types
,
required
,
choices
,
excludes
,
default
,
actions
):
def
__init__
(
self
,
types
,
required
,
choices
,
excludes
,
default
,
actions
):
self
.
types
=
types
self
.
types
=
types
...
@@ -627,6 +616,9 @@ class AbstractInputFile(AbstractIOFile):
...
@@ -627,6 +616,9 @@ class AbstractInputFile(AbstractIOFile):
except
:
except
:
return
[
input
,
False
]
return
[
input
,
False
]
def
check
(
self
,
ifile
):
eval
(
self
.
file_format
)(
ifile
)
class
AbstractOutputFile
(
AbstractIOFile
):
class
AbstractOutputFile
(
AbstractIOFile
):
"""
"""
...
@@ -667,6 +659,7 @@ class InputFile(StrParameter, AbstractInputFile):
...
@@ -667,6 +659,7 @@ class InputFile(StrParameter, AbstractInputFile):
jflow_config_reader
=
JFlowConfigReader
()
jflow_config_reader
=
JFlowConfigReader
()
new_path
=
os
.
path
.
join
(
jflow_config_reader
.
get_tmp_directory
(),
input
)
new_path
=
os
.
path
.
join
(
jflow_config_reader
.
get_tmp_directory
(),
input
)
if
is_local
:
new_path
=
input
if
is_local
:
new_path
=
input
self
.
check
(
new_path
)
return
new_path
return
new_path
...
@@ -752,6 +745,9 @@ class InputFileList(ParameterList, AbstractInputFile):
...
@@ -752,6 +745,9 @@ class InputFileList(ParameterList, AbstractInputFile):
for
path
in
path2test
:
for
path
in
path2test
:
jflow_config_reader
=
JFlowConfigReader
()
jflow_config_reader
=
JFlowConfigReader
()
new_vals
.
append
(
os
.
path
.
join
(
jflow_config_reader
.
get_tmp_directory
(),
path
))
new_vals
.
append
(
os
.
path
.
join
(
jflow_config_reader
.
get_tmp_directory
(),
path
))
# now that all files are downloaded and ok, check the format
for
cfile
in
new_vals
:
self
.
check
(
cfile
)
return
new_vals
return
new_vals
class
OutputFileList
(
ParameterList
,
AbstractOutputFile
):
class
OutputFileList
(
ParameterList
,
AbstractOutputFile
):
...
...
workflows/alignment/__init__.py
View file @
3dd46446
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
from
jflow.workflow
import
Workflow
from
jflow.workflow
import
Workflow
from
jflow.parameter
import
InputFileList
,
InputFile
from
jflow.parameter
import
InputFileList
,
InputFile
from
workflows.formats
import
Formats
class
Alignment
(
Workflow
):
class
Alignment
(
Workflow
):
...
@@ -24,9 +26,9 @@ class Alignment (Workflow):
...
@@ -24,9 +26,9 @@ class Alignment (Workflow):
return
"Align reads against a reference genome"
return
"Align reads against a reference genome"
def
define_parameters
(
self
,
function
=
"process"
):
def
define_parameters
(
self
,
function
=
"process"
):
self
.
add_input_file_list
(
"read_1"
,
"Which read1 files should be used"
,
required
=
True
)
self
.
add_input_file_list
(
"read_1"
,
"Which read1 files should be used"
,
file_format
=
Formats
.
FASTQ
,
required
=
True
)
self
.
add_input_file_list
(
"read_2"
,
"Which read2 files should be used (if single end, leave empty)"
)
self
.
add_input_file_list
(
"read_2"
,
"Which read2 files should be used (if single end, leave empty)"
,
file_format
=
Formats
.
FASTQ
)
self
.
add_input_file
(
"reference_genome"
,
"Which genome should the read being align on"
,
required
=
True
)
self
.
add_input_file
(
"reference_genome"
,
"Which genome should the read being align on"
,
required
=
True
,
file_format
=
Formats
.
FASTA
)
def
process
(
self
):
def
process
(
self
):
# index the reference genome
# index the reference genome
...
...
workflows/components/bwa.py
View file @
3dd46446
...
@@ -19,7 +19,7 @@ import os
...
@@ -19,7 +19,7 @@ import os
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
from
jflow.component
import
Component
from
jflow.component
import
Component
from
jflow.parameter
import
Formats
from
workflows.formats
import
Formats
from
weaver.function
import
ShellFunction
from
weaver.function
import
ShellFunction
from
weaver.abstraction
import
Map
from
weaver.abstraction
import
Map
...
...
workflows/components/bwaindex.py
View file @
3dd46446
...
@@ -19,7 +19,7 @@ import os
...
@@ -19,7 +19,7 @@ import os
from
subprocess
import
Popen
,
PIPE
from
subprocess
import
Popen
,
PIPE
from
jflow.component
import
Component
from
jflow.component
import
Component
from
jflow.parameter
import
Formats
from
workflows.formats
import
Formats
from
weaver.function
import
PythonFunction
,
ShellFunction
from
weaver.function
import
PythonFunction
,
ShellFunction
...
...
workflows/formats.py
0 → 100644
View file @
3dd46446
#
# 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/>.
#
from
jflow
import
seqio
import
os
import
sys
class
Formats
(
object
):
ANY
=
"any"
BAM
=
"bam"
FASTQ
=
"fastq"
FASTA
=
"fasta"
SFF
=
"sff"
def
fastq
(
ifile
):
try
:
reader
=
seqio
.
FastqReader
(
ifile
)
nb_seq
=
0
for
id
,
desc
,
seq
,
qualities
in
reader
:
nb_seq
+=
1
# only check the first 10 sequences
if
nb_seq
==
10
:
break
except
:
sys
.
stderr
.
write
(
"Error: The provided file '"
+
ifile
+
"' is not a fastq file!
\n
"
)
sys
.
exit
(
1
)
def
fasta
(
ifile
):
try
:
reader
=
seqio
.
FastaReader
(
ifile
,
wholefile
=
True
)
nb_seq
=
0
for
id
,
desc
,
seq
,
qualities
in
reader
:
nb_seq
+=
1
# only check the first 10 sequences
if
nb_seq
==
10
:
break
except
:
sys
.
stderr
.
write
(
"Error: The provided file '"
+
ifile
+
"' is not a fasta file!
\n
"
)
sys
.
exit
(
1
)
def
sff
(
ifile
):
try
:
reader
=
seqio
.
SFFReader
(
ifile
)
nb_seq
=
0
for
id
,
desc
,
seq
,
qualities
in
reader
:
nb_seq
+=
1
# only check the first 10 sequences
if
nb_seq
==
10
:
break
except
:
sys
.
stderr
.
write
(
"Error: The provided file '"
+
ifile
+
"' is not a sff file!
\n
"
)
sys
.
exit
(
1
)
\ No newline at end of file
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