Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
biopet.biopet
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mirrors
biopet.biopet
Commits
5badc583
Commit
5badc583
authored
8 years ago
by
Peter van 't Hof
Browse files
Options
Downloads
Patches
Plain Diff
Added output file
parent
4ec46159
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
+23
-12
23 additions, 12 deletions
...in/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
with
23 additions
and
12 deletions
biopet-tools/src/main/scala/nl/lumc/sasc/biopet/tools/FindOverlapMatch.scala
+
23
−
12
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
a
rgs
.
input
Vcf
)
val
reader
=
Source
.
fromFile
(
cmd
A
rgs
.
input
Metrics
)
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
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment