Merge branch 'master' of ssh://gsa1/humgen/gsa-scr1/gsa-engineering/git/unstable
This commit is contained in:
commit
aa097a83d5
|
|
@ -24,8 +24,7 @@ public class GATKReport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new GATKReport with the contents of a GATKReport on disk.
|
* Create a new GATKReport with the contents of a GATKReport on disk.
|
||||||
*
|
* @param filename the path to the file to load
|
||||||
* @param filename the path to the file to load
|
|
||||||
*/
|
*/
|
||||||
public GATKReport(String filename) {
|
public GATKReport(String filename) {
|
||||||
this(new File(filename));
|
this(new File(filename));
|
||||||
|
|
@ -33,8 +32,7 @@ public class GATKReport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new GATKReport with the contents of a GATKReport on disk.
|
* Create a new GATKReport with the contents of a GATKReport on disk.
|
||||||
*
|
* @param file the file to load
|
||||||
* @param file the file to load
|
|
||||||
*/
|
*/
|
||||||
public GATKReport(File file) {
|
public GATKReport(File file) {
|
||||||
loadReport(file);
|
loadReport(file);
|
||||||
|
|
@ -42,8 +40,7 @@ public class GATKReport {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a GATKReport file from disk
|
* Load a GATKReport file from disk
|
||||||
*
|
* @param file the file to load
|
||||||
* @param file the file to load
|
|
||||||
*/
|
*/
|
||||||
private void loadReport(File file) {
|
private void loadReport(File file) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -51,11 +48,12 @@ public class GATKReport {
|
||||||
|
|
||||||
GATKReportTable table = null;
|
GATKReportTable table = null;
|
||||||
String[] header = null;
|
String[] header = null;
|
||||||
|
int id = 0;
|
||||||
GATKReportVersion version = null;
|
GATKReportVersion version = null;
|
||||||
List<Integer> columnStarts = null;
|
List<Integer> columnStarts = null;
|
||||||
|
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ( (line = reader.readLine()) != null ) {
|
||||||
|
|
||||||
if (line.startsWith(GATKREPORT_HEADER_PREFIX)) {
|
if (line.startsWith(GATKREPORT_HEADER_PREFIX)) {
|
||||||
|
|
||||||
|
|
@ -73,7 +71,7 @@ public class GATKReport {
|
||||||
|
|
||||||
header = null;
|
header = null;
|
||||||
columnStarts = null;
|
columnStarts = null;
|
||||||
} else if (line.trim().isEmpty()) {
|
} else if ( line.trim().isEmpty() ) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} else {
|
} else {
|
||||||
if (table != null) {
|
if (table != null) {
|
||||||
|
|
@ -99,22 +97,19 @@ public class GATKReport {
|
||||||
if (header == null) {
|
if (header == null) {
|
||||||
header = splitLine;
|
header = splitLine;
|
||||||
|
|
||||||
// Set the first column as the primary key
|
table.addPrimaryKey("id", false);
|
||||||
table.addPrimaryKey(header[0]);
|
|
||||||
// Set every other column as column
|
for ( String columnName : header ) {
|
||||||
for (int i = 1; i < header.length; i++) {
|
table.addColumn(columnName, "");
|
||||||
table.addColumn(header[i], "");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id = 0;
|
||||||
} else {
|
} else {
|
||||||
//Get primary key Value from the current line array
|
for (int columnIndex = 0; columnIndex < header.length; columnIndex++) {
|
||||||
String primaryKey = splitLine[0];
|
table.set(id, header[columnIndex], splitLine[columnIndex]);
|
||||||
//Input all the remaining values
|
|
||||||
for (int columnIndex = 1; columnIndex < header.length; columnIndex++) {
|
|
||||||
table.set(primaryKey, header[columnIndex], splitLine[columnIndex]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
id++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -129,8 +124,8 @@ public class GATKReport {
|
||||||
/**
|
/**
|
||||||
* Add a new table to the collection
|
* Add a new table to the collection
|
||||||
*
|
*
|
||||||
* @param tableName the name of the table
|
* @param tableName the name of the table
|
||||||
* @param tableDescription the description of the table
|
* @param tableDescription the description of the table
|
||||||
*/
|
*/
|
||||||
public void addTable(String tableName, String tableDescription) {
|
public void addTable(String tableName, String tableDescription) {
|
||||||
addTable(tableName, tableDescription, true);
|
addTable(tableName, tableDescription, true);
|
||||||
|
|
@ -144,7 +139,7 @@ public class GATKReport {
|
||||||
/**
|
/**
|
||||||
* Return true if table with a given name exists
|
* Return true if table with a given name exists
|
||||||
*
|
*
|
||||||
* @param tableName the name of the table
|
* @param tableName the name of the table
|
||||||
* @return true if the table exists, false otherwise
|
* @return true if the table exists, false otherwise
|
||||||
*/
|
*/
|
||||||
public boolean hasTable(String tableName) {
|
public boolean hasTable(String tableName) {
|
||||||
|
|
@ -154,8 +149,8 @@ public class GATKReport {
|
||||||
/**
|
/**
|
||||||
* Return a table with a given name
|
* Return a table with a given name
|
||||||
*
|
*
|
||||||
* @param tableName the name of the table
|
* @param tableName the name of the table
|
||||||
* @return the table object
|
* @return the table object
|
||||||
*/
|
*/
|
||||||
public GATKReportTable getTable(String tableName) {
|
public GATKReportTable getTable(String tableName) {
|
||||||
GATKReportTable table = tables.get(tableName);
|
GATKReportTable table = tables.get(tableName);
|
||||||
|
|
@ -167,7 +162,7 @@ public class GATKReport {
|
||||||
/**
|
/**
|
||||||
* Print all tables contained within this container to a PrintStream
|
* Print all tables contained within this container to a PrintStream
|
||||||
*
|
*
|
||||||
* @param out the PrintStream to which the tables should be written
|
* @param out the PrintStream to which the tables should be written
|
||||||
*/
|
*/
|
||||||
public void print(PrintStream out) {
|
public void print(PrintStream out) {
|
||||||
for (GATKReportTable table : tables.values()) {
|
for (GATKReportTable table : tables.values()) {
|
||||||
|
|
@ -180,24 +175,4 @@ public class GATKReport {
|
||||||
public Collection<GATKReportTable> getTables() {
|
public Collection<GATKReportTable> getTables() {
|
||||||
return tables.values();
|
return tables.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void combineWith(GATKReport input) {
|
|
||||||
|
|
||||||
// For every input table, add values
|
|
||||||
System.out.println("This.tables: keySet");
|
|
||||||
for (String s : tables.keySet())
|
|
||||||
System.out.println(s);
|
|
||||||
|
|
||||||
// todo test tables exist
|
|
||||||
|
|
||||||
|
|
||||||
for (String tableName : input.tables.keySet()) {
|
|
||||||
System.out.println("Input table key: " + tableName);
|
|
||||||
if (tables.containsKey(tableName))
|
|
||||||
tables.get(tableName).mergeRows(input.getTable(tableName));
|
|
||||||
else
|
|
||||||
throw new ReviewedStingException("Failed to combine GATKReport, tables don't match!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
||||||
package org.broadinstitute.sting.gatk.report;
|
|
||||||
|
|
||||||
import org.broadinstitute.sting.commandline.Gatherer;
|
|
||||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by IntelliJ IDEA.
|
|
||||||
* User: roger
|
|
||||||
* Date: 1/9/12
|
|
||||||
* Time: 11:17 PM
|
|
||||||
* To change this template use File | Settings | File Templates.
|
|
||||||
*/
|
|
||||||
public class GATKReportGatherer extends Gatherer {
|
|
||||||
@Override
|
|
||||||
public void gather(List<File> inputs, File output) {
|
|
||||||
//Combines inputs GATKReport to one output
|
|
||||||
|
|
||||||
PrintStream o;
|
|
||||||
try {
|
|
||||||
o = new PrintStream(output);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new UserException("File to be output by CoverageByRG Gather function was not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
GATKReport current = new GATKReport();
|
|
||||||
boolean isFirst = true;
|
|
||||||
for (File input : inputs) {
|
|
||||||
|
|
||||||
// If the table is empty
|
|
||||||
if (isFirst) {
|
|
||||||
current = new GATKReport(input);
|
|
||||||
isFirst = false;
|
|
||||||
} else {
|
|
||||||
GATKReport toAdd = new GATKReport(input);
|
|
||||||
current.combineWith(toAdd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
current.print(o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -4,10 +4,7 @@ import org.apache.commons.lang.ObjectUtils;
|
||||||
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
import org.broadinstitute.sting.utils.exceptions.ReviewedStingException;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.Collection;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.TreeSet;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
|
@ -15,12 +12,12 @@ import java.util.regex.Pattern;
|
||||||
* A data structure that allows data to be collected over the course of a walker's computation, then have that data
|
* A data structure that allows data to be collected over the course of a walker's computation, then have that data
|
||||||
* written to a PrintStream such that it's human-readable, AWK-able, and R-friendly (given that you load it using the
|
* written to a PrintStream such that it's human-readable, AWK-able, and R-friendly (given that you load it using the
|
||||||
* GATKReport loader module).
|
* GATKReport loader module).
|
||||||
* <p/>
|
*
|
||||||
* The goal of this object is to use the same data structure for both accumulating data during a walker's computation
|
* The goal of this object is to use the same data structure for both accumulating data during a walker's computation
|
||||||
* and emitting that data to a file for easy analysis in R (or any other program/language that can take in a table of
|
* and emitting that data to a file for easy analysis in R (or any other program/language that can take in a table of
|
||||||
* results). Thus, all of the infrastructure below is designed simply to make printing the following as easy as
|
* results). Thus, all of the infrastructure below is designed simply to make printing the following as easy as
|
||||||
* possible:
|
* possible:
|
||||||
* <p/>
|
*
|
||||||
* ##:GATKReport.v0.1 ErrorRatePerCycle : The error rate per sequenced position in the reads
|
* ##:GATKReport.v0.1 ErrorRatePerCycle : The error rate per sequenced position in the reads
|
||||||
* cycle errorrate.61PA8.7 qualavg.61PA8.7
|
* cycle errorrate.61PA8.7 qualavg.61PA8.7
|
||||||
* 0 0.007451835696110506 25.474613284804366
|
* 0 0.007451835696110506 25.474613284804366
|
||||||
|
|
@ -32,60 +29,60 @@ import java.util.regex.Pattern;
|
||||||
* 6 5.452562704471102E-4 36.1217248908297
|
* 6 5.452562704471102E-4 36.1217248908297
|
||||||
* 7 5.452562704471102E-4 36.1910480349345
|
* 7 5.452562704471102E-4 36.1910480349345
|
||||||
* 8 5.452562704471102E-4 36.00345705967977
|
* 8 5.452562704471102E-4 36.00345705967977
|
||||||
* <p/>
|
*
|
||||||
* Here, we have a GATKReport table - a well-formatted, easy to read representation of some tabular data. Every single
|
* Here, we have a GATKReport table - a well-formatted, easy to read representation of some tabular data. Every single
|
||||||
* table has this same GATKReport.v0.1 header, which permits multiple files from different sources to be cat-ed
|
* table has this same GATKReport.v0.1 header, which permits multiple files from different sources to be cat-ed
|
||||||
* together, which makes it very easy to pull tables from different programs into R via a single file.
|
* together, which makes it very easy to pull tables from different programs into R via a single file.
|
||||||
* <p/>
|
*
|
||||||
* ------------
|
* ------------
|
||||||
* Definitions:
|
* Definitions:
|
||||||
* <p/>
|
*
|
||||||
* Table info:
|
* Table info:
|
||||||
* The first line, structured as
|
* The first line, structured as
|
||||||
* ##:<report version> <table name> : <table description>
|
* ##:<report version> <table name> : <table description>
|
||||||
* <p/>
|
*
|
||||||
* Table header:
|
* Table header:
|
||||||
* The second line, specifying a unique name for each column in the table.
|
* The second line, specifying a unique name for each column in the table.
|
||||||
* <p/>
|
*
|
||||||
* The first column mentioned in the table header is the "primary key" column - a column that provides the unique
|
* The first column mentioned in the table header is the "primary key" column - a column that provides the unique
|
||||||
* identifier for each row in the table. Once this column is created, any element in the table can be referenced by
|
* identifier for each row in the table. Once this column is created, any element in the table can be referenced by
|
||||||
* the row-column coordinate, i.e. "primary key"-"column name" coordinate.
|
* the row-column coordinate, i.e. "primary key"-"column name" coordinate.
|
||||||
* <p/>
|
*
|
||||||
* When a column is added to a table, a default value must be specified (usually 0). This is the initial value for
|
* When a column is added to a table, a default value must be specified (usually 0). This is the initial value for
|
||||||
* an element in a column. This permits operations like increment() and decrement() to work properly on columns that
|
* an element in a column. This permits operations like increment() and decrement() to work properly on columns that
|
||||||
* are effectively counters for a particular event.
|
* are effectively counters for a particular event.
|
||||||
* <p/>
|
*
|
||||||
* Finally, the display property for each column can be set during column creation. This is useful when a given
|
* Finally, the display property for each column can be set during column creation. This is useful when a given
|
||||||
* column stores an intermediate result that will be used later on, perhaps to calculate the value of another column.
|
* column stores an intermediate result that will be used later on, perhaps to calculate the value of another column.
|
||||||
* In these cases, it's obviously necessary to store the value required for further computation, but it's not
|
* In these cases, it's obviously necessary to store the value required for further computation, but it's not
|
||||||
* necessary to actually print the intermediate column.
|
* necessary to actually print the intermediate column.
|
||||||
* <p/>
|
*
|
||||||
* Table body:
|
* Table body:
|
||||||
* The values of the table itself.
|
* The values of the table itself.
|
||||||
* <p/>
|
*
|
||||||
* ---------------
|
* ---------------
|
||||||
* Implementation:
|
* Implementation:
|
||||||
* <p/>
|
*
|
||||||
* The implementation of this table has two components:
|
* The implementation of this table has two components:
|
||||||
* 1. A TreeSet<Object> that stores all the values ever specified for the primary key. Any get() operation that
|
* 1. A TreeSet<Object> that stores all the values ever specified for the primary key. Any get() operation that
|
||||||
* refers to an element where the primary key object does not exist will result in its implicit creation. I
|
* refers to an element where the primary key object does not exist will result in its implicit creation. I
|
||||||
* haven't yet decided if this is a good idea...
|
* haven't yet decided if this is a good idea...
|
||||||
* <p/>
|
*
|
||||||
* 2. A HashMap<String, GATKReportColumn> that stores a mapping from column name to column contents. Each
|
* 2. A HashMap<String, GATKReportColumn> that stores a mapping from column name to column contents. Each
|
||||||
* GATKReportColumn is effectively a map (in fact, GATKReportColumn extends TreeMap<Object, Object>) between
|
* GATKReportColumn is effectively a map (in fact, GATKReportColumn extends TreeMap<Object, Object>) between
|
||||||
* primary key and the column value. This means that, given N columns, the primary key information is stored
|
* primary key and the column value. This means that, given N columns, the primary key information is stored
|
||||||
* N+1 times. This is obviously wasteful and can likely be handled much more elegantly in future implementations.
|
* N+1 times. This is obviously wasteful and can likely be handled much more elegantly in future implementations.
|
||||||
* <p/>
|
*
|
||||||
* ------------------------------
|
* ------------------------------
|
||||||
* Element and column operations:
|
* Element and column operations:
|
||||||
* <p/>
|
*
|
||||||
* In addition to simply getting and setting values, this object also permits some simple operations to be applied to
|
* In addition to simply getting and setting values, this object also permits some simple operations to be applied to
|
||||||
* individual elements or to whole columns. For instance, an element can be easily incremented without the hassle of
|
* individual elements or to whole columns. For instance, an element can be easily incremented without the hassle of
|
||||||
* calling get(), incrementing the obtained value by 1, and then calling set() with the new value. Also, some vector
|
* calling get(), incrementing the obtained value by 1, and then calling set() with the new value. Also, some vector
|
||||||
* operations are supported. For instance, two whole columns can be divided and have the result be set to a third
|
* operations are supported. For instance, two whole columns can be divided and have the result be set to a third
|
||||||
* column. This is especially useful when aggregating counts in two intermediate columns that will eventually need to
|
* column. This is especially useful when aggregating counts in two intermediate columns that will eventually need to
|
||||||
* be manipulated row-by-row to compute the final column.
|
* be manipulated row-by-row to compute the final column.
|
||||||
* <p/>
|
*
|
||||||
* Note: I've made no attempt whatsoever to make these operations efficient. Right now, some of the methods check the
|
* Note: I've made no attempt whatsoever to make these operations efficient. Right now, some of the methods check the
|
||||||
* type of the stored object using an instanceof call and attempt to do the right thing. Others cast the contents of
|
* type of the stored object using an instanceof call and attempt to do the right thing. Others cast the contents of
|
||||||
* the cell to a Number, call the Number.toDouble() method and compute a result. This is clearly not the ideal design,
|
* the cell to a Number, call the Number.toDouble() method and compute a result. This is clearly not the ideal design,
|
||||||
|
|
@ -95,9 +92,7 @@ import java.util.regex.Pattern;
|
||||||
* @author Khalid Shakir
|
* @author Khalid Shakir
|
||||||
*/
|
*/
|
||||||
public class GATKReportTable {
|
public class GATKReportTable {
|
||||||
/**
|
/** REGEX that matches any table with an invalid name */
|
||||||
* REGEX that matches any table with an invalid name
|
|
||||||
*/
|
|
||||||
public final static String INVALID_TABLE_NAME_REGEX = "[^a-zA-Z0-9_\\-\\.]";
|
public final static String INVALID_TABLE_NAME_REGEX = "[^a-zA-Z0-9_\\-\\.]";
|
||||||
private static final GATKReportVersion LATEST_REPORT_VERSION = GATKReportVersion.V0_2;
|
private static final GATKReportVersion LATEST_REPORT_VERSION = GATKReportVersion.V0_2;
|
||||||
private String tableName;
|
private String tableName;
|
||||||
|
|
@ -114,8 +109,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Verifies that a table or column name has only alphanumeric characters - no spaces or special characters allowed
|
* Verifies that a table or column name has only alphanumeric characters - no spaces or special characters allowed
|
||||||
*
|
*
|
||||||
* @param name the name of the table or column
|
* @param name the name of the table or column
|
||||||
* @return true if the name is valid, false if otherwise
|
* @return true if the name is valid, false if otherwise
|
||||||
*/
|
*/
|
||||||
private boolean isValidName(String name) {
|
private boolean isValidName(String name) {
|
||||||
Pattern p = Pattern.compile(INVALID_TABLE_NAME_REGEX);
|
Pattern p = Pattern.compile(INVALID_TABLE_NAME_REGEX);
|
||||||
|
|
@ -127,8 +122,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Verifies that a table or column name has only alphanumeric characters - no spaces or special characters allowed
|
* Verifies that a table or column name has only alphanumeric characters - no spaces or special characters allowed
|
||||||
*
|
*
|
||||||
* @param description the name of the table or column
|
* @param description the name of the table or column
|
||||||
* @return true if the name is valid, false if otherwise
|
* @return true if the name is valid, false if otherwise
|
||||||
*/
|
*/
|
||||||
private boolean isValidDescription(String description) {
|
private boolean isValidDescription(String description) {
|
||||||
Pattern p = Pattern.compile("\\r|\\n");
|
Pattern p = Pattern.compile("\\r|\\n");
|
||||||
|
|
@ -140,15 +135,15 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Construct a new GATK report table with the specified name and description
|
* Construct a new GATK report table with the specified name and description
|
||||||
*
|
*
|
||||||
* @param tableName the name of the table
|
* @param tableName the name of the table
|
||||||
* @param tableDescription the description of the table
|
* @param tableDescription the description of the table
|
||||||
*/
|
*/
|
||||||
public GATKReportTable(String tableName, String tableDescription) {
|
public GATKReportTable(String tableName, String tableDescription) {
|
||||||
this(tableName, tableDescription, true);
|
this(tableName, tableDescription, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GATKReportTable(String tableName, String tableDescription, boolean sortByPrimaryKey) {
|
public GATKReportTable(String tableName, String tableDescription, boolean sortByPrimaryKey) {
|
||||||
if (!isValidName(tableName)) {
|
if (!isValidName(tableName)) {
|
||||||
throw new ReviewedStingException("Attempted to set a GATKReportTable name of '" + tableName + "'. GATKReportTable names must be purely alphanumeric - no spaces or special characters are allowed.");
|
throw new ReviewedStingException("Attempted to set a GATKReportTable name of '" + tableName + "'. GATKReportTable names must be purely alphanumeric - no spaces or special characters are allowed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -174,7 +169,7 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Add a primary key column. This becomes the unique identifier for every column in the table.
|
* Add a primary key column. This becomes the unique identifier for every column in the table.
|
||||||
*
|
*
|
||||||
* @param primaryKeyName the name of the primary key column
|
* @param primaryKeyName the name of the primary key column
|
||||||
*/
|
*/
|
||||||
public void addPrimaryKey(String primaryKeyName) {
|
public void addPrimaryKey(String primaryKeyName) {
|
||||||
addPrimaryKey(primaryKeyName, true);
|
addPrimaryKey(primaryKeyName, true);
|
||||||
|
|
@ -183,8 +178,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Add an optionally visible primary key column. This becomes the unique identifier for every column in the table, and will always be printed as the first column.
|
* Add an optionally visible primary key column. This becomes the unique identifier for every column in the table, and will always be printed as the first column.
|
||||||
*
|
*
|
||||||
* @param primaryKeyName the name of the primary key column
|
* @param primaryKeyName the name of the primary key column
|
||||||
* @param display should this primary key be displayed?
|
* @param display should this primary key be displayed?
|
||||||
*/
|
*/
|
||||||
public void addPrimaryKey(String primaryKeyName, boolean display) {
|
public void addPrimaryKey(String primaryKeyName, boolean display) {
|
||||||
if (!isValidName(primaryKeyName)) {
|
if (!isValidName(primaryKeyName)) {
|
||||||
|
|
@ -200,7 +195,6 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Returns the first primary key matching the dotted column values.
|
* Returns the first primary key matching the dotted column values.
|
||||||
* Ex: dbsnp.eval.called.all.novel.all
|
* Ex: dbsnp.eval.called.all.novel.all
|
||||||
*
|
|
||||||
* @param dottedColumnValues Period concatenated values.
|
* @param dottedColumnValues Period concatenated values.
|
||||||
* @return The first primary key matching the column values or throws an exception.
|
* @return The first primary key matching the column values or throws an exception.
|
||||||
*/
|
*/
|
||||||
|
|
@ -214,7 +208,6 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Returns true if there is at least on row with the dotted column values.
|
* Returns true if there is at least on row with the dotted column values.
|
||||||
* Ex: dbsnp.eval.called.all.novel.all
|
* Ex: dbsnp.eval.called.all.novel.all
|
||||||
*
|
|
||||||
* @param dottedColumnValues Period concatenated values.
|
* @param dottedColumnValues Period concatenated values.
|
||||||
* @return true if there is at least one row matching the columns.
|
* @return true if there is at least one row matching the columns.
|
||||||
*/
|
*/
|
||||||
|
|
@ -225,7 +218,6 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Returns the first primary key matching the dotted column values.
|
* Returns the first primary key matching the dotted column values.
|
||||||
* Ex: dbsnp.eval.called.all.novel.all
|
* Ex: dbsnp.eval.called.all.novel.all
|
||||||
*
|
|
||||||
* @param dottedColumnValues Period concatenated values.
|
* @param dottedColumnValues Period concatenated values.
|
||||||
* @return The first primary key matching the column values or null.
|
* @return The first primary key matching the column values or null.
|
||||||
*/
|
*/
|
||||||
|
|
@ -236,7 +228,6 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Returns the first primary key matching the column values.
|
* Returns the first primary key matching the column values.
|
||||||
* Ex: new String[] { "dbsnp", "eval", "called", "all", "novel", "all" }
|
* Ex: new String[] { "dbsnp", "eval", "called", "all", "novel", "all" }
|
||||||
*
|
|
||||||
* @param columnValues column values.
|
* @param columnValues column values.
|
||||||
* @return The first primary key matching the column values.
|
* @return The first primary key matching the column values.
|
||||||
*/
|
*/
|
||||||
|
|
@ -244,7 +235,7 @@ public class GATKReportTable {
|
||||||
for (Object primaryKey : primaryKeyColumn) {
|
for (Object primaryKey : primaryKeyColumn) {
|
||||||
boolean matching = true;
|
boolean matching = true;
|
||||||
for (int i = 0; matching && i < columnValues.length; i++) {
|
for (int i = 0; matching && i < columnValues.length; i++) {
|
||||||
matching = ObjectUtils.equals(columnValues[i], get(primaryKey, i + 1));
|
matching = ObjectUtils.equals(columnValues[i], get(primaryKey, i+1));
|
||||||
}
|
}
|
||||||
if (matching)
|
if (matching)
|
||||||
return primaryKey;
|
return primaryKey;
|
||||||
|
|
@ -255,8 +246,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Add a column to the report and specify the default value that should be supplied if a given position in the table is never explicitly set.
|
* Add a column to the report and specify the default value that should be supplied if a given position in the table is never explicitly set.
|
||||||
*
|
*
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @param defaultValue the default value for the column
|
* @param defaultValue the default value for the column
|
||||||
*/
|
*/
|
||||||
public void addColumn(String columnName, Object defaultValue) {
|
public void addColumn(String columnName, Object defaultValue) {
|
||||||
addColumn(columnName, defaultValue, null);
|
addColumn(columnName, defaultValue, null);
|
||||||
|
|
@ -265,13 +256,12 @@ public class GATKReportTable {
|
||||||
public void addColumn(String columnName, Object defaultValue, String format) {
|
public void addColumn(String columnName, Object defaultValue, String format) {
|
||||||
addColumn(columnName, defaultValue, true, format);
|
addColumn(columnName, defaultValue, true, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a column to the report, specify the default column value, and specify whether the column should be displayed in the final output (useful when intermediate columns are necessary for later calculations, but are not required to be in the output file.
|
* Add a column to the report, specify the default column value, and specify whether the column should be displayed in the final output (useful when intermediate columns are necessary for later calculations, but are not required to be in the output file.
|
||||||
*
|
*
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @param defaultValue the default value of the column
|
* @param defaultValue the default value of the column
|
||||||
* @param display if true - the column will be displayed; if false - the column will be hidden
|
* @param display if true - the column will be displayed; if false - the column will be hidden
|
||||||
*/
|
*/
|
||||||
public void addColumn(String columnName, Object defaultValue, boolean display) {
|
public void addColumn(String columnName, Object defaultValue, boolean display) {
|
||||||
addColumn(columnName, defaultValue, display, null);
|
addColumn(columnName, defaultValue, display, null);
|
||||||
|
|
@ -287,8 +277,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Check if the requested element exists, and if not, create it.
|
* Check if the requested element exists, and if not, create it.
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
*/
|
*/
|
||||||
private void verifyEntry(Object primaryKey, String columnName) {
|
private void verifyEntry(Object primaryKey, String columnName) {
|
||||||
if (!columns.containsKey(columnName)) {
|
if (!columns.containsKey(columnName)) {
|
||||||
|
|
@ -309,9 +299,9 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Set the value for a given position in the table
|
* Set the value for a given position in the table
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @param value the value to set
|
* @param value the value to set
|
||||||
*/
|
*/
|
||||||
public void set(Object primaryKey, String columnName, Object value) {
|
public void set(Object primaryKey, String columnName, Object value) {
|
||||||
verifyEntry(primaryKey, columnName);
|
verifyEntry(primaryKey, columnName);
|
||||||
|
|
@ -322,9 +312,9 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Get a value from the given position in the table
|
* Get a value from the given position in the table
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @return the value stored at the specified position in the table
|
* @return the value stored at the specified position in the table
|
||||||
*/
|
*/
|
||||||
public Object get(Object primaryKey, String columnName) {
|
public Object get(Object primaryKey, String columnName) {
|
||||||
verifyEntry(primaryKey, columnName);
|
verifyEntry(primaryKey, columnName);
|
||||||
|
|
@ -337,7 +327,7 @@ public class GATKReportTable {
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnIndex the index of the column
|
* @param columnIndex the index of the column
|
||||||
* @return the value stored at the specified position in the table
|
* @return the value stored at the specified position in the table
|
||||||
*/
|
*/
|
||||||
private Object get(Object primaryKey, int columnIndex) {
|
private Object get(Object primaryKey, int columnIndex) {
|
||||||
return columns.getByIndex(columnIndex).get(primaryKey);
|
return columns.getByIndex(columnIndex).get(primaryKey);
|
||||||
|
|
@ -346,8 +336,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Increment an element in the table. This implementation is awful - a functor would probably be better.
|
* Increment an element in the table. This implementation is awful - a functor would probably be better.
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
*/
|
*/
|
||||||
public void increment(Object primaryKey, String columnName) {
|
public void increment(Object primaryKey, String columnName) {
|
||||||
Object oldValue = get(primaryKey, columnName);
|
Object oldValue = get(primaryKey, columnName);
|
||||||
|
|
@ -375,8 +365,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Decrement an element in the table. This implementation is awful - a functor would probably be better.
|
* Decrement an element in the table. This implementation is awful - a functor would probably be better.
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
*/
|
*/
|
||||||
public void decrement(Object primaryKey, String columnName) {
|
public void decrement(Object primaryKey, String columnName) {
|
||||||
Object oldValue = get(primaryKey, columnName);
|
Object oldValue = get(primaryKey, columnName);
|
||||||
|
|
@ -404,9 +394,9 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Add the specified value to an element in the table
|
* Add the specified value to an element in the table
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @param valueToAdd the value to add
|
* @param valueToAdd the value to add
|
||||||
*/
|
*/
|
||||||
public void add(Object primaryKey, String columnName, Object valueToAdd) {
|
public void add(Object primaryKey, String columnName, Object valueToAdd) {
|
||||||
Object oldValue = get(primaryKey, columnName);
|
Object oldValue = get(primaryKey, columnName);
|
||||||
|
|
@ -434,8 +424,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Subtract the specified value from an element in the table
|
* Subtract the specified value from an element in the table
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @param valueToSubtract the value to subtract
|
* @param valueToSubtract the value to subtract
|
||||||
*/
|
*/
|
||||||
public void subtract(Object primaryKey, String columnName, Object valueToSubtract) {
|
public void subtract(Object primaryKey, String columnName, Object valueToSubtract) {
|
||||||
|
|
@ -464,9 +454,9 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Multiply the specified value to an element in the table
|
* Multiply the specified value to an element in the table
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @param valueToMultiply the value to multiply by
|
* @param valueToMultiply the value to multiply by
|
||||||
*/
|
*/
|
||||||
public void multiply(Object primaryKey, String columnName, Object valueToMultiply) {
|
public void multiply(Object primaryKey, String columnName, Object valueToMultiply) {
|
||||||
Object oldValue = get(primaryKey, columnName);
|
Object oldValue = get(primaryKey, columnName);
|
||||||
|
|
@ -494,9 +484,9 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Divide the specified value from an element in the table
|
* Divide the specified value from an element in the table
|
||||||
*
|
*
|
||||||
* @param primaryKey the primary key value
|
* @param primaryKey the primary key value
|
||||||
* @param columnName the name of the column
|
* @param columnName the name of the column
|
||||||
* @param valueToDivide the value to divide by
|
* @param valueToDivide the value to divide by
|
||||||
*/
|
*/
|
||||||
public void divide(Object primaryKey, String columnName, Object valueToDivide) {
|
public void divide(Object primaryKey, String columnName, Object valueToDivide) {
|
||||||
Object oldValue = get(primaryKey, columnName);
|
Object oldValue = get(primaryKey, columnName);
|
||||||
|
|
@ -524,9 +514,9 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Add two columns to each other and set the results to a third column
|
* Add two columns to each other and set the results to a third column
|
||||||
*
|
*
|
||||||
* @param columnToSet the column that should hold the results
|
* @param columnToSet the column that should hold the results
|
||||||
* @param augend the column that shall be the augend
|
* @param augend the column that shall be the augend
|
||||||
* @param addend the column that shall be the addend
|
* @param addend the column that shall be the addend
|
||||||
*/
|
*/
|
||||||
public void addColumns(String columnToSet, String augend, String addend) {
|
public void addColumns(String columnToSet, String augend, String addend) {
|
||||||
for (Object primaryKey : primaryKeyColumn) {
|
for (Object primaryKey : primaryKeyColumn) {
|
||||||
|
|
@ -542,8 +532,8 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Subtract one column from another and set the results to a third column
|
* Subtract one column from another and set the results to a third column
|
||||||
*
|
*
|
||||||
* @param columnToSet the column that should hold the results
|
* @param columnToSet the column that should hold the results
|
||||||
* @param minuend the column that shall be the minuend (the a in a - b)
|
* @param minuend the column that shall be the minuend (the a in a - b)
|
||||||
* @param subtrahend the column that shall be the subtrahend (the b in a - b)
|
* @param subtrahend the column that shall be the subtrahend (the b in a - b)
|
||||||
*/
|
*/
|
||||||
public void subtractColumns(String columnToSet, String minuend, String subtrahend) {
|
public void subtractColumns(String columnToSet, String minuend, String subtrahend) {
|
||||||
|
|
@ -561,8 +551,8 @@ public class GATKReportTable {
|
||||||
* Multiply two columns by each other and set the results to a third column
|
* Multiply two columns by each other and set the results to a third column
|
||||||
*
|
*
|
||||||
* @param columnToSet the column that should hold the results
|
* @param columnToSet the column that should hold the results
|
||||||
* @param multiplier the column that shall be the multiplier
|
* @param multiplier the column that shall be the multiplier
|
||||||
* @param multiplicand the column that shall be the multiplicand
|
* @param multiplicand the column that shall be the multiplicand
|
||||||
*/
|
*/
|
||||||
public void multiplyColumns(String columnToSet, String multiplier, String multiplicand) {
|
public void multiplyColumns(String columnToSet, String multiplier, String multiplicand) {
|
||||||
for (Object primaryKey : primaryKeyColumn) {
|
for (Object primaryKey : primaryKeyColumn) {
|
||||||
|
|
@ -578,9 +568,9 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Divide two columns by each other and set the results to a third column
|
* Divide two columns by each other and set the results to a third column
|
||||||
*
|
*
|
||||||
* @param columnToSet the column that should hold the results
|
* @param columnToSet the column that should hold the results
|
||||||
* @param numeratorColumn the column that shall be the numerator
|
* @param numeratorColumn the column that shall be the numerator
|
||||||
* @param denominatorColumn the column that shall be the denominator
|
* @param denominatorColumn the column that shall be the denominator
|
||||||
*/
|
*/
|
||||||
public void divideColumns(String columnToSet, String numeratorColumn, String denominatorColumn) {
|
public void divideColumns(String columnToSet, String numeratorColumn, String denominatorColumn) {
|
||||||
for (Object primaryKey : primaryKeyColumn) {
|
for (Object primaryKey : primaryKeyColumn) {
|
||||||
|
|
@ -595,11 +585,10 @@ public class GATKReportTable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the print width of the primary key column
|
* Return the print width of the primary key column
|
||||||
*
|
* @return the width of the primary key column
|
||||||
* @return the width of the primary key column
|
|
||||||
*/
|
*/
|
||||||
public int getPrimaryKeyColumnWidth() {
|
public int getPrimaryKeyColumnWidth() {
|
||||||
int maxWidth = getPrimaryKeyName().length();
|
int maxWidth = primaryKeyName.length();
|
||||||
|
|
||||||
for (Object primaryKey : primaryKeyColumn) {
|
for (Object primaryKey : primaryKeyColumn) {
|
||||||
int width = primaryKey.toString().length();
|
int width = primaryKey.toString().length();
|
||||||
|
|
@ -615,7 +604,7 @@ public class GATKReportTable {
|
||||||
/**
|
/**
|
||||||
* Write the table to the PrintStream, formatted nicely to be human-readable, AWK-able, and R-friendly.
|
* Write the table to the PrintStream, formatted nicely to be human-readable, AWK-able, and R-friendly.
|
||||||
*
|
*
|
||||||
* @param out the PrintStream to which the table should be written
|
* @param out the PrintStream to which the table should be written
|
||||||
*/
|
*/
|
||||||
public void write(PrintStream out) {
|
public void write(PrintStream out) {
|
||||||
// Get the column widths for everything
|
// Get the column widths for everything
|
||||||
|
|
@ -631,15 +620,13 @@ public class GATKReportTable {
|
||||||
// Emit the table header, taking into account the padding requirement if the primary key is a hidden column
|
// Emit the table header, taking into account the padding requirement if the primary key is a hidden column
|
||||||
boolean needsPadding = false;
|
boolean needsPadding = false;
|
||||||
if (primaryKeyDisplay) {
|
if (primaryKeyDisplay) {
|
||||||
out.printf(primaryKeyFormat, getPrimaryKeyName());
|
out.printf(primaryKeyFormat, primaryKeyName);
|
||||||
needsPadding = true;
|
needsPadding = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String columnName : columns.keySet()) {
|
for (String columnName : columns.keySet()) {
|
||||||
if (columns.get(columnName).isDisplayable()) {
|
if (columns.get(columnName).isDisplayable()) {
|
||||||
if (needsPadding) {
|
if (needsPadding) { out.printf(" "); }
|
||||||
out.printf(" ");
|
|
||||||
}
|
|
||||||
out.printf(columnFormats.get(columnName).getNameFormat(), columnName);
|
out.printf(columnFormats.get(columnName).getNameFormat(), columnName);
|
||||||
|
|
||||||
needsPadding = true;
|
needsPadding = true;
|
||||||
|
|
@ -658,9 +645,7 @@ public class GATKReportTable {
|
||||||
|
|
||||||
for (String columnName : columns.keySet()) {
|
for (String columnName : columns.keySet()) {
|
||||||
if (columns.get(columnName).isDisplayable()) {
|
if (columns.get(columnName).isDisplayable()) {
|
||||||
if (needsPadding) {
|
if (needsPadding) { out.printf(" "); }
|
||||||
out.printf(" ");
|
|
||||||
}
|
|
||||||
String value = columns.get(columnName).getStringValue(primaryKey);
|
String value = columns.get(columnName).getStringValue(primaryKey);
|
||||||
out.printf(columnFormats.get(columnName).getValueFormat(), value);
|
out.printf(columnFormats.get(columnName).getValueFormat(), value);
|
||||||
|
|
||||||
|
|
@ -690,49 +675,4 @@ public class GATKReportTable {
|
||||||
public GATKReportColumns getColumns() {
|
public GATKReportColumns getColumns() {
|
||||||
return columns;
|
return columns;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mergeRows(GATKReportTable input) {
|
|
||||||
/*
|
|
||||||
* This function is different from addRowsFrom because we will add the ability to sum,average, etc rows
|
|
||||||
* TODO: Add other combining algorithms
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Make sure the columns match AND the Primary Key
|
|
||||||
if (input.getColumns().keySet().equals(this.getColumns().keySet()) &&
|
|
||||||
input.getPrimaryKeyName().equals(this.getPrimaryKeyName())) {
|
|
||||||
this.addRowsFrom(input);
|
|
||||||
} else
|
|
||||||
throw new ReviewedStingException("Failed to combine GATKReportTable, columns don't match!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addRowsFrom(GATKReportTable input) {
|
|
||||||
// add column by column
|
|
||||||
|
|
||||||
// For every column
|
|
||||||
for (String columnKey : input.getColumns().keySet()) {
|
|
||||||
GATKReportColumn current = this.getColumns().get(columnKey);
|
|
||||||
GATKReportColumn toAdd = input.getColumns().get(columnKey);
|
|
||||||
// We want to take the current column and add all the values from input
|
|
||||||
|
|
||||||
// The column is a map of values <Key, Value>
|
|
||||||
for (Object rowKey : toAdd.keySet()) {
|
|
||||||
// We add every value from toAdd to the current
|
|
||||||
if (!current.containsKey(rowKey)) {
|
|
||||||
this.set(rowKey, columnKey, toAdd.get(rowKey));
|
|
||||||
System.out.printf("Putting row with PK: %s \n", rowKey);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
// TODO we should be able to handle combining data by adding, averaging, etc.
|
|
||||||
this.set(rowKey, columnKey, toAdd.get(rowKey));
|
|
||||||
|
|
||||||
System.out.printf("OVERWRITING Row with PK: %s \n", rowKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPrimaryKeyName() {
|
|
||||||
return primaryKeyName;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,23 +49,23 @@ public class GATKReportUnitTest extends BaseTest {
|
||||||
|
|
||||||
@DataProvider(name = "rightAlignValues")
|
@DataProvider(name = "rightAlignValues")
|
||||||
public Object[][] getRightAlignValues() {
|
public Object[][] getRightAlignValues() {
|
||||||
return new Object[][]{
|
return new Object[][] {
|
||||||
new Object[]{null, true},
|
new Object[] {null, true},
|
||||||
new Object[]{"null", true},
|
new Object[] {"null", true},
|
||||||
new Object[]{"NA", true},
|
new Object[] {"NA", true},
|
||||||
new Object[]{"0", true},
|
new Object[] {"0", true},
|
||||||
new Object[]{"0.0", true},
|
new Object[] {"0.0", true},
|
||||||
new Object[]{"-0", true},
|
new Object[] {"-0", true},
|
||||||
new Object[]{"-0.0", true},
|
new Object[] {"-0.0", true},
|
||||||
new Object[]{String.valueOf(Long.MAX_VALUE), true},
|
new Object[] {String.valueOf(Long.MAX_VALUE), true},
|
||||||
new Object[]{String.valueOf(Long.MIN_VALUE), true},
|
new Object[] {String.valueOf(Long.MIN_VALUE), true},
|
||||||
new Object[]{String.valueOf(Float.MIN_NORMAL), true},
|
new Object[] {String.valueOf(Float.MIN_NORMAL), true},
|
||||||
new Object[]{String.valueOf(Double.MAX_VALUE), true},
|
new Object[] {String.valueOf(Double.MAX_VALUE), true},
|
||||||
new Object[]{String.valueOf(Double.MIN_VALUE), true},
|
new Object[] {String.valueOf(Double.MIN_VALUE), true},
|
||||||
new Object[]{String.valueOf(Double.POSITIVE_INFINITY), true},
|
new Object[] {String.valueOf(Double.POSITIVE_INFINITY), true},
|
||||||
new Object[]{String.valueOf(Double.NEGATIVE_INFINITY), true},
|
new Object[] {String.valueOf(Double.NEGATIVE_INFINITY), true},
|
||||||
new Object[]{String.valueOf(Double.NaN), true},
|
new Object[] {String.valueOf(Double.NaN), true},
|
||||||
new Object[]{"hello", false}
|
new Object[] {"hello", false}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -73,96 +73,4 @@ public class GATKReportUnitTest extends BaseTest {
|
||||||
public void testIsRightAlign(String value, boolean expected) {
|
public void testIsRightAlign(String value, boolean expected) {
|
||||||
Assert.assertEquals(GATKReportColumn.isRightAlign(value), expected, "right align of '" + value + "'");
|
Assert.assertEquals(GATKReportColumn.isRightAlign(value), expected, "right align of '" + value + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testGATKReportGatherer() {
|
|
||||||
|
|
||||||
/*
|
|
||||||
GATKReportTable actual1 = new GATKReportTable("TableName", "Description");
|
|
||||||
actual1.addPrimaryKey("key");
|
|
||||||
actual1.addColumn("colA", 0);
|
|
||||||
actual1.addColumn("colB", 0);
|
|
||||||
actual1.set("row1", "colA", 1);
|
|
||||||
actual1.set("row1", "colB", 2);
|
|
||||||
|
|
||||||
GATKReportTable actual2 = new GATKReportTable("TableName", "Description");
|
|
||||||
actual2.addPrimaryKey("key");
|
|
||||||
actual2.addColumn("colA", 0);
|
|
||||||
actual2.addColumn("colB", 0);
|
|
||||||
actual2.set("row2", "colA", 3);
|
|
||||||
actual2.set("row2", "colB", 4);
|
|
||||||
|
|
||||||
GATKReportTable actual3 = new GATKReportTable("TableName", "Description");
|
|
||||||
actual3.addPrimaryKey("key");
|
|
||||||
actual3.addColumn("colA", 0);
|
|
||||||
actual3.addColumn("colB", 0);
|
|
||||||
actual3.set("row3", "colA", 5);
|
|
||||||
actual3.set("row3", "colB", 6);
|
|
||||||
|
|
||||||
actual1.mergeRows(actual2);
|
|
||||||
actual1.mergeRows(actual3);
|
|
||||||
actual1.write(System.out);
|
|
||||||
*/
|
|
||||||
|
|
||||||
GATKReportTable expected = new GATKReportTable("TableName", "Description");
|
|
||||||
expected.addPrimaryKey("key");
|
|
||||||
expected.addColumn("colA", 0);
|
|
||||||
expected.addColumn("colB", 0);
|
|
||||||
expected.set("row1", "colA", 1);
|
|
||||||
expected.set("row1", "colB", 2);
|
|
||||||
expected.set("row2", "colA", 3);
|
|
||||||
expected.set("row2", "colB", 4);
|
|
||||||
expected.set("row3", "colA", 5);
|
|
||||||
expected.set("row3", "colB", 6);
|
|
||||||
expected.write(System.out);
|
|
||||||
|
|
||||||
GATKReport report1, report2, report3;
|
|
||||||
report1 = new GATKReport();
|
|
||||||
report1.addTable("TableName", "Description");
|
|
||||||
report1.getTable("TableName").addPrimaryKey("key");
|
|
||||||
report1.getTable("TableName").addColumn("colA", 0);
|
|
||||||
report1.getTable("TableName").addColumn("colB", 0);
|
|
||||||
report1.getTable("TableName").set("row1", "colA", 1);
|
|
||||||
report1.getTable("TableName").set("row1", "colB", 2);
|
|
||||||
|
|
||||||
report2 = new GATKReport();
|
|
||||||
report2.addTable("TableName", "Description");
|
|
||||||
report2.getTable("TableName").addPrimaryKey("key");
|
|
||||||
report2.getTable("TableName").addColumn("colA", 0);
|
|
||||||
report2.getTable("TableName").addColumn("colB", 0);
|
|
||||||
report2.getTable("TableName").set("row2", "colA", 3);
|
|
||||||
report2.getTable("TableName").set("row2", "colB", 4);
|
|
||||||
|
|
||||||
report3 = new GATKReport();
|
|
||||||
report3.addTable("TableName", "Description");
|
|
||||||
report3.getTable("TableName").addPrimaryKey("key");
|
|
||||||
report3.getTable("TableName").addColumn("colA", 0);
|
|
||||||
report3.getTable("TableName").addColumn("colB", 0);
|
|
||||||
report3.getTable("TableName").set("row3", "colA", 5);
|
|
||||||
report3.getTable("TableName").set("row3", "colB", 6);
|
|
||||||
|
|
||||||
report1.combineWith(report2);
|
|
||||||
report1.combineWith(report3);
|
|
||||||
|
|
||||||
report1.print(System.out);
|
|
||||||
/*
|
|
||||||
File a = new File("/home/roger/tbls/a.tbl");
|
|
||||||
File b = new File("/home/roger/tbls/b.tbl");
|
|
||||||
File c = new File("/home/roger/tbls/c.tbl");
|
|
||||||
File out = new File("/home/roger/tbls/out.tbl");
|
|
||||||
|
|
||||||
|
|
||||||
List<File> FileList = new ArrayList<File>();
|
|
||||||
FileList.add(a);
|
|
||||||
FileList.add(b);
|
|
||||||
FileList.add(c);
|
|
||||||
|
|
||||||
GATKReportGatherer gatherer = new GATKReportGatherer();
|
|
||||||
gatherer.gather(FileList, out);
|
|
||||||
System.out.print(out);
|
|
||||||
*/
|
|
||||||
|
|
||||||
//Assert.assertEquals(1,1);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue