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
954e0245
Commit
954e0245
authored
Oct 20, 2015
by
Peter van 't Hof
Browse files
Moved function to utils, this might be usefull in other pipelines
parent
6af00416
Changes
2
Hide whitespace changes
Inline
Side-by-side
public/biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/IoUtils.scala
View file @
954e0245
...
...
@@ -47,4 +47,26 @@ object IoUtils {
}
}
}
/** Possible compression extensions to trim from input files. */
val
zipExtensions
=
Set
(
".gz"
,
".gzip"
,
".bzip2"
,
".bz"
,
".xz"
,
".zip"
)
/**
* Given a file object and a set of compression extensions, return the filename without any of the compression
* extensions.
*
* Examples:
* - my_file.fq.gz returns "my_file.fq"
* - my_other_file.fastq returns "my_file.fastq"
*
* @param f Input file object.
* @param exts Possible compression extensions to trim.
* @return Filename without compression extension.
*/
def
getUncompressedFileName
(
f
:
File
,
exts
:
Set
[
String
]
=
zipExtensions
)
:
String
=
exts
.
foldLeft
(
f
.
getName
)
{
(
fname
,
ext
)
=>
if
(
fname
.
toLowerCase
.
endsWith
(
ext
))
fname
.
dropRight
(
ext
.
length
)
else
fname
}
}
public/flexiprep/src/main/scala/nl/lumc/sasc/biopet/pipelines/flexiprep/Flexiprep.scala
View file @
954e0245
...
...
@@ -19,6 +19,7 @@ import nl.lumc.sasc.biopet.core.summary.SummaryQScript
import
nl.lumc.sasc.biopet.core.
{
BiopetFifoPipe
,
PipelineCommand
,
SampleLibraryTag
}
import
nl.lumc.sasc.biopet.extensions.
{
Zcat
,
Gzip
}
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.utils.IoUtils._
import
nl.lumc.sasc.biopet.extensions.tools.
{
SeqStat
,
FastqSync
}
import
org.broadinstitute.gatk.queue.QScript
...
...
@@ -54,8 +55,6 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
def
summarySettings
=
Map
(
"skip_trim"
->
skipTrim
,
"skip_clip"
->
skipClip
,
"paired"
->
paired
)
var
paired
:
Boolean
=
input_R2
.
isDefined
var
R1_ext
:
String
=
_
var
R2_ext
:
String
=
_
var
R1_name
:
String
=
_
var
R2_name
:
String
=
_
...
...
@@ -74,27 +73,6 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
Some
(
flexiprepReport
)
}
/** Possible compression extensions to trim from input files. */
private
val
zipExtensions
=
Set
(
".gz"
,
".gzip"
)
/**
* Given a file object and a set of compression extensions, return the filename without any of the compression
* extensions.
*
* Examples:
* - my_file.fq.gz returns "my_file.fq"
* - my_other_file.fastq returns "my_file.fastq"
*
* @param f Input file object.
* @param exts Possible compression extensions to trim.
* @return Filename without compression extension.
*/
private
def
getUncompressedName
(
f
:
File
,
exts
:
Set
[
String
]
=
zipExtensions
)
:
String
=
exts
.
foldLeft
(
f
.
toString
)
{
case
(
fname
,
ext
)
=>
if
(
fname
.
toLowerCase
.
endsWith
(
ext
))
fname
.
dropRight
(
ext
.
length
)
else
fname
}
/** Function that's need to be executed before the script is accessed */
def
init
()
{
require
(
outputDir
!=
null
,
"Missing output directory on flexiprep module"
)
...
...
@@ -107,10 +85,10 @@ class Flexiprep(val root: Configurable) extends QScript with SummaryQScript with
inputFiles
:+=
new
InputFile
(
input_R1
)
input_R2
.
foreach
(
inputFiles
:+=
new
InputFile
(
_
))
R1_name
=
getUncompressedName
(
input_R1
)
R1_name
=
getUncompressed
File
Name
(
input_R1
)
input_R2
.
foreach
{
fileR2
=>
paired
=
true
R2_name
=
getUncompressedName
(
fileR2
)
paired
=
true
R2_name
=
getUncompressed
File
Name
(
fileR2
)
}
}
...
...
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