Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Maintenance - Mise à jour mensuelle Lundi 6 Février entre 7h00 et 9h00
Open sidebar
genotoul-bioinfo
jflow
Commits
da101903
Commit
da101903
authored
Sep 04, 2014
by
Jerome Mariette
Browse files
improve the implementation a bit!
parent
a89cfae5
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/jflow/__init__.py
View file @
da101903
...
...
@@ -22,6 +22,9 @@ import os
from
jflow.config_reader
import
JFlowConfigReader
# Define some Error classes
class
InvalidFormatError
(
Exception
):
pass
jflowconf
=
JFlowConfigReader
()
# if log file directory does not exist, create it
...
...
src/jflow/parameter.py
View file @
da101903
...
...
@@ -16,6 +16,7 @@
#
import
re
import
sys
import
types
import
datetime
import
logging
...
...
@@ -621,8 +622,15 @@ class AbstractInputFile(AbstractIOFile):
eval
(
self
.
file_format
)
function_exists
=
True
except
:
function_exists
=
False
if
function_exists
:
eval
(
self
.
file_format
)(
ifile
)
if
function_exists
:
try
:
eval
(
self
.
file_format
)(
ifile
)
except
jflow
.
InvalidFormatError
as
e
:
sys
.
stderr
.
write
(
str
(
e
)
+
"
\n
"
)
sys
.
exit
(
1
)
else
:
sys
.
stderr
.
write
(
"Error: Invalid file format '"
+
self
.
file_format
+
"'!
\n
"
)
sys
.
exit
(
1
)
class
AbstractOutputFile
(
AbstractIOFile
):
"""
...
...
workflows/alignment/__init__.py
View file @
da101903
...
...
@@ -17,7 +17,6 @@
from
jflow.workflow
import
Workflow
from
jflow.parameter
import
InputFileList
,
InputFile
from
workflows.formats
import
Formats
class
Alignment
(
Workflow
):
...
...
@@ -26,9 +25,9 @@ class Alignment (Workflow):
return
"Align reads against a reference genome"
def
define_parameters
(
self
,
function
=
"process"
):
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)"
,
file_format
=
Formats
.
FASTQ
)
self
.
add_input_file
(
"reference_genome"
,
"Which genome should the read being align on"
,
required
=
True
,
file_format
=
Formats
.
FASTA
)
self
.
add_input_file_list
(
"read_1"
,
"Which read1 files should be used"
,
file_format
=
"fastq"
,
required
=
True
)
self
.
add_input_file_list
(
"read_2"
,
"Which read2 files should be used (if single end, leave empty)"
,
file_format
=
"fastq"
)
self
.
add_input_file
(
"reference_genome"
,
"Which genome should the read being align on"
,
required
=
True
,
file_format
=
"fasta"
)
def
process
(
self
):
# index the reference genome
...
...
workflows/components/bwa.py
View file @
da101903
...
...
@@ -19,19 +19,18 @@ import os
from
subprocess
import
Popen
,
PIPE
from
jflow.component
import
Component
from
workflows.formats
import
Formats
from
jflow.abstraction
import
MultiMap
from
weaver.function
import
ShellFunction
from
weaver.abstraction
import
Map
from
jflow.abstraction
import
MultiMap
class
BWA
(
Component
):
def
define_parameters
(
self
,
reference_genome
,
read1
,
read2
=
None
,
algorithm
=
"aln"
):
self
.
add_input_file
(
"reference_genome"
,
"Which reference file should be used"
,
default
=
reference_genome
,
required
=
True
)
self
.
add_input_file_list
(
"read1"
,
"Which read1 files should be used"
,
file_format
=
Formats
.
FASTQ
,
default
=
read1
,
required
=
True
)
self
.
add_input_file_list
(
"read2"
,
"Which read2 files should be used"
,
file_format
=
Formats
.
FASTQ
,
default
=
read2
)
self
.
add_input_file_list
(
"read1"
,
"Which read1 files should be used"
,
file_format
=
"fastq"
,
default
=
read1
,
required
=
True
)
self
.
add_input_file_list
(
"read2"
,
"Which read2 files should be used"
,
file_format
=
"fastq"
,
default
=
read2
)
self
.
add_parameter
(
"algorithm"
,
"Which algorithm should be used to align the reads"
,
default
=
algorithm
,
choices
=
[
"aln"
,
"bwasw"
])
if
algorithm
==
"aln"
:
self
.
add_output_file_list
(
"sai1"
,
"The BWA sai1 file"
,
pattern
=
'{basename_woext}.sai'
,
items
=
self
.
read1
)
...
...
@@ -42,10 +41,10 @@ class BWA (Component):
self
.
add_output_file_list
(
"sai2"
,
"The BWA sai2 file"
,
pattern
=
'{basename_woext}.sai'
,
items
=
self
.
read2
)
else
:
self
.
sai2
=
None
self
.
add_output_file_list
(
"bam_files"
,
"The BWA bam file"
,
pattern
=
'{basename_woext}.bam'
,
items
=
[
self
.
read1
,
self
.
read2
],
file_format
=
Formats
.
BAM
)
self
.
add_output_file_list
(
"bam_files"
,
"The BWA bam file"
,
pattern
=
'{basename_woext}.bam'
,
items
=
[
self
.
read1
,
self
.
read2
],
file_format
=
"bam"
)
else
:
self
.
sai2
=
None
self
.
add_output_file_list
(
"bam_files"
,
"The BWA bam file"
,
pattern
=
'{basename_woext}.bam'
,
items
=
self
.
read1
,
file_format
=
Formats
.
BAM
)
self
.
add_output_file_list
(
"bam_files"
,
"The BWA bam file"
,
pattern
=
'{basename_woext}.bam'
,
items
=
self
.
read1
,
file_format
=
"bam"
)
self
.
add_output_file
(
"stderr"
,
"The BWA stderr file"
,
filename
=
'bwa.stderr'
)
def
process
(
self
):
...
...
workflows/components/bwaindex.py
View file @
da101903
...
...
@@ -19,7 +19,6 @@ import os
from
subprocess
import
Popen
,
PIPE
from
jflow.component
import
Component
from
workflows.formats
import
Formats
from
weaver.function
import
PythonFunction
,
ShellFunction
...
...
@@ -43,7 +42,7 @@ def bwa_index(exec_path, algorithm, input_fasta, databank, stdout_path, stderr_p
class
BWAIndex
(
Component
):
def
define_parameters
(
self
,
input_fasta
,
algorithm
=
"bwtsw"
):
self
.
add_input_file
(
"input_fasta"
,
"Which fasta file should be indexed"
,
file_format
=
Formats
.
FASTA
,
default
=
input_fasta
,
required
=
True
)
self
.
add_input_file
(
"input_fasta"
,
"Which fasta file should be indexed"
,
file_format
=
"fasta"
,
default
=
input_fasta
,
required
=
True
)
self
.
add_parameter
(
"algorithm"
,
"Which algorithm should be used to index the fasta file"
,
default
=
algorithm
,
choices
=
[
"bwtsw"
,
"div"
,
"is"
])
self
.
add_output_file
(
"databank"
,
"The indexed databank to use with BWA"
,
filename
=
os
.
path
.
basename
(
input_fasta
))
self
.
add_output_file
(
"stdout"
,
"The BWAIndex stdout file"
,
filename
=
"bwaindex.stdout"
)
...
...
workflows/formats.py
View file @
da101903
...
...
@@ -15,18 +15,14 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import
jflow
from
jflow
import
seqio
import
os
import
sys
class
Formats
(
object
):
ANY
=
"any"
BAM
=
"bam"
FASTQ
=
"fastq"
FASTA
=
"fasta"
SFF
=
"sff"
def
any
(
ifile
):
pass
def
bam
(
ifile
):
pass
def
fastq
(
ifile
):
try
:
...
...
@@ -36,9 +32,8 @@ def fastq(ifile):
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
)
except
:
raise
jflow
.
InvalidFormatError
(
"Error: The provided file '"
+
ifile
+
"' is not a fastq file!"
)
def
fasta
(
ifile
):
try
:
...
...
@@ -48,9 +43,8 @@ def fasta(ifile):
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
)
except
:
raise
jflow
.
InvalidFormatError
(
"Error: The provided file '"
+
ifile
+
"' is not a fasta file!"
)
def
sff
(
ifile
):
try
:
...
...
@@ -60,7 +54,6 @@ def sff(ifile):
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
)
except
:
raise
jflow
.
InvalidFormatError
(
"Error: The provided file '"
+
ifile
+
"' is not a sff file!"
)
\ No newline at end of file
workflows/types.py
View file @
da101903
...
...
@@ -20,5 +20,9 @@ import datetime
def
date
(
datestr
):
return
datetime
.
datetime
.
strptime
(
datestr
,
'%d/%m/%Y'
)
try
:
return
datetime
.
datetime
.
strptime
(
datestr
,
'%d/%m/%Y'
)
except
:
raise
argparse
.
ArgumentTypeError
(
"'"
+
datestr
+
"' is an invalid date!"
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment