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
50d678ff
Commit
50d678ff
authored
Oct 12, 2016
by
Peter van 't Hof
Browse files
Added regex option
parent
2727f142
Changes
1
Hide whitespace changes
Inline
Side-by-side
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
View file @
50d678ff
...
...
@@ -6,6 +6,7 @@ import nl.lumc.sasc.biopet.utils.ToolCommand
import
scala.collection.mutable.ListBuffer
import
scala.io.Source
import
scala.util.matching.Regex
/**
* This tool will find all pairs above a cutoff in a data table
...
...
@@ -17,7 +18,9 @@ object FindOverlapMatch extends ToolCommand {
case
class
Args
(
inputMetrics
:
File
=
null
,
outputFile
:
Option
[
File
]
=
None
,
cutoff
:
Double
=
0.0
,
filterSameNames
:
Boolean
=
true
)
extends
AbstractArgs
filterSameNames
:
Boolean
=
true
,
rowSampleRegex
:
Option
[
Regex
]
=
None
,
columnSampleRegex
:
Option
[
Regex
]
=
None
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'i'
,
"input"
)
required
()
unbounded
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
...
...
@@ -32,7 +35,12 @@ object FindOverlapMatch extends ToolCommand {
opt
[
Unit
](
"use_same_names"
)
unbounded
()
valueName
"<value>"
action
{
(
x
,
c
)
=>
c
.
copy
(
filterSameNames
=
false
)
}
text
"Do not compare samples with the same name"
opt
[
String
](
"rowSampleRegex"
)
unbounded
()
valueName
"<regex>"
action
{
(
x
,
c
)
=>
c
.
copy
(
rowSampleRegex
=
Some
(
x
.
r
))
}
opt
[
String
](
"columnSampleRegex"
)
unbounded
()
valueName
"<regex>"
action
{
(
x
,
c
)
=>
c
.
copy
(
columnSampleRegex
=
Some
(
x
.
r
))
}
}
/**
...
...
@@ -58,9 +66,9 @@ object FindOverlapMatch extends ToolCommand {
case
_
=>
sys
.
process
.
stdout
}
for
(
i1
<-
samplesColumnHeader
)
{
for
(
i1
<-
samplesColumnHeader
if
cmdArgs
.
columnSampleRegex
.
map
(
_
.
findFirstIn
(
i1
.
_1
).
isDefined
).
getOrElse
(
true
)
)
{
val
buffer
=
ListBuffer
[(
String
,
Double
)]()
for
(
i2
<-
samplesRowHeader
)
{
for
(
i2
<-
samplesRowHeader
if
cmdArgs
.
rowSampleRegex
.
map
(
_
.
findFirstIn
(
i2
.
_1
).
isDefined
).
getOrElse
(
true
)
)
{
val
value
=
data
(
i1
.
_2
)(
i2
.
_2
).
toDouble
if
(
value
>=
cmdArgs
.
cutoff
&&
(!
cmdArgs
.
filterSameNames
||
i1
.
_2
!=
i2
.
_2
))
{
buffer
.+=((
i2
.
_1
,
value
))
...
...
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