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
0bc37c76
Commit
0bc37c76
authored
Mar 30, 2015
by
Peter van 't Hof
Browse files
Init version of report module
parent
aa506e53
Changes
5
Hide whitespace changes
Inline
Side-by-side
public/biopet-framework/src/main/resources/nl/lumc/sasc/biopet/core/report/biopet.css
0 → 100644
View file @
0bc37c76
header
{
background-color
:
black
;
color
:
white
;
text-align
:
center
;
padding
:
5px
;
}
nav
{
line-height
:
30px
;
background-color
:
#eeeeee
;
width
:
100%
;
padding
:
5px
;
}
nav
ul
ul
{
display
:
none
;
}
nav
ul
li
:hover
>
ul
{
display
:
block
;
}
nav
ul
{
background
:
#efefef
;
background
:
linear-gradient
(
top
,
#efefef
0%
,
#bbbbbb
100%
);
background
:
-moz-linear-gradient
(
top
,
#efefef
0%
,
#bbbbbb
100%
);
background
:
-webkit-linear-gradient
(
top
,
#efefef
0%
,
#bbbbbb
100%
);
box-shadow
:
0px
0px
9px
rgba
(
0
,
0
,
0
,
0.15
);
padding
:
0
20px
;
border-radius
:
10px
;
list-style
:
none
;
position
:
relative
;
display
:
inline-table
;
}
nav
ul
:after
{
content
:
""
;
clear
:
both
;
display
:
block
;
}
nav
ul
li
{
float
:
left
;
}
nav
ul
li
:hover
{
background
:
#4b545f
;
background
:
linear-gradient
(
top
,
#4f5964
0%
,
#5f6975
40%
);
background
:
-moz-linear-gradient
(
top
,
#4f5964
0%
,
#5f6975
40%
);
background
:
-webkit-linear-gradient
(
top
,
#4f5964
0%
,
#5f6975
40%
);
}
nav
ul
li
:hover
a
{
color
:
#fff
;
}
nav
ul
li
a
{
display
:
block
;
padding
:
25px
40px
;
color
:
#757575
;
text-decoration
:
none
;
}
nav
ul
ul
{
background
:
#5f6975
;
border-radius
:
0px
;
padding
:
0
;
position
:
absolute
;
top
:
100%
;
}
nav
ul
ul
li
{
float
:
none
;
border-top
:
1px
solid
#6b727c
;
border-bottom
:
1px
solid
#575f6a
;
position
:
relative
;
}
nav
ul
ul
li
a
{
padding
:
15px
40px
;
color
:
#fff
;
}
nav
ul
ul
li
a
:hover
{
background
:
#4b545f
;
}
nav
ul
ul
ul
{
position
:
absolute
;
left
:
100%
;
top
:
0
;
}
section
{
width
:
350px
;
float
:
left
;
padding
:
10px
;
}
footer
{
background-color
:
black
;
color
:
white
;
clear
:
both
;
text-align
:
center
;
padding
:
5px
;
}
table
,
td
,
th
{
border
:
1px
solid
green
;
border-collapse
:
collapse
;
}
th
{
background-color
:
green
;
border
:
1px
solid
white
;
color
:
white
;
}
\ No newline at end of file
public/biopet-framework/src/main/resources/nl/lumc/sasc/biopet/core/report/main.ssp
0 → 100644
View file @
0bc37c76
#import(nl.lumc.sasc.biopet.core.summary.Summary)
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
<
%@
var
summary:
Summary
%
>
<
%@
var
indexPage:
ReportPage
%
>
<
%@
var
reportName:
String
%
>
<
%@
var
page:
ReportPage
%
>
<
%@
var
path:
List
[
String
]
%
>
<
%@
var
args:
Map
[
String
,
Any
]
%
>
#{
val rootPath = "./" + Array.fill(path.size)("../").mkString("")
def createMenu(page: ReportPage, path: List[String] = Nil): String = {
val buffer: StringBuffer = new StringBuffer()
buffer.append("
<ul>
")
for (subPage
<-
page.subPages
)
{
val
href:
String =
{
if
(
path.isEmpty
)
rootPath
+
subPage._1
+
"/
index.html
"
else
rootPath
+
path.mkString
("","/","/")
+
subPage._1
+
"/
index.html
"
}
buffer.append
("<
li
><a
href=
\""
+
href
+
"\"
>
" + subPage._1 + "
</a>
")
buffer.append(createMenu(subPage._2, path ::: subPage._1 :: Nil))
buffer.append("
</li>
")
}
buffer.append("
</ul>
")
buffer.toString
}
def getSubPage(path:List[String]): ReportPage = {
path.foldLeft(indexPage)(_.subPages(_))
}
}#
<!DOCTYPE html>
<html>
<head>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"${rootPath}css/biopet.css"
>
</head>
<body>
<header><h1>
${reportName}
</h1></header>
<nav>
<ul>
#for (t
<-
0
to
path.size
)
<
li
>
#if (t == 0)
<a
href=
"${rootPath}index.html"
>
Home
</a>
${unescape(createMenu(indexPage))}
#else
<a
href=
"${rootPath}${path.slice(0, t).mkString("
","/","/")}
index.html
"
>
${path(t - 1)}
</a>
${unescape(createMenu(getSubPage(path.slice(0, t)), path.slice(0, t)))}
#end
</li>
#end
</ul>
</nav>
#for ((name, url)
<-
page.sections
)
<
section
id=
"${name}"
>
${name}
</section>
#end
<footer>
Footer
</footer>
</body>
</html>
\ No newline at end of file
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/report/MultisampleReportBuilder.scala
0 → 100644
View file @
0bc37c76
package
nl.lumc.sasc.biopet.core.report
import
nl.lumc.sasc.biopet.core.summary.Summary
/**
* Created by pjvan_thof on 3/30/15.
*/
trait
MultisampleReportBuilder
extends
ReportBuilder
{
def
generalPage
:
ReportPage
def
samplePage
(
sampleId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
def
libraryPage
(
libraryId
:
String
,
args
:
Map
[
String
,
Any
])
:
ReportPage
def
generateSamplesPage
(
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
samplePages
=
summary
.
samples
.
map
(
sampleId
=>
(
sampleId
->
samplePage
(
sampleId
,
args
++
Map
(
"sampleId"
->
Some
(
sampleId
)))))
.
toMap
ReportPage
(
samplePages
,
Map
(),
args
)
}
def
generateLibraryPage
(
args
:
Map
[
String
,
Any
])
:
ReportPage
=
{
val
libPages
=
summary
.
libraries
(
args
(
"sampleId"
)
match
{
case
Some
(
x
)
=>
x
.
toString
case
None
=>
throw
new
IllegalStateException
(
"Sample not found"
)
})
.
map
(
libId
=>
(
libId
->
libraryPage
(
libId
,
args
++
Map
(
"libId"
->
Some
(
libId
)))))
.
toMap
ReportPage
(
libPages
,
Map
(),
args
)
}
def
indexPage
=
ReportPage
(
Map
(
"General"
->
generalPage
,
"Samples"
->
generateSamplesPage
(
pageArgs
)),
Map
(),
pageArgs
)
}
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportBuilder.scala
0 → 100644
View file @
0bc37c76
package
nl.lumc.sasc.biopet.core.report
import
java.io.
{
PrintWriter
,
File
}
import
nl.lumc.sasc.biopet.core.ToolCommand
import
nl.lumc.sasc.biopet.core.summary.Summary
import
org.fusesource.scalate.
{
TemplateSource
,
TemplateEngine
}
import
scala.io.Source
/**
* Created by pjvan_thof on 3/27/15.
*/
trait
ReportBuilder
extends
ToolCommand
{
case
class
Args
(
summary
:
File
=
null
,
outputDir
:
File
=
null
)
extends
AbstractArgs
class
OptParser
extends
AbstractOptParser
{
opt
[
File
](
's'
,
"summary"
)
required
()
maxOccurs
(
1
)
valueName
(
"<file>"
)
action
{
(
x
,
c
)
=>
c
.
copy
(
summary
=
x
)
}
opt
[
File
](
'o'
,
"outputDir"
)
required
()
maxOccurs
(
1
)
valueName
(
"<file>"
)
action
{
(
x
,
c
)
=>
c
.
copy
(
outputDir
=
x
)
}
}
private
var
setSummary
:
Summary
=
_
final
def
summary
=
setSummary
def
pageArgs
:
Map
[
String
,
Any
]
=
Map
()
def
main
(
args
:
Array
[
String
])
:
Unit
=
{
logger
.
info
(
"Start"
)
val
argsParser
=
new
OptParser
val
cmdArgs
:
Args
=
argsParser
.
parse
(
args
,
Args
())
getOrElse
sys
.
exit
(
1
)
require
(
cmdArgs
.
outputDir
.
exists
(),
"Output dir does not exist"
)
require
(
cmdArgs
.
outputDir
.
isDirectory
,
"Output dir is not a directory"
)
// Write css to output dir
val
cssDir
=
new
File
(
cmdArgs
.
outputDir
,
"css"
)
cssDir
.
mkdirs
()
val
cssWriter
=
new
PrintWriter
(
new
File
(
cssDir
,
"biopet.css"
))
Source
.
fromInputStream
(
getClass
.
getResourceAsStream
(
"biopet.css"
)).
getLines
().
foreach
(
cssWriter
.
println
(
_
))
cssWriter
.
close
()
setSummary
=
new
Summary
(
cmdArgs
.
summary
)
generatePage
(
summary
,
indexPage
,
cmdArgs
.
outputDir
,
args
=
pageArgs
++
Map
(
"summary"
->
summary
,
"reportName"
->
reportName
,
"indexPage"
->
indexPage
))
logger
.
info
(
"Done"
)
}
protected
val
engine
=
new
TemplateEngine
()
def
indexPage
:
ReportPage
def
reportName
:
String
def
generatePage
(
summary
:
Summary
,
page
:
ReportPage
,
outputDir
:
File
,
path
:
List
[
String
]
=
Nil
,
args
:
Map
[
String
,
Any
]
=
Map
())
:
Unit
=
{
val
templateText
=
Source
.
fromInputStream
(
getClass
.
getResourceAsStream
(
"main.ssp"
)).
getLines
().
mkString
(
"\n"
)
val
template
=
engine
.
compileText
(
"ssp"
,
templateText
)
val
pageArgs
=
args
++
page
.
args
++
Map
(
"page"
->
page
,
"path"
->
path
)
val
output
=
engine
.
layout
(
template
.
source
,
pageArgs
++
Map
(
"args"
->
pageArgs
))
val
file
=
new
File
(
outputDir
,
path
.
mkString
(
""
,
File
.
separator
,
File
.
separator
)
+
"index.html"
)
file
.
getParentFile
.
mkdirs
()
val
writer
=
new
PrintWriter
(
file
)
writer
.
println
(
output
)
writer
.
close
()
// Generating subpages
for
((
name
,
subPage
)
<-
page
.
subPages
)
{
generatePage
(
summary
,
subPage
,
outputDir
,
path
:::
name
::
Nil
,
pageArgs
)
}
}
}
public/biopet-framework/src/main/scala/nl/lumc/sasc/biopet/core/report/ReportPage.scala
0 → 100644
View file @
0bc37c76
package
nl.lumc.sasc.biopet.core.report
import
java.net.URL
/**
* Created by pjvan_thof on 3/27/15.
*/
case
class
ReportPage
(
val
subPages
:
Map
[
String
,
ReportPage
],
val
sections
:
Map
[
String
,
URL
],
val
args
:
Map
[
String
,
Any
])
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