Merged bug fix from Stable into Unstable

This commit is contained in:
Mauricio Carneiro 2012-07-25 13:47:07 -04:00
commit 1e4816e150
8 changed files with 77 additions and 286 deletions

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2012, The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.gatk;
import java.lang.annotation.*;
/**
* Allows the walker to be tagged, they can have an unlimited number of categories.
*/
@Documented
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Categorize {
public Category[] value() default {Category.UNCATEGORIZED};
}

View File

@ -1,68 +0,0 @@
/*
* Copyright (c) 2012, The Broad Institute
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
package org.broadinstitute.sting.gatk;
public enum Category {
BAM_PROCESSING("Walker", "BAM Processing and Analysis Tools"),
COMPANION("Walker", "Companion Utilities"),
CANCER_SPECIFIC("Walker", "Cancer-specific Variant Discovery Tools"),
QUALITY_CONTROL("Walker", "Quality Control and Simple Analysis Tools"),
VALIDATION("Walker", "Validation Utilities"),
VARIANT_DETECTION("ex", "Variant Detection"),
VARIANT_DISCOVERY("Walker", "Variant Discovery Tools"),
VARIANT_EVALUATION("Walker", "Variant Evaluation and Manipulation Tools"),
EXPERIMENTAL("Walker", "Miscellaneous Experimental (and Potentially Unstable) Tools"),
UNCATEGORIZED("all", "No category");
private final String description;
/**
* Accepted strings are from the GATKDocWorkUnit.group
*/
private final String type;
private Category(String type, String description) {
this.description = description;
this.type = type;
}
public String type() {
return type;
}
public String getDescription() {
return description;
}
}

View File

