clipping.ssp 3.96 KB
Newer Older
Peter van 't Hof's avatar
Peter van 't Hof committed
1
#import(nl.lumc.sasc.biopet.utils.summary.db.SummaryDb)
2
#import(nl.lumc.sasc.biopet.core.report.ReportPage)
Peter van 't Hof's avatar
Peter van 't Hof committed
3
4
#import(scala.concurrent.Await)
#import(scala.concurrent.duration.Duration)
5
6
#import(nl.lumc.sasc.biopet.pipelines.bammetrics.BammetricsReport)
#import(java.io.File)
Peter van 't Hof's avatar
Peter van 't Hof committed
7
8
#import(scalaz._)
#import(Scalaz._)
Peter van 't Hof's avatar
Peter van 't Hof committed
9
10
11
<%@ var summary: SummaryDb %>
<%@ var sampleId: Option[Int] = None %>
<%@ var libId: Option[Int] = None %>
12
<%@ var sampleLevel: Boolean = false %>
Peter van 't Hof's avatar
Peter van 't Hof committed
13
<%@ var rootPath: String %>
14
15
16
17
<%@ var outputDir: File %>
<%@ var showPlot: Boolean = false %>
<%@ var showTable: Boolean = true %>
<%@ var showIntro: Boolean = true%>
Peter van 't Hof's avatar
Peter van 't Hof committed
18
19
<%@ var runId: Int %>
<%@ var fields: List[String] = List("min", "max", "mean", "median", "modal")%>
20
#{
Peter van 't Hof's avatar
Peter van 't Hof committed
21
    val samples = Await.result(summary.getSamples(runId = Some(runId)), Duration.Inf)
22
23
24
25
26
27
28
29
30
}#

#if (showIntro)
    <br/>
    <div class="row">
    <div class="col-md-1"></div>
    <div class="col-md-6">
        <p>
        #if (sampleId.isDefined && libId.isDefined)
Peter van 't Hof's avatar
Peter van 't Hof committed
31
            This plot shows the clipping distribution for library <b>${libId}</b> of sample <b>${sampleId}</b>.
32
33
34
35
36
37
38
39
40
41
42
        #elseif(sampleId.isDefined)
            This plot shows the clipping distribution for the libraries of sample <b>${sampleId}</b>.
        #else
            This plot shows the clipping distribution for each of the <b>${samples.size}</b> samples.
        #end
        </p>
    </div>
    </div>
#end

#if (showPlot)
Peter van 't Hof's avatar
Peter van 't Hof committed
43
    #{ BammetricsReport.clippingPlot(outputDir, "clipping", summary, !sampleLevel, sampleId = sampleId, libraryId = libId) }#
44
45
46
47
48
49
50
51
52
53
54
55

    <div class="panel-body">
    <img src="clipping.png" class="img-responsive" />
    </div>
    <div class="panel-footer">
        #if (showTable)
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#clippingTable">
                <i class="glyphicon glyphicon-eye-close"></i> Hide table</button>
        #else
            <button type="button" class="btn btn-info" data-toggle="collapse" data-target="#clippingTable">
            <i class="glyphicon glyphicon-eye-open"></i> Show table</button>
        #end
Peter van 't Hof's avatar
Peter van 't Hof committed
56
      <a href="clipping.tsv"><button type="button" class="btn btn-info"><i class="glyphicon glyphicon-cloud-download"></i>TSV file</button></a>
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71

    </div>
#end

<div class="panel-body collapse #if (showTable)in#end" id="clippingTable">
<!-- Table -->
<table class="table">
    <thead><tr>
        <th data-sorted="true" data-sorted-direction="ascending">Sample</th>
        #if (!sampleLevel) <th>Library</th> #end
        #for (field <- fields)
            <th>${field.replaceAll("_", " ")}</th>
        #end
    </tr></thead>
    <tbody>
Peter van 't Hof's avatar
Peter van 't Hof committed
72
        #for (sample <- samples.sortBy(_.name))
73
            #{
Peter van 't Hof's avatar
Peter van 't Hof committed
74
75
76
77
                val libs: List[Option[Int]] = (libId, sampleLevel) match {
                case (_, true) => List(None)
                case (Some(_), _) => List(libId)
                case _ => Await.result(summary.getLibraries(sampleId = Some(sample.id), runId = Some(runId)), Duration.Inf).map(x => Some(x.id)).toList
78
79
                }
            }#
80
            <tr><td rowspan="${libs.size}"><a href="${rootPath}Samples/${sample.name}/index.html">${sample.name}</a></td>
81
            #for (libId <- libs)
82
                #{ val libName = libId.map(l => Await.result(summary.getLibraryName(l), Duration.Inf)) }#
83
                #if (libs.head != libId) <tr> #end
84
                    #if (!sampleLevel) <td><a href="${rootPath}Samples/${sample.name}/Libraries/${libName}/index.html">${libName}</a></td> #end
85
                    #{
Peter van 't Hof's avatar
Peter van 't Hof committed
86
                        val statsPaths = fields.map(x => x -> List("clipping", "general", x)).toMap
Peter van 't Hof's avatar
Peter van 't Hof committed
87
                        val results = summary.getStatKeys(runId, "bammetrics".right, Some("bamstats".right), sample = Some(sample.id.left), library = libId.map(_.left), keyValues = statsPaths)
88
                    }#
Peter van 't Hof's avatar
Peter van 't Hof committed
89
90
                    #for (field <- fields)
                        <td>${results(field)}</td>
91
92
93
94
95
96
97
98
                    #end
                </tr>
            #end
        #end
    </tbody>
</table>

</div>