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
50963363
Commit
50963363
authored
Apr 29, 2015
by
Peter van 't Hof
Browse files
Added summary value class
parent
ab81e99e
Changes
1
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/summary/SummaryValue.scala
0 → 100644
View file @
50963363
package
nl.lumc.sasc.biopet.core.summary
import
java.math.BigDecimal
/**
* Created by pjvan_thof on 4/23/15.
*/
case
class
SummaryValue
(
val
value
:
Option
[
Any
])
{
def
this
(
path
:
List
[
String
],
summary
:
Summary
,
sampleId
:
Option
[
String
]
=
None
,
libId
:
Option
[
String
]
=
None
)
=
{
this
((
sampleId
,
libId
)
match
{
case
(
Some
(
sample
),
Some
(
lib
))
=>
summary
.
getLibraryValue
(
sample
,
lib
,
path
:
_
*
)
case
(
Some
(
sample
),
_
)
=>
summary
.
getSampleValue
(
sample
,
path
:
_
*
)
case
_
=>
summary
.
getValue
(
path
:
_
*
)
})
}
def
+
(
that
:
SummaryValue
)
:
SummaryValue
=
{
(
this
.
value
,
that
.
value
)
match
{
case
(
Some
(
a
:
Double
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
+
b
.
toString
.
toDouble
))
case
(
Some
(
a
:
Int
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
+
b
.
toString
.
toInt
))
case
(
Some
(
a
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
.
toString
.
toDouble
+
b
.
toString
.
toDouble
))
case
_
=>
SummaryValue
(
None
)
}
}
def
-
(
that
:
SummaryValue
)
:
SummaryValue
=
{
(
this
.
value
,
that
.
value
)
match
{
case
(
Some
(
a
:
Double
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
-
b
.
toString
.
toDouble
))
case
(
Some
(
a
:
Int
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
-
b
.
toString
.
toInt
))
case
(
Some
(
a
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
.
toString
.
toDouble
-
b
.
toString
.
toDouble
))
case
_
=>
SummaryValue
(
None
)
}
}
def
/
(
that
:
SummaryValue
)
:
SummaryValue
=
{
(
this
.
value
,
that
.
value
)
match
{
case
(
Some
(
a
:
Double
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
/
b
.
toString
.
toDouble
))
case
(
Some
(
a
:
Int
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
/
b
.
toString
.
toInt
))
case
(
Some
(
a
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
.
toString
.
toDouble
/
b
.
toString
.
toDouble
))
case
_
=>
SummaryValue
(
None
)
}
}
def
*
(
that
:
SummaryValue
)
:
SummaryValue
=
{
(
this
.
value
,
that
.
value
)
match
{
case
(
Some
(
a
:
Double
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
*
b
.
toString
.
toDouble
))
case
(
Some
(
a
:
Int
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
*
b
.
toString
.
toInt
))
case
(
Some
(
a
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
.
toString
.
toDouble
*
b
.
toString
.
toDouble
))
case
_
=>
SummaryValue
(
None
)
}
}
def
%
(
that
:
SummaryValue
)
:
SummaryValue
=
{
(
this
.
value
,
that
.
value
)
match
{
case
(
Some
(
a
:
Double
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
%
b
.
toString
.
toDouble
))
case
(
Some
(
a
:
Int
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
%
b
.
toString
.
toInt
))
case
(
Some
(
a
),
Some
(
b
))
=>
SummaryValue
(
Some
(
a
.
toString
.
toDouble
%
b
.
toString
.
toDouble
))
case
_
=>
SummaryValue
(
None
)
}
}
}
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