@ -25,10 +25,8 @@
package org.broadinstitute.sting.utils.help;
import com.sun.javadoc.ClassDoc;
import org.broadinstitute.sting.gatk.Category;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -56,10 +54,6 @@ class GATKDocWorkUnit implements Comparable<GATKDocWorkUnit> {
* The name of the documentation group (e.g., walkers, read filters) class belongs to
*/
final String group;
/**
* The categories that this class belongs to
*/
final List<Category> categories;
/**
* The documentation handler for this class
*/
@ -81,15 +75,13 @@ class GATKDocWorkUnit implements Comparable<GATKDocWorkUnit> {
String summary;
Map<String, Object> forTemplate;
public GATKDocWorkUnit(String name, String filename, String group, List<Category> categories,
DocumentedGATKFeatureObject annotation, DocumentedGATKFeatureHandler handler,
ClassDoc classDoc, Class clazz,
public GATKDocWorkUnit(String name, String filename, String group, DocumentedGATKFeatureObject annotation,
DocumentedGATKFeatureHandler handler, ClassDoc classDoc, Class clazz,
String buildTimestamp, String absoluteVersion) {
this.annotation = annotation;
this.name = name;
this.filename = filename;
this.group = group;
this.categories = categories;
this.handler = handler;
this.classDoc = classDoc;
this.clazz = clazz;

View File

@ -24,7 +24,6 @@
package org.broadinstitute.sting.utils.help;
import com.google.gson.Gson;
import com.sun.javadoc.ClassDoc;
import com.sun.javadoc.RootDoc;
import freemarker.template.Configuration;
@ -35,8 +34,6 @@ import org.apache.commons.io.FileUtils;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.broad.tribble.FeatureCodec;
import org.broadinstitute.sting.gatk.Categorize;
import org.broadinstitute.sting.gatk.Category;
import org.broadinstitute.sting.gatk.CommandLineGATK;
import org.broadinstitute.sting.gatk.walkers.qc.DocumentationTest;
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
@ -44,16 +41,15 @@ import org.broadinstitute.sting.utils.exceptions.UserException;
import org.broadinstitute.sting.utils.text.XReadLines;
import java.io.*;
import java.lang.annotation.Annotation;
import java.util.*;
/**
* Javadoc Doclet that combines javadoc, GATK ParsingEngine annotations, and FreeMarker
* templates to produce html formatted GATKDocs for walkers
* and other classes.
*
* <p/>
* This document has the following workflow:
*
* <p/>
* 1 -- walk the javadoc heirarchy, looking for class that have the
* DocumentedGATKFeature annotation or are in the type heirarchy in the
* static list of things to document, and are to be documented
@ -63,7 +59,7 @@ import java.util.*;
* as well as links to related features via their units. Writing
* of a specific class HTML is accomplished by a generate DocumentationHandler
* 4 -- write out an index of all units, organized by group
*
* <p/>
* The documented classes are restricted to only those with @DocumentedGATKFeature
* annotation or are in the STATIC_DOCS class.
*/
@ -207,12 +203,19 @@ public class GATKDoclet {
myWorkUnits = computeWorkUnits();
Map<Category, List<Map<String, String>>> catNav = getCategories(new ArrayList<GATKDocWorkUnit>(myWorkUnits));
processCategories(catNav, myWorkUnits);
List<Map<String, String>> groups = new ArrayList<Map<String, String>>();
Set<String> seenDocumentationFeatures = new HashSet<String>();
List<Map<String, String>> data = new ArrayList<Map<String, String>>();
for (GATKDocWorkUnit workUnit : myWorkUnits) {
data.add(workUnit.indexDataMap());
if (!seenDocumentationFeatures.contains(workUnit.annotation.groupName())) {
groups.add(toMap(workUnit.annotation));
seenDocumentationFeatures.add(workUnit.annotation.groupName());
}
}
for (GATKDocWorkUnit workUnit : myWorkUnits) {
processDocWorkUnit(cfg, workUnit, catNav);
processDocWorkUnit(cfg, workUnit, groups, data);
}
processIndex(cfg, new ArrayList<GATKDocWorkUnit>(myWorkUnits));
@ -257,43 +260,6 @@ public class GATKDoclet {
}
}
private void processCategories(Map<Category, List<Map<String, String>>> getCategories, Set<GATKDocWorkUnit> classes) throws IOException {
List<Object> categories = new LinkedList<Object>();
for (Category cat : getCategories.keySet()) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("Name", cat.getDescription());
properties.put("UrlSlug", cat.name().toLowerCase().replace('_', '-'));
categories.add(properties);
}
writeJson(DESTINATION_DIR + "/categories.json", categories);
List<Object> posts = new LinkedList<Object>();
for (GATKDocWorkUnit unit : classes) {
Map<String, Object> properties = new HashMap<String, Object>();
properties.put("Post Title", unit.name + " Documentation");
properties.put("Categories", unit.categories);
List<String> tags = new ArrayList<String>();
tags.add(unit.name);
tags.add(unit.group);
properties.put("Tags", tags);
String body = String.format("<a href='%s'>%s</a><hr /><p>%s</p>",
GATKDocUtils.URL_ROOT_FOR_RELEASE_GATKDOCS + unit.filename, unit.name + " Documentation", unit.summary);
properties.put("Body", body);
posts.add(properties);
}
}
private void writeJson(String filename, Object source) throws IOException {
Gson gson = new Gson();
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(filename))), 1024 * 1024);
out.write(gson.toJson(source));
out.close();
}
/**
* Returns the set of all GATKDocWorkUnits that we are going to generate docs for.
*
@ -318,10 +284,8 @@ public class GATKDoclet {
if (handler != null && handler.includeInDocs(doc)) {
logger.info("Generating documentation for class " + doc);
String filename = handler.getDestinationFilename(doc, clazz);
Category[] categories = getClassAnnotationValue(clazz, Categorize.class, "value");
GATKDocWorkUnit unit = new GATKDocWorkUnit(doc.name(),
filename, feature.groupName(), (categories == null) ? new ArrayList<Category>() : Arrays.asList(categories),
feature, handler, doc, clazz,
filename, feature.groupName(), feature, handler, doc, clazz,
buildTimestamp, absoluteVersion);
m.add(unit);
}
@ -451,8 +415,6 @@ public class GATKDoclet {
root.put("timestamp", buildTimestamp);
root.put("version", absoluteVersion);
root.put("categories", getCategories(indexData));
return root;
}
@ -498,14 +460,16 @@ public class GATKDoclet {
*
* @param cfg
* @param unit
* @param data
* @throws IOException
*/
private void processDocWorkUnit(Configuration cfg, GATKDocWorkUnit unit, Map<Category, List<Map<String, String>>> categories)
private void processDocWorkUnit(Configuration cfg, GATKDocWorkUnit unit, List<Map<String, String>> groups, List<Map<String, String>> data)
throws IOException {
//System.out.printf("Processing documentation for class %s%n", unit.classDoc);
unit.handler.processOne(unit);
unit.forTemplate.put("catNav", categories);
unit.forTemplate.put("groups", groups);
unit.forTemplate.put("data", data);
// Get or create a template
Template temp = cfg.getTemplate(unit.handler.getTemplateName(unit.classDoc));
@ -520,45 +484,6 @@ public class GATKDoclet {
}
}
// hack - todo - is there a better way to process annotations?
private Category[] getClassAnnotationValue(Class classType, Class annotationType, String attributeName) {
Category[] value = null;
Annotation annotation = classType.getAnnotation(annotationType);
if (annotation != null) {
try {
value = (Category[]) annotation.annotationType().getMethod(attributeName).invoke(annotation);
} catch (Exception ex) {
}
}
return value;
}
private Map<Category, List<Map<String, String>>> getCategories(List<GATKDocWorkUnit> classes) {
Map<Category, List<Map<String, String>>> output = new TreeMap<Category, List<Map<String, String>>>();
for (Category cat : Category.values()) {
output.put(cat, new ArrayList<Map<String, String>>());
}
for (GATKDocWorkUnit unit : classes) {
Category[] categories = getClassAnnotationValue(unit.clazz, Categorize.class, "value");
if (categories != null) {
for (Category cat : categories) {
unit.handler.processOne(unit);
Map<String, String> datum = unit.indexDataMap();
output.get(cat).add(datum);
}
}
}
return output;
}
private static String getSimpleVersion(String absoluteVersion) {
String[] parts = absoluteVersion.split("-");

View File

@ -88,6 +88,7 @@ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler {
addHighLevelBindings(root);
addArgumentBindings(root);
addRelatedBindings(root);
root.put("group", toProcess.group);
toProcess.setHandlerContent((String) root.get("summary"), root);
}
@ -109,7 +110,6 @@ public class GenericDocumentationHandler extends DocumentedGATKFeatureHandler {
root.put("description", toProcess.classDoc.commentText().substring(summaryBuilder.toString().length()));
root.put("timestamp", toProcess.buildTimestamp);
root.put("version", toProcess.absoluteVersion);
root.put("categories", toProcess.categories);
for (Tag tag : toProcess.classDoc.tags()) {
root.put(tag.name(), tag.text());

View File

@ -28,7 +28,7 @@
-->
<#global siteRoot = "http://gsa-stage:8080/" />
<#global siteRoot = "http://www.broadinstitute.org/gatk/" />
<#global forum = "http://gatk.vanillaforums.com/" />
<#macro makeHeader title isIndex>
@ -49,9 +49,9 @@
body {
padding-top : 60px;
}
}
</style>
</head>
<body>
<div class="navbar navbar-fixed-top">
@ -63,7 +63,7 @@
</div>
<div class="container-fluid">
<?php
// Output Buffering allows for the website to inject a different header
ob_clean();
include '../include/common.php';
printHeader("${title}", "Guides");
@ -95,7 +95,7 @@
?>
</#macro>
<#macro getCategories map filter>
<#macro getCategories groups>
<style>
#sidenav .accordion-body a {
color : gray;
@ -105,31 +105,20 @@
list-style : none;
}
</style>
<ul class="nav nav-pills nav-stacked" id="sidenav">
<#list 0..(map?keys?size-1) as x>
<li><a data-toggle="collapse" data-parent="#sidenav"
href="#${map?keys[x]}">${map?keys[x].getDescription()}</a>
<#list groups?sort_by("name") as group>
<li><a data-toggle="collapse" data-parent="#sidenav" href="#${group.id}">${group.name}</a>
<div id="${map?keys[x]}"
<?php echo (in_array('${map?keys[x]}', $categories)) ? 'class="accordion-body collapse in"'.chr(62) : 'class="accordion-body collapse"'.chr(62);?>
<div id="${group.id}"
<?php echo ($group == '${group.name}')? 'class="accordion-body collapse in"'.chr(62) : 'class="accordion-body collapse"'.chr(62);?>
<ul>
<#assign items=map?values[x] />
<#if filter !="all" >
<#list items as datum>
<#if datum.group == filter>
<li><a href="${datum.filename}" rel="tooltip"
title="${datum.summary}">${datum.name}</a>
</li>
</#if>
</#list>
<#else>
<#list items as datum>
<li><a href="${datum.filename}" rel="tooltip"
title="${datum.summary}">${datum.name}</a>
</li>
</#list>
</#if>
<#list data as datum>
<#if datum.group == group.name>
<li>
<a href="${datum.filename}">${datum.name}</a>
</li>
</#if>
</#list>
</ul>
</div>
</li>

View File

@ -25,38 +25,29 @@
<#include "common.html"/>
<#macro emitGroup group>
<div class="accordion" id="index">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#index" href="#${group.id}"><h3>
${group.name}</h3></a>
</div>
<div class="accordion-body collapse" id="${group.id}">
<div class="accordion-inner">
<p class="lead">${group.summary}
<p>
<#if group.id == "GATKwalkers">
<h3>Categories</h3>
<@getCategories map=categories filter="GATK walkers" />
<#else>
<table class="table table-striped table-bordered table-condensed">
<tr>
<th>Name</th>
<th>Summary</th>
</tr>
<#list data as datum>
<#if datum.group == group.name>
<tr>
<td><a href="${datum.filename}">${datum.name}</a></td>
<td>${datum.summary}</td>
</tr>
</#if>
</#list>
</table>
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#index" href="#${group.id}">
<h4>${group.name}</h4>
</a>
</div>
<div class="accordion-body collapse" id="${group.id}">
<div class="accordion-inner">
<p class="lead">${group.summary}</p>
<table class="table table-striped table-bordered table-condensed">
<tr>
<th>Name</th>
<th>Summary</th>
</tr>
<#list data as datum>
<#if datum.group == group.name>
<tr>
<td><a href="${datum.filename}">${datum.name}</a></td>
<td>${datum.summary}</td>
</tr>
</#if>
</div>
</#list>
</table>
</div>
</div>
</div>
@ -67,9 +58,11 @@
<small>${version}</small>
</h1>
<hr>
<#list groups?sort_by("name") as group>
<@emitGroup group=group/>
</#list>
<div class="accordion" id="index">
<#list groups?sort_by("name") as group>
<@emitGroup group=group/>
</#list>
</div>
<@footerInfo />
<@pageFooter />

View File

@ -37,7 +37,8 @@
<td>${arg.summary}</td>
</tr>
<#--
<td>${arg.required}</td>
<
td>${arg.required}</td>
-->
</#list>
</#if>
@ -87,14 +88,12 @@
</#list>
</#macro>
<#list categories as cat>
<?php $categories[] = '${cat}'; ?>
</#list>
<?php $group = '${group}'; ?>
<@makeHeader title="${name} documentation" isIndex=false />
<section class="span4">
<aside class="well">
<h2>Categories</h2>
<@getCategories map=catNav filter="all" />
<@getCategories groups=groups />
</aside>
<?php getForumPosts( '${name}' ) ?>
@ -106,18 +105,17 @@
<p class="lead">${summary}</p>
<#if author??>
<h2>Author<br/>
<small>${author}</small>
</h2>
<h3>Author
<small> ${author}</small>
</h3>
</#if>
<#if (categories?size > 0) >
<h3>Categories</h3>
<ul>
<#list categories as cat>
<li>${cat.getDescription()}</li>
</#list>
</ul>
<#if group?? >
<h3>Category
<small> ${group}</small>
</h3>
</#if>
<br/>
<h2>Introduction</h2>
${description}