Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror of Picard metrics documentation generation changes. #7749

Merged
merged 8 commits into from
Mar 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package org.broadinstitute.hellbender.metrics;

import htsjdk.samtools.SamPairUtil.PairOrientation;
import org.broadinstitute.hellbender.metrics.MultiLevelMetrics;
import org.broadinstitute.barclay.help.DocumentedFeature;
import picard.util.help.HelpConstants;

import java.io.Serializable;

Expand All @@ -11,6 +12,7 @@
* ".insertSizeMetrics". In addition the insert size distribution is plotted to
* a file with the extension ".insertSizeMetrics.pdf".
*/
@DocumentedFeature(groupName = HelpConstants.DOC_CAT_METRICS, summary = HelpConstants.DOC_CAT_METRICS_SUMMARY)
public final class InsertSizeMetrics extends MultiLevelMetrics implements Serializable {

private static final long serialVersionUID = 1L;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package org.broadinstitute.hellbender.metrics;

import htsjdk.samtools.metrics.MetricBase;
import org.broadinstitute.barclay.help.DocumentedFeature;
import org.broadinstitute.hellbender.utils.Utils;
import org.broadinstitute.hellbender.utils.read.GATKRead;
import org.broadinstitute.hellbender.utils.read.ReadUtils;
import picard.util.help.HelpConstants;

import java.io.Serializable;

/** A set of metrics used to describe the general quality of a BAM file */
@DocumentedFeature(groupName = HelpConstants.DOC_CAT_METRICS, summary = HelpConstants.DOC_CAT_METRICS_SUMMARY)
public final class QualityYieldMetrics extends MetricBase implements Serializable {
private static final long serialVersionUID = 1;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.broadinstitute.hellbender.metrics.analysis;

import htsjdk.samtools.metrics.MetricBase;
import org.broadinstitute.barclay.help.DocumentedFeature;
import picard.util.help.HelpConstants;

@DocumentedFeature(groupName = HelpConstants.DOC_CAT_METRICS, summary = HelpConstants.DOC_CAT_METRICS_SUMMARY)
public class AlleleFrequencyQCMetric extends MetricBase {

public String SAMPLE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package org.broadinstitute.hellbender.metrics.analysis;

import htsjdk.samtools.metrics.MetricBase;
import org.broadinstitute.barclay.help.DocumentedFeature;
import picard.util.help.HelpConstants;

@DocumentedFeature(groupName = HelpConstants.DOC_CAT_METRICS, summary = HelpConstants.DOC_CAT_METRICS_SUMMARY)
public final class BaseDistributionByCycleMetrics extends MetricBase {
public int READ_END;
public int CYCLE;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package org.broadinstitute.hellbender.tools.spark.pathseq.loggers;

import htsjdk.samtools.metrics.MetricBase;
import org.broadinstitute.barclay.help.DocumentedFeature;
import picard.util.help.HelpConstants;

/**
* Metrics that are calculated during the PathSeq filter
*/
@DocumentedFeature(groupName = HelpConstants.DOC_CAT_METRICS, summary = HelpConstants.DOC_CAT_METRICS_SUMMARY)
public final class PSFilterMetrics extends MetricBase {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.broadinstitute.hellbender.tools.spark.pathseq.loggers;

import htsjdk.samtools.metrics.MetricBase;
import org.broadinstitute.barclay.help.DocumentedFeature;
import picard.util.help.HelpConstants;

/**
* Metrics that are calculated during the PathSeq scoring
*/
@SuppressWarnings("serial")
@DocumentedFeature(groupName = HelpConstants.DOC_CAT_METRICS, summary = HelpConstants.DOC_CAT_METRICS_SUMMARY)
public final class PSScoreMetrics extends MetricBase {

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
package org.broadinstitute.hellbender.utils.help;

import htsjdk.samtools.metrics.MetricBase;
import org.broadinstitute.barclay.argparser.CommandLineProgramProperties;
import org.broadinstitute.barclay.help.DefaultDocWorkUnitHandler;
import org.broadinstitute.barclay.help.DocWorkUnit;
import org.broadinstitute.barclay.help.HelpDoclet;
import org.broadinstitute.barclay.help.scanners.JavaLanguageModelScanners;

import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
* The GATK Documentation work unit handler class that is the companion to GATKHelpDoclet.
Expand All @@ -17,6 +28,12 @@ public class GATKHelpDocWorkUnitHandler extends DefaultDocWorkUnitHandler {
private final static String GATK_JAVADOC_TAG_PREFIX = "GATK"; // prefix for custom javadoc tags used by GATK

private final static String GATK_FREEMARKER_TEMPLATE_NAME = "generic.template.html";
private final static String PICARD_METRICS_TEMPLATE_NAME = "metrics.template.html";

private final static String WORK_UNIT_SUMMARY_KEY = "summary";
private final static String METRICS_MAP_ENTRY_KEY = "metrics";
private final static String METRICS_MAP_NAME_KEY = "name";
private final static String METRICS_MAP_SUMMARY_KEY = "summary";

public GATKHelpDocWorkUnitHandler(final HelpDoclet doclet) {
super(doclet);
Expand All @@ -30,12 +47,19 @@ public GATKHelpDocWorkUnitHandler(final HelpDoclet doclet) {

/**
* @param workUnit the classdoc object being processed
* @return the name of a the freemarker template to be used for the class being documented.
* @return the name of the freemarker template to be used for the class being documented.
* Must reside in the folder passed to the Barclay Doclet via the "-settings-dir" parameter to
* Javadoc.
*/
@Override
public String getTemplateName(final DocWorkUnit workUnit) { return GATK_FREEMARKER_TEMPLATE_NAME; }
public String getTemplateName(final DocWorkUnit workUnit) {
Class<?> clazz = workUnit.getClazz();
if (MetricBase.class.isAssignableFrom(clazz)) {
return PICARD_METRICS_TEMPLATE_NAME;
} else {
return GATK_FREEMARKER_TEMPLATE_NAME;
}
}


/**
Expand All @@ -54,6 +78,28 @@ protected void addCustomBindings(final DocWorkUnit currentWorkUnit) {
if (picard.cmdline.CommandLineProgram.class.isAssignableFrom(toolClass)) {
final CommandLineProgramProperties clpProperties = currentWorkUnit.getCommandLineProperties();
currentWorkUnit.setProperty("picardsummary", clpProperties.summary());
} else if (MetricBase.class.isAssignableFrom(toolClass)) {
currentWorkUnit.setProperty(WORK_UNIT_SUMMARY_KEY, currentWorkUnit.getSummary());
final List<Map<String, String>> workUnitMetricsList = new ArrayList<>();
currentWorkUnit.setProperty(METRICS_MAP_ENTRY_KEY, workUnitMetricsList);
final Field[] fields = currentWorkUnit.getClazz().getFields();
for (final Field field : fields) {
if (Modifier.isPublic(field.getModifiers())) {
final Element fieldElement = JavaLanguageModelScanners.getElementForField(
getDoclet().getDocletEnv(),
currentWorkUnit.getDocElement(),
field,
ElementKind.FIELD
);
if (fieldElement != null) {
final String docComment = JavaLanguageModelScanners.getDocComment(getDoclet().getDocletEnv(), fieldElement);
final Map<String, String> metricsFields = new HashMap<>();
metricsFields.put(METRICS_MAP_NAME_KEY, field.getName());
metricsFields.put(METRICS_MAP_SUMMARY_KEY, docComment);
workUnitMetricsList.add(metricsFields);
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?php
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just copied from picard I assume?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its copied from the Picard one that I made up when I added the metrics ;-). I removed the group in from it though, since thats not usually included in the detail pages and for some reason I left it in the Picard one (which is not really used anyway).


include '../../../common/include/common.php';
include_once '../../config.php';
$module = modules::GATK;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With some minor changes it looks like.

printHeader($module, $name, topSN::guide);
?>

<link type='text/css' rel='stylesheet' href='gatkDoc.css'>

<div class='row-fluid' id="top">

<#include "common.html"/>

<?php $group = '${group}'; ?>

<section class="span4">
<aside class="well">
<a href="index.html"><h4><i class='fa fa-chevron-left'></i> Back to Tool Docs Index</h4></a>
</aside>
<?php getForumPosts( '${name}' ) ?>

</section>

<div class="span8">

<h1>${name}</h1>

<p class="lead">${summary}</p>

<#if group?? >
<h3>Category
<small> ${group}</small>
</h3>
</#if>
<hr>
<h2>Overview</h2>
${description}

<#-- Create the metrics summary -->
<#if metrics?size != 0>
<p>This table summarizes the values that are specific to this metric.</p>
<table class="table table-striped table-bordered table-condensed">
<thead>
<tr>
<th>Metric</th>
<th>Summary</th>
</tr>
</thead>
<#list metrics as metric>
<tr>
<td>${metric.name}<br />
<td>${metric.summary}</td>
</tr>
</#list>
</tbody>
</table>
</#if>

<@footerInfo />
<@footerClose />

</div>

<?php printFooter($module); ?>