Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mirrors
biopet.biopet
Commits
3049d572
Commit
3049d572
authored
Jan 19, 2016
by
Wai Yi Leung
Browse files
Update Cutadapt wrapper and style change (camelCaps instead of _)
parent
564081d7
Changes
3
Hide whitespace changes
Inline
Side-by-side
public/biopet-extensions/src/main/scala/nl/lumc/sasc/biopet/extensions/Cutadapt.scala
View file @
3049d572
...
...
@@ -26,19 +26,19 @@ import scala.collection.mutable
import
scala.io.Source
/**
* Extension for cutadapt
* Started with version 1.5
* Updated to version 1.9 (18-01-2016 by wyleung)
*
*/
* Extension for cutadapt
* Started with version 1.5
* Updated to version 1.9 (18-01-2016 by wyleung)
*/
class
Cutadapt
(
val
root
:
Configurable
)
extends
BiopetCommandLineFunction
with
Summarizable
with
Version
{
@Input
(
doc
=
"Input fastq file"
)
var
fastq
_i
nput
:
File
=
_
var
fastq
I
nput
:
File
=
_
@Output
var
fastq
_o
utput
:
File
=
_
var
fastq
O
utput
:
File
=
_
@Output
(
doc
=
"Output statistics file"
)
var
stats
_o
utput
:
File
=
_
var
stats
O
utput
:
File
=
_
executable
=
config
(
"exe"
,
default
=
"cutadapt"
)
def
versionCommand
=
executable
+
" --version"
...
...
@@ -47,10 +47,10 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
/** Name of the key containing clipped adapters information in the summary stats. */
def
adaptersStatsName
=
"adapters"
var
default
_c
lip
_m
ode
:
String
=
config
(
"default_clip_mode"
,
default
=
"3"
)
var
opt_
adapter
:
Set
[
String
]
=
config
(
"adapter"
,
default
=
Nil
)
var
opt_
anywhere
:
Set
[
String
]
=
config
(
"anywhere"
,
default
=
Nil
)
var
opt_
front
:
Set
[
String
]
=
config
(
"front"
,
default
=
Nil
)
var
default
C
lip
M
ode
:
String
=
config
(
"default_clip_mode"
,
default
=
"3"
)
var
adapter
:
Set
[
String
]
=
config
(
"adapter"
,
default
=
Nil
)
var
anywhere
:
Set
[
String
]
=
config
(
"anywhere"
,
default
=
Nil
)
var
front
:
Set
[
String
]
=
config
(
"front"
,
default
=
Nil
)
var
errorRate
:
Option
[
Double
]
=
config
(
"error_rate"
)
var
noIndels
:
Boolean
=
config
(
"no_indels"
,
default
=
false
)
...
...
@@ -60,17 +60,17 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
var
noMatchAdapterWildcards
:
Boolean
=
config
(
"no_match_adapter_wildcards"
,
default
=
false
)
// specific for 1.9
/** Options for filtering of processed reads */
var
opt_
discard
:
Boolean
=
config
(
"discard"
,
default
=
false
)
var
trimmed
_o
nly
:
Boolean
=
config
(
"trimmed_only"
,
default
=
false
)
var
opt_
minimum
_l
ength
:
Int
=
config
(
"minimum_length"
,
1
)
var
opt_
maximum
_l
ength
:
Option
[
Int
]
=
config
(
"maximum_length"
)
var
discard
:
Boolean
=
config
(
"discard"
,
default
=
false
)
var
trimmed
O
nly
:
Boolean
=
config
(
"trimmed_only"
,
default
=
false
)
var
minimum
L
ength
:
Int
=
config
(
"minimum_length"
,
1
)
var
maximum
L
ength
:
Option
[
Int
]
=
config
(
"maximum_length"
)
var
noTrim
:
Boolean
=
config
(
"no_trim"
,
default
=
false
)
var
maxN
:
Option
[
Int
]
=
config
(
"max_n"
)
// specific for 1.9
var
maskAdapter
:
Boolean
=
config
(
"mask_adapter"
,
default
=
false
)
/** Options that influence what gets output to where */
var
quiet
:
Boolean
=
config
(
"quiet"
,
default
=
false
)
// var output: File // see up @Output
// var output: File // see up @Output
var
infoFile
:
Option
[
File
]
=
config
(
"info_file"
)
var
restFile
:
Option
[
File
]
=
config
(
"rest_file"
)
var
wildcardFile
:
Option
[
File
]
=
config
(
"wildcard_file"
)
...
...
@@ -89,31 +89,30 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
var
lengthTag
:
Option
[
String
]
=
config
(
"length_tag"
)
/** Colorspace options */
var
colorspace
:
Boolean
=
config
(
"colorspace"
,
default
=
false
)
var
doubleEncode
:
Boolean
=
config
(
"double_encode"
,
default
=
false
)
var
trimPrimer
:
Boolean
=
config
(
"trim_primer"
,
default
=
false
)
var
stripF3
:
Boolean
=
config
(
"strip_f3"
,
default
=
false
)
var
maq
:
Boolean
=
config
(
"maq"
,
default
=
false
)
var
bwa
:
Boolean
=
config
(
"bwa"
,
default
=
false
)
var
noZeroCap
:
Boolean
=
config
(
"no_zero_cap"
,
default
=
false
)
var
zeroCap
:
Boolean
=
config
(
"zero_cap"
,
default
=
false
)
var
colorspace
:
Boolean
=
config
(
"colorspace"
,
default
=
false
)
var
doubleEncode
:
Boolean
=
config
(
"double_encode"
,
default
=
false
)
var
trimPrimer
:
Boolean
=
config
(
"trim_primer"
,
default
=
false
)
var
stripF3
:
Boolean
=
config
(
"strip_f3"
,
default
=
false
)
var
maq
:
Boolean
=
config
(
"maq"
,
default
=
false
)
var
bwa
:
Boolean
=
config
(
"bwa"
,
default
=
false
)
var
noZeroCap
:
Boolean
=
config
(
"no_zero_cap"
,
default
=
false
)
var
zeroCap
:
Boolean
=
config
(
"zero_cap"
,
default
=
false
)
/** Paired end options */
var
peAdapter
:
Set
[
String
]
=
config
(
"pe_adapter"
,
default
=
Nil
)
var
peAdapterFront
:
Set
[
String
]
=
config
(
"pe_adapter_front"
,
default
=
Nil
)
var
peAdapterBoth
:
Set
[
String
]
=
config
(
"pe_adapter_both"
,
default
=
Nil
)
var
peCut
:
Boolean
=
config
(
"pe_cut"
,
default
=
false
)
var
peCut
:
Boolean
=
config
(
"pe_cut"
,
default
=
false
)
var
pairedOutput
:
Option
[
File
]
=
config
(
"paired_output"
)
var
interleaved
:
Boolean
=
config
(
"interleaved"
,
default
=
false
)
var
interleaved
:
Boolean
=
config
(
"interleaved"
,
default
=
false
)
var
untrimmedPairedOutput
:
Option
[
File
]
=
config
(
"untrimmed_paired_output"
)
/** return commandline to execute */
def
cmdLine
=
required
(
executable
)
+
// Options that influence how the adapters are found
repeat
(
"-a"
,
opt_
adapter
)
+
repeat
(
"-b"
,
opt_
anywhere
)
+
repeat
(
"-g"
,
opt_
front
)
+
repeat
(
"-a"
,
adapter
)
+
repeat
(
"-b"
,
anywhere
)
+
repeat
(
"-g"
,
front
)
+
optional
(
"--error-rate"
,
errorRate
)
+
conditional
(
noIndels
,
"--no-indels"
)
+
optional
(
"--times"
,
times
)
+
...
...
@@ -121,10 +120,10 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
conditional
(
matchReadWildcards
,
"--match-read-wildcards"
)
+
conditional
(
noMatchAdapterWildcards
,
"--no-match-adapter-wildcards"
)
+
// Options for filtering of processed reads
conditional
(
opt_
discard
,
"--discard"
)
+
conditional
(
trimmed
_o
nly
,
"--trimmed-only"
)
+
optional
(
"-m"
,
opt_
minimum
_l
ength
)
+
optional
(
"-M"
,
opt_
maximum
_l
ength
)
+
conditional
(
discard
,
"--discard"
)
+
conditional
(
trimmed
O
nly
,
"--trimmed-only"
)
+
optional
(
"-m"
,
minimum
L
ength
)
+
optional
(
"-M"
,
maximum
L
ength
)
+
conditional
(
noTrim
,
"--no-trim"
)
+
optional
(
"--max-n"
,
maxN
)
+
conditional
(
maskAdapter
,
"--mask-adapter"
)
+
...
...
@@ -160,9 +159,9 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
optional
(
"--paired-output"
,
pairedOutput
)
+
optional
(
"--untrimmed-paired-output"
,
untrimmedPairedOutput
)
+
// input / output
required
(
fastq
_i
nput
)
+
(
if
(
outputAsStsout
)
""
else
required
(
"--output"
,
fastq
_o
utput
)
+
" > "
+
required
(
stats
_o
utput
))
required
(
fastq
I
nput
)
+
(
if
(
outputAsStsout
)
""
else
required
(
"--output"
,
fastq
O
utput
)
+
" > "
+
required
(
stats
O
utput
))
/** Output summary stats */
def
summaryStats
:
Map
[
String
,
Any
]
=
{
...
...
@@ -174,7 +173,7 @@ class Cutadapt(val root: Configurable) extends BiopetCommandLineFunction with Su
val
stats
:
mutable.Map
[
String
,
Int
]
=
mutable
.
Map
(
"trimmed"
->
0
,
"tooshort"
->
0
,
"toolong"
->
0
)
val
adapter_stats
:
mutable.Map
[
String
,
Int
]
=
mutable
.
Map
()
if
(
stats
_o
utput
.
exists
)
for
(
line
<-
Source
.
fromFile
(
stats
_o
utput
).
getLines
())
{
if
(
stats
O
utput
.
exists
)
for
(
line
<-
Source
.
fromFile
(
stats
O
utput
).
getLines
())
{
line
match
{
case
trimR
(
m
)
=>
stats
+=
(
"trimmed"
->
m
.
toInt
)
case
tooShortR
(
m
)
=>
stats
+=
(
"tooshort"
->
m
.
toInt
)
...
...
public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Cutadapt.scala
View file @
3049d572
...
...
@@ -46,16 +46,16 @@ class Cutadapt(root: Configurable, fastqc: Fastqc) extends nl.lumc.sasc.biopet.e
// adapter sequence is clipped but not found by FastQC ~ should not happen since all clipped adapter
// sequences come from FastQC
case
_
=>
throw
new
IllegalStateException
(
s
"Adapter '$seq' is clipped but not found by FastQC in '$fastq
_i
nput'."
)
throw
new
IllegalStateException
(
s
"Adapter '$seq' is clipped but not found by FastQC in '$fastq
I
nput'."
)
}
// FastQC found no adapters
case
otherwise
=>
;
logger
.
debug
(
s
"No adapters found for summarizing in '$fastq
_i
nput'."
)
logger
.
debug
(
s
"No adapters found for summarizing in '$fastq
I
nput'."
)
None
}
// "adapters" key not found ~ something went wrong in our part
case
_
=>
throw
new
RuntimeException
(
s
"Required key 'adapters' not found in stats entry '$fastq
_i
nput'."
)
case
_
=>
throw
new
RuntimeException
(
s
"Required key 'adapters' not found in stats entry '$fastq
I
nput'."
)
}
initStats
.
updated
(
adaptersStatsName
,
adapterCounts
)
}
...
...
public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/QcCommand.scala
View file @
3049d572
...
...
@@ -102,12 +102,12 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
val
foundAdapters
=
fastqc
.
foundAdapters
.
map
(
_
.
seq
)
if
(
foundAdapters
.
nonEmpty
)
{
val
cutadapt
=
new
Cutadapt
(
root
,
fastqc
)
cutadapt
.
fastq
_i
nput
=
seqtk
.
output
cutadapt
.
fastq
_o
utput
=
new
File
(
output
.
getParentFile
,
input
.
getName
+
".cutadapt.fq"
)
cutadapt
.
stats
_o
utput
=
new
File
(
flexiprep
.
outputDir
,
s
"${flexiprep.sampleId.getOrElse("
x
")}-${flexiprep.libId.getOrElse("
x
")}.$read.clip.stats"
)
if
(
cutadapt
.
default
_c
lip
_m
ode
==
"3"
)
cutadapt
.
opt_
adapter
++=
foundAdapters
else
if
(
cutadapt
.
default
_c
lip
_m
ode
==
"5"
)
cutadapt
.
opt_
front
++=
foundAdapters
else
if
(
cutadapt
.
default
_c
lip
_m
ode
==
"both"
)
cutadapt
.
opt_
anywhere
++=
foundAdapters
cutadapt
.
fastq
I
nput
=
seqtk
.
output
cutadapt
.
fastq
O
utput
=
new
File
(
output
.
getParentFile
,
input
.
getName
+
".cutadapt.fq"
)
cutadapt
.
stats
O
utput
=
new
File
(
flexiprep
.
outputDir
,
s
"${flexiprep.sampleId.getOrElse("
x
")}-${flexiprep.libId.getOrElse("
x
")}.$read.clip.stats"
)
if
(
cutadapt
.
default
C
lip
M
ode
==
"3"
)
cutadapt
.
adapter
++=
foundAdapters
else
if
(
cutadapt
.
default
C
lip
M
ode
==
"5"
)
cutadapt
.
front
++=
foundAdapters
else
if
(
cutadapt
.
default
C
lip
M
ode
==
"both"
)
cutadapt
.
anywhere
++=
foundAdapters
addPipeJob
(
cutadapt
)
Some
(
cutadapt
)
}
else
None
...
...
@@ -117,7 +117,7 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
val
sickle
=
new
Sickle
(
root
)
sickle
.
output_stats
=
new
File
(
flexiprep
.
outputDir
,
s
"${flexiprep.sampleId.getOrElse("
x
")}-${flexiprep.libId.getOrElse("
x
")}.$read.trim.stats"
)
sickle
.
input_R1
=
clip
match
{
case
Some
(
c
)
=>
c
.
fastq
_o
utput
case
Some
(
c
)
=>
c
.
fastq
O
utput
case
_
=>
seqtk
.
output
}
sickle
.
output_R1
=
new
File
(
output
.
getParentFile
,
input
.
getName
+
".sickle.fq"
)
...
...
@@ -127,7 +127,7 @@ class QcCommand(val root: Configurable, val fastqc: Fastqc) extends BiopetComman
val
outputFile
=
(
clip
,
trim
)
match
{
case
(
_
,
Some
(
t
))
=>
t
.
output_R1
case
(
Some
(
c
),
_
)
=>
c
.
fastq
_o
utput
case
(
Some
(
c
),
_
)
=>
c
.
fastq
O
utput
case
_
=>
seqtk
.
output
}
...
...
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