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
7eb9af74
Commit
7eb9af74
authored
May 17, 2016
by
bow
Browse files
Merge branch 'feature-bed_check' into 'develop'
Init bed check fixes #298 See merge request !401
parents
09fa0b3f
d08b6c72
Changes
3
Hide whitespace changes
Inline
Side-by-side
bammetrics/src/main/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetrics.scala
View file @
7eb9af74
...
...
@@ -17,15 +17,16 @@ package nl.lumc.sasc.biopet.pipelines.bammetrics
import
java.io.File
import
nl.lumc.sasc.biopet.core.annotations.
{
RibosomalRefFlat
,
Annotation
RefFlat
}
import
nl.lumc.sasc.biopet.core.annotations.
{
AnnotationRefFlat
,
Ribosomal
RefFlat
}
import
nl.lumc.sasc.biopet.utils.config.Configurable
import
nl.lumc.sasc.biopet.core.summary.SummaryQScript
import
nl.lumc.sasc.biopet.core.
{
Reference
,
BiopetFifoPipe
,
PipelineCommand
,
SampleLibraryTag
}
import
nl.lumc.sasc.biopet.core.
{
BiopetFifoPipe
,
PipelineCommand
,
Reference
,
SampleLibraryTag
}
import
nl.lumc.sasc.biopet.extensions.bedtools.
{
BedtoolsCoverage
,
BedtoolsIntersect
}
import
nl.lumc.sasc.biopet.extensions.picard._
import
nl.lumc.sasc.biopet.extensions.samtools.SamtoolsFlagstat
import
nl.lumc.sasc.biopet.pipelines.bammetrics.scripts.CoverageStats
import
nl.lumc.sasc.biopet.extensions.tools.BiopetFlagstat
import
nl.lumc.sasc.biopet.utils.intervals.BedCheck
import
org.broadinstitute.gatk.queue.QScript
class
BamMetrics
(
val
root
:
Configurable
)
extends
QScript
...
...
@@ -72,6 +73,8 @@ class BamMetrics(val root: Configurable) extends QScript
/** executed before script */
def
init
()
:
Unit
=
{
inputFiles
:+=
new
InputFile
(
inputBam
)
ampliconBedFile
.
foreach
(
BedCheck
.
checkBedFileToReference
(
_
,
referenceFasta
(),
biopetError
=
true
))
roiBedFiles
.
foreach
(
BedCheck
.
checkBedFileToReference
(
_
,
referenceFasta
(),
biopetError
=
true
))
}
/** Script to add jobs */
...
...
bammetrics/src/test/scala/nl/lumc/sasc/biopet/pipelines/bammetrics/BamMetricsTest.scala
View file @
7eb9af74
...
...
@@ -61,9 +61,9 @@ class BamMetricsTest extends TestNGSuite with Matchers {
def
testBamMetrics
(
rois
:
Int
,
amplicon
:
Boolean
,
rna
:
Boolean
,
wgs
:
Boolean
)
=
{
val
map
=
ConfigUtils
.
mergeMaps
(
Map
(
"output_dir"
->
BamMetricsTest
.
outputDir
,
"rna_metrics"
->
rna
,
"wgs_metrics"
->
wgs
),
Map
(
BamMetricsTest
.
executables
.
toSeq
:
_
*
))
++
(
if
(
amplicon
)
Map
(
"amplicon_bed"
->
"amplicon.bed"
)
else
Map
())
++
(
if
(
amplicon
)
Map
(
"amplicon_bed"
->
BamMetricsTest
.
ampliconBed
.
getAbsolutePath
)
else
Map
())
++
(
if
(
rna
)
Map
(
"annotation_refflat"
->
"transcripts.refFlat"
)
else
Map
())
++
Map
(
"regions_of_interest"
->
(
1
to
rois
).
map
(
"roi_"
+
_
+
".bed"
).
toList
)
Map
(
"regions_of_interest"
->
(
1
to
rois
).
map
(
BamMetricsTest
.
roi
(
_
).
getAbsolutePath
).
toList
)
val
bammetrics
:
BamMetrics
=
initPipeline
(
map
)
bammetrics
.
inputBam
=
BamMetricsTest
.
bam
...
...
@@ -94,6 +94,14 @@ object BamMetricsTest {
val
bam
=
new
File
(
outputDir
,
"input"
+
File
.
separator
+
"bla.bam"
)
Files
.
touch
(
bam
)
val
ampliconBed
=
new
File
(
outputDir
,
"input"
+
File
.
separator
+
"amplicon_bed.bed"
)
Files
.
touch
(
ampliconBed
)
def
roi
(
i
:
Int
)
:
File
=
{
val
roi
=
new
File
(
outputDir
,
"input"
+
File
.
separator
+
s
"roi${i}.bed"
)
Files
.
touch
(
roi
)
roi
}
private
def
copyFile
(
name
:
String
)
:
Unit
=
{
val
is
=
getClass
.
getResourceAsStream
(
"/"
+
name
)
...
...
biopet-utils/src/main/scala/nl/lumc/sasc/biopet/utils/intervals/BedCheck.scala
0 → 100644
View file @
7eb9af74
package
nl.lumc.sasc.biopet.utils.intervals
import
java.io.File
import
scala.collection.mutable.Set
import
nl.lumc.sasc.biopet.utils.Logging
/**
* Created by pjvanthof on 14/05/16.
*/
object
BedCheck
{
private
val
cache
:
Set
[(
File
,
File
)]
=
Set
()
def
checkBedFileToReference
(
bedFile
:
File
,
reference
:
File
,
biopetError
:
Boolean
=
false
,
ignoreCache
:
Boolean
=
false
)
:
Unit
=
{
if
(
ignoreCache
||
!
cache
.
contains
((
bedFile
,
reference
)))
{
cache
.
add
((
bedFile
,
reference
))
val
bedrecords
=
BedRecordList
.
fromFile
(
bedFile
)
if
(
biopetError
)
{
try
{
bedrecords
.
validateContigs
(
reference
)
}
catch
{
case
e
:
IllegalArgumentException
=>
Logging
.
addError
(
e
.
getMessage
+
s
", Bedfile: $bedFile"
)
}
}
else
bedrecords
.
validateContigs
(
reference
)
}
}
}
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