
org.snpeff.stats.plot.GoogleBarChart Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of SnpEff Show documentation
Show all versions of SnpEff Show documentation
Variant annotation and effect prediction package.
The newest version!
package org.snpeff.stats.plot;
import java.util.ArrayList;
import org.snpeff.util.Gpr;
public class GoogleBarChart extends GoogleLineChart {
public GoogleBarChart(String name) {
super(name);
}
public GoogleBarChart(String name, int width, int height) {
super(name, width, height);
}
/**
* Scale columns to their respective counts
*/
public void percentColumns() {
ArrayList> newColumns = new ArrayList>();
for (ArrayList col : columns)
newColumns.add(percentColumns(col));
columns = newColumns;
}
/**
* Scale column to total sum
* @param col
* @return
*/
public ArrayList percentColumns(ArrayList col) {
ArrayList newCol = new ArrayList(col.size());
// Calculate total
double total = 0;
for (String d : col)
total += Gpr.parseDoubleSafe(d);
// Scale
for (String d : col)
newCol.add("" + (100.0 * Gpr.parseDoubleSafe(d) / total));
return newCol;
}
@Override
public String toStringHtmlHeader() {
StringBuilder sb = new StringBuilder();
sb.append("");
sb.append("\n");
sb.append("\n");
sb.append("\n");
return sb.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy