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
5badc583
Commit
5badc583
authored
Sep 27, 2016
by
Peter van 't Hof
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added output file
parent
4ec46159
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
+23
-12
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
...in/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
+23
-12
No files found.
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
View file @
5badc583
package
nl.lumc.sasc.biopet.tools
import
java.io.
File
import
java.io.
{
File
,
PrintStream
,
PrintWriter
}
import
nl.lumc.sasc.biopet.utils.ToolCommand
...
...
@@ -12,16 +12,20 @@ import scala.io.Source
*/
object
FindOverlapMatch
extends
ToolCommand
{
case
class
Args
(
inputVcf
:
File
=
null
,
case
class
Args
(
inputMetrics
:
File
=
null
,
outputFile
:
Option
[
File
]
=
None
,
cutoff
:
Double
=
0.0
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
'i'
,
"input"
)
required
()
unbounded
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
inputVcf
=
x
)
}
c
.
copy
(
inputMetrics
=
x
)
}
text
"Input should be a table where the first row and column have the ID's, those can be different"
opt
[
File
](
'o'
,
"output"
)
unbounded
()
valueName
"<file>"
action
{
(
x
,
c
)
=>
c
.
copy
(
outputFile
=
Some
(
x
))
}
text
"default to stdout"
opt
[
Double
](
'c'
,
"cutoff"
)
required
()
unbounded
()
valueName
"<value>"
action
{
(
x
,
c
)
=>
c
.
copy
(
cutoff
=
x
)
}
}
text
"minimum value to report it as pair"
}
/**
...
...
@@ -29,23 +33,29 @@ object FindOverlapMatch extends ToolCommand {
*/
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
val
argsParser
=
new
OptParser
val
cmd
a
rgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
(
throw
new
IllegalArgumentException
)
val
cmd
A
rgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
(
throw
new
IllegalArgumentException
)
val
reader
=
Source
.
fromFile
(
cmd
args
.
inputVcf
)
val
reader
=
Source
.
fromFile
(
cmd
Args
.
inputMetrics
)
val
data
=
reader
.
getLines
().
map
(
_
.
split
(
"\t"
)).
toArray
val
samples
=
data
.
head
.
zipWithIndex
.
tail
val
samplesColumnHeader
=
data
.
head
.
zipWithIndex
.
tail
val
samplesRowHeader
=
data
.
map
(
_
.
head
).
zipWithIndex
.
tail
var
overlap
=
0
var
multiOverlap
=
0
var
noOverlap
=
0
for
(
i1
<-
samples
)
{
val
writer
=
cmdArgs
.
outputFile
match
{
case
Some
(
file
)
=>
new
PrintStream
(
file
)
case
_
=>
sys
.
process
.
stdout
}
for
(
i1
<-
samplesColumnHeader
)
{
val
buffer
=
ListBuffer
[(
String
,
Double
)]()
for
(
i2
<-
samples
)
{
for
(
i2
<-
samples
RowHeader
)
{
val
value
=
data
(
i1
.
_2
)(
i2
.
_2
).
toDouble
if
(
value
>=
cmd
a
rgs
.
cutoff
&&
i1
.
_2
!=
i2
.
_2
)
{
if
(
value
>=
cmd
A
rgs
.
cutoff
&&
i1
.
_2
!=
i2
.
_2
)
{
buffer
.+=((
i2
.
_1
,
value
))
}
}
...
...
@@ -53,10 +63,11 @@ object FindOverlapMatch extends ToolCommand {
else
noOverlap
+=
1
if
(
buffer
.
size
>
1
)
multiOverlap
+=
1
println
(
s
"${i1._1}\t${buffer.mkString("
\
t
")}"
)
writer
.
println
(
s
"${i1._1}\t${buffer.mkString("
\
t
")}"
)
}
logger
.
info
(
s
"$overlap found"
)
logger
.
info
(
s
"no $noOverlap found"
)
logger
.
info
(
s
"multi $multiOverlap found"
)
writer
.
close
()
}
}
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