Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
biopet.biopet
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Mirrors
biopet.biopet
Commits
8a1ead0e
Commit
8a1ead0e
authored
Sep 27, 2016
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit testing
parent
5badc583
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
2 deletions
+54
-2
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
...in/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
+9
-2
biopet-tools/src/test/resources/overlapmetrics.txt
biopet-tools/src/test/resources/overlapmetrics.txt
+4
-0
biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatchTest.scala
...cala/nl/lumc/sasc/biopet/tools/FindOverlapMatchTest.scala
+41
-0
No files found.
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
View file @
8a1ead0e
...
...
@@ -8,13 +8,16 @@ import scala.collection.mutable.ListBuffer
import
scala.io.Source
/**
* This tool will find all pairs above a cutoff in a data table
*
* Created by pjvan_thof on 21-9-16.
*/
object
FindOverlapMatch
extends
ToolCommand
{
case
class
Args
(
inputMetrics
:
File
=
null
,
outputFile
:
Option
[
File
]
=
None
,
cutoff
:
Double
=
0.0
)
extends
AbstractArgs
cutoff
:
Double
=
0.0
,
filterSameNames
:
Boolean
=
true
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'i'
,
"input"
)
required
()
unbounded
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
...
...
@@ -26,6 +29,10 @@ object FindOverlapMatch extends ToolCommand {
opt
[
Double
](
'c'
,
"cutoff"
)
required
()
unbounded
()
valueName
"<value>"
action
{
(
x
,
c
)
=>
c
.
copy
(
cutoff
=
x
)
}
text
"minimum value to report it as pair"
opt
[
Unit
](
"use_same_names"
)
unbounded
()
valueName
"<value>"
action
{
(
x
,
c
)
=>
c
.
copy
(
filterSameNames
=
false
)
}
text
"Do not compare samples with the same name"
}
/**
...
...
@@ -55,7 +62,7 @@ object FindOverlapMatch extends ToolCommand {
val
buffer
=
ListBuffer
[(
String
,
Double
)]()
for
(
i2
<-
samplesRowHeader
)
{
val
value
=
data
(
i1
.
_2
)(
i2
.
_2
).
toDouble
if
(
value
>=
cmdArgs
.
cutoff
&&
i1
.
_2
!=
i2
.
_2
)
{
if
(
value
>=
cmdArgs
.
cutoff
&&
(!
cmdArgs
.
filterSameNames
||
i1
.
_2
!=
i2
.
_2
)
)
{
buffer
.+=((
i2
.
_1
,
value
))
}
}
...
...
biopet-tools/src/test/resources/overlapmetrics.txt
0 → 100644
View file @
8a1ead0e
sample1 sample2 sample3
sample1 1.0 0.5 0.9
sample2 0.5 1.0 0.5
sample3 0.9 0.5 1.0
biopet-tools/src/test/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatchTest.scala
0 → 100644
View file @
8a1ead0e
package
nl.lumc.sasc.biopet.tools
import
java.io.File
import
java.nio.file.Paths
import
org.scalatest.Matchers
import
org.scalatest.testng.TestNGSuite
import
org.testng.annotations.Test
import
scala.io.Source
/**
* Created by pjvan_thof on 27-9-16.
*/
class
FindOverlapMatchTest
extends
TestNGSuite
with
Matchers
{
private
def
resourcePath
(
p
:
String
)
:
String
=
{
Paths
.
get
(
getClass
.
getResource
(
p
).
toURI
).
toString
}
@Test
def
testOverlap
:
Unit
=
{
val
input
=
new
File
(
resourcePath
(
"/overlapmetrics.txt"
))
val
output
=
File
.
createTempFile
(
"overlap."
,
".txt"
)
val
shouldBeOutput
=
new
File
(
resourcePath
(
"/overlapmetrics.default.output"
))
output
.
deleteOnExit
()
FindOverlapMatch
.
main
(
Array
(
"-i"
,
input
.
getAbsolutePath
,
"-c"
,
"0.9"
,
"-o"
,
output
.
getAbsolutePath
))
Source
.
fromFile
(
output
).
getLines
().
toList
shouldBe
Source
.
fromFile
(
shouldBeOutput
).
getLines
().
toList
}
@Test
def
testOverlapSameName
:
Unit
=
{
val
input
=
new
File
(
resourcePath
(
"/overlapmetrics.txt"
))
val
output
=
File
.
createTempFile
(
"overlap."
,
".txt"
)
val
shouldBeOutput
=
new
File
(
resourcePath
(
"/overlapmetrics.same_names.output"
))
output
.
deleteOnExit
()
FindOverlapMatch
.
main
(
Array
(
"-i"
,
input
.
getAbsolutePath
,
"-c"
,
"0.9"
,
"-o"
,
output
.
getAbsolutePath
,
"--use_same_names"
))
Source
.
fromFile
(
output
).
getLines
().
toList
shouldBe
Source
.
fromFile
(
shouldBeOutput
).
getLines
().
toList
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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