Merge branch 'master' of ssh://nickel.broadinstitute.org/humgen/gsa-scr1/gsa-engineering/git/unstable

This commit is contained in:
Guillermo del Angel 2012-03-28 16:00:38 -04:00
commit 62ee31afba
6 changed files with 53 additions and 55 deletions

View File

@ -177,11 +177,8 @@ public class GATKReport {
*/ */
public void print(PrintStream out) { public void print(PrintStream out) {
out.println(GATKREPORT_HEADER_PREFIX + getVersion().toString() + SEPARATOR + getTables().size()); out.println(GATKREPORT_HEADER_PREFIX + getVersion().toString() + SEPARATOR + getTables().size());
for (GATKReportTable table : tables.values()) { for (GATKReportTable table : tables.values())
if (table.getNumRows() > 0) { table.write(out);
table.write(out);
}
}
} }
public Collection<GATKReportTable> getTables() { public Collection<GATKReportTable> getTables() {

View File

@ -48,9 +48,9 @@ public enum GATKReportDataType {
Boolean("%[Bb]"), Boolean("%[Bb]"),
/** /**
* Used for byte and char value. Will display as a char so use printable values! * Used for char values. Will display as a char so use printable values!
*/ */
Byte("%[Cc]"), Character("%[Cc]"),
/** /**
* Used for float and double values. Will output a decimal with format %.8f unless otherwise specified. * Used for float and double values. Will output a decimal with format %.8f unless otherwise specified.
@ -58,7 +58,7 @@ public enum GATKReportDataType {
Decimal("%.*[EeFf]"), Decimal("%.*[EeFf]"),
/** /**
* Used for int, and long values. Will display the full number by default. * Used for int, byte, short, and long values. Will display the full number by default.
*/ */
Integer("%[Dd]"), Integer("%[Dd]"),
@ -97,17 +97,26 @@ public enum GATKReportDataType {
GATKReportDataType value; GATKReportDataType value;
if (object instanceof Boolean) { if (object instanceof Boolean) {
value = GATKReportDataType.Boolean; value = GATKReportDataType.Boolean;
} else if (object instanceof Byte || object instanceof Character) {
value = GATKReportDataType.Byte; } else if (object instanceof Character) {
} else if (object instanceof Float || object instanceof Double) { value = GATKReportDataType.Character;
} else if (object instanceof Float ||
object instanceof Double) {
value = GATKReportDataType.Decimal; value = GATKReportDataType.Decimal;
} else if (object instanceof Integer || object instanceof Long) {
} else if (object instanceof Integer ||
object instanceof Long ||
object instanceof Short ||
object instanceof Byte ) {
value = GATKReportDataType.Integer; value = GATKReportDataType.Integer;
} else if (object instanceof String) { } else if (object instanceof String) {
value = GATKReportDataType.String; value = GATKReportDataType.String;
} else { } else {
value = GATKReportDataType.Unknown; value = GATKReportDataType.Unknown;
//throw new ReviewedStingException("GATKReport could not convert the data object into a GATKReportDataType. Acceptable data objects are found in the documentation."); //throw new UserException("GATKReport could not convert the data object into a GATKReportDataType. Acceptable data objects are found in the documentation.");
} }
return value; return value;
} }
@ -140,8 +149,8 @@ public enum GATKReportDataType {
return 0.0D; return 0.0D;
case Boolean: case Boolean:
return false; return false;
case Byte: case Character:
return (byte) 0; return '0';
case Integer: case Integer:
return 0L; return 0L;
case String: case String:
@ -166,16 +175,7 @@ public enum GATKReportDataType {
case Boolean: case Boolean:
case Integer: case Integer:
return a.toString().equals(b.toString()); return a.toString().equals(b.toString());
case Byte: case Character:
// A mess that checks if the bytes and characters contain the same value
if ((a instanceof Character && b instanceof Character) ||
(a instanceof Byte && b instanceof Byte))
return a.toString().equals(b.toString());
else if (a instanceof Character && b instanceof Byte) {
return ((Character) a).charValue() == ((Byte) b).byteValue();
} else if (a instanceof Byte && b instanceof Character) {
return ((Byte) a).byteValue() == ((Character) b).charValue();
}
case String: case String:
default: default:
return a.equals(b); return a.equals(b);
@ -201,8 +201,8 @@ public enum GATKReportDataType {
return Long.parseLong(str); return Long.parseLong(str);
case String: case String:
return str; return str;
case Byte: case Character:
return (byte) str.toCharArray()[0]; return str.toCharArray()[0];
default: default:
return str; return str;
} }
@ -225,7 +225,7 @@ public enum GATKReportDataType {
return "%d"; return "%d";
case String: case String:
return "%s"; return "%s";
case Byte: case Character:
return "%c"; return "%c";
case Null: case Null:
default: default:

View File

@ -254,7 +254,7 @@ public class GATKReportTable {
* @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.
*/ */
public Object getPrimaryKey(String dottedColumnValues) { public Object getPrimaryKeyByData(String dottedColumnValues) {
Object key = findPrimaryKey(dottedColumnValues); Object key = findPrimaryKey(dottedColumnValues);
if (key == null) if (key == null)
throw new ReviewedStingException("Attempted to get non-existent GATKReportTable key for values: " + dottedColumnValues); throw new ReviewedStingException("Attempted to get non-existent GATKReportTable key for values: " + dottedColumnValues);
@ -411,9 +411,8 @@ public class GATKReportTable {
if (value == null) if (value == null)
value = "null"; value = "null";
// This code is bs. Why am do I have to conform to bad code // This code below is bs. Why am do I have to conform to bad code
// Below is some ode to convert a string into its appropriate type. // Below is some code to convert a string into its appropriate type.
// This is just Roger ranting
// If we got a string but the column is not a String type // If we got a string but the column is not a String type
Object newValue = null; Object newValue = null;
@ -431,7 +430,7 @@ public class GATKReportTable {
} catch (Exception e) { } catch (Exception e) {
} }
} }
if (column.getDataType().equals(GATKReportDataType.Byte) && ((String) value).length() == 1) { if (column.getDataType().equals(GATKReportDataType.Character) && ((String) value).length() == 1) {
newValue = ((String) value).charAt(0); newValue = ((String) value).charAt(0);
} }
@ -816,7 +815,7 @@ public class GATKReportTable {
out.println(); out.println();
} }
out.println(); out.println();
} }
public int getNumRows() { public int getNumRows() {
@ -877,8 +876,6 @@ public class GATKReportTable {
this.set(rowKey, columnKey, toAdd.get(rowKey)); this.set(rowKey, columnKey, toAdd.get(rowKey));
//System.out.printf("Putting row with PK: %s \n", rowKey); //System.out.printf("Putting row with PK: %s \n", rowKey);
} else { } else {
// TODO we should be able to handle combining data by adding, averaging, etc.
this.set(rowKey, columnKey, toAdd.get(rowKey)); this.set(rowKey, columnKey, toAdd.get(rowKey));
System.out.printf("OVERWRITING Row with PK: %s \n", rowKey); System.out.printf("OVERWRITING Row with PK: %s \n", rowKey);

View File

@ -94,8 +94,11 @@ public class RecalibrationReport {
BitSet key = entry.getKey(); BitSet key = entry.getKey();
RecalDatum otherDatum = entry.getValue(); RecalDatum otherDatum = entry.getValue();
RecalDatum thisDatum = thisTable.get(key); RecalDatum thisDatum = thisTable.get(key);
thisDatum.increment(otherDatum); // add the two datum objects into 'this' if (thisDatum == null)
thisDatum.resetCalculatedQualities(); // reset the empirical quality to make sure the user doesn't forget to recalculate it thisDatum = otherDatum; // sometimes the datum in other won't be present in 'this'. So just assign it!
else
thisDatum.increment(otherDatum); // add the two datum objects into 'this'
thisDatum.resetCalculatedQualities(); // reset the empirical quality to make sure the user doesn't forget to recalculate it
} }
} }
} }

View File

@ -34,21 +34,22 @@ import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
public class GATKReportUnitTest extends BaseTest { public class GATKReportUnitTest extends BaseTest {
@Test(enabled = false) @Test
public void testParse() throws Exception { public void testParse() throws Exception {
String reportPath = validationDataLocation + "exampleGATKReportv1.tbl"; String reportPath = validationDataLocation + "exampleGATKReportv1.tbl";
GATKReport report = new GATKReport(reportPath); GATKReport report = new GATKReport(reportPath);
Assert.assertEquals(report.getVersion(), GATKReportVersion.V1_0);
Assert.assertEquals(report.getTables().size(), 5);
GATKReportTable countVariants = report.getTable("CountVariants"); GATKReportTable countVariants = report.getTable("CountVariants");
//Assert.assertEquals(countVariants.getVersion(), GATKReportVersion.V0_1); Object countVariantsPK = countVariants.getPrimaryKeyByData("dbsnp.eval.none.all");
Object countVariantsPK = countVariants.getPrimaryKey("none.eval.none.all"); Assert.assertEquals(countVariants.get(countVariantsPK, "nProcessedLoci"), "63025520");
Assert.assertEquals(countVariants.get(countVariantsPK, "nProcessedLoci"), "100000"); Assert.assertEquals(countVariants.get(countVariantsPK, "nNoCalls"), "0");
Assert.assertEquals(countVariants.get(countVariantsPK, "nNoCalls"), "99872"); Assert.assertEquals(countVariants.get(countVariantsPK, "heterozygosity"), 4.73e-06);
GATKReportTable validationReport = report.getTable("ValidationReport"); GATKReportTable validationReport = report.getTable("ValidationReport");
//Assert.assertEquals(validationReport.getVersion(), GATKReportVersion.V0_1); Object validationReportPK = countVariants.getPrimaryKeyByData("dbsnp.eval.none.novel");
Object validationReportPK = countVariants.getPrimaryKey("none.eval.none.known"); Assert.assertEquals(validationReport.get(validationReportPK, "PPV"), Double.NaN);
Assert.assertEquals(validationReport.get(validationReportPK, "sensitivity"), "NaN");
} }
@DataProvider(name = "rightAlignValues") @DataProvider(name = "rightAlignValues")
@ -117,15 +118,15 @@ public class GATKReportUnitTest extends BaseTest {
report1.addTable("TableName", "Description"); report1.addTable("TableName", "Description");
report1.getTable("TableName").addPrimaryKey("id", displayPK); report1.getTable("TableName").addPrimaryKey("id", displayPK);
report1.getTable("TableName").addColumn("colA", GATKReportDataType.String.getDefaultValue(), "%s"); report1.getTable("TableName").addColumn("colA", GATKReportDataType.String.getDefaultValue(), "%s");
report1.getTable("TableName").addColumn("colB", GATKReportDataType.Byte.getDefaultValue(), "%c"); report1.getTable("TableName").addColumn("colB", GATKReportDataType.Character.getDefaultValue(), "%c");
report1.getTable("TableName").set(1, "colA", "NotNum"); report1.getTable("TableName").set(1, "colA", "NotNum");
report1.getTable("TableName").set(1, "colB", (byte) 64); report1.getTable("TableName").set(1, "colB", (char) 64);
report2 = new GATKReport(); report2 = new GATKReport();
report2.addTable("TableName", "Description"); report2.addTable("TableName", "Description");
report2.getTable("TableName").addPrimaryKey("id", displayPK); report2.getTable("TableName").addPrimaryKey("id", displayPK);
report2.getTable("TableName").addColumn("colA", GATKReportDataType.String.getDefaultValue(), "%s"); report2.getTable("TableName").addColumn("colA", GATKReportDataType.String.getDefaultValue(), "%s");
report2.getTable("TableName").addColumn("colB", GATKReportDataType.Byte.getDefaultValue(), "%c"); report2.getTable("TableName").addColumn("colB", GATKReportDataType.Character.getDefaultValue(), "%c");
report2.getTable("TableName").set(2, "colA", "df3"); report2.getTable("TableName").set(2, "colA", "df3");
report2.getTable("TableName").set(2, "colB", 'A'); report2.getTable("TableName").set(2, "colB", 'A');
@ -133,7 +134,7 @@ public class GATKReportUnitTest extends BaseTest {
report3.addTable("TableName", "Description"); report3.addTable("TableName", "Description");
report3.getTable("TableName").addPrimaryKey("id", displayPK); report3.getTable("TableName").addPrimaryKey("id", displayPK);
report3.getTable("TableName").addColumn("colA", GATKReportDataType.String.getDefaultValue(), "%s"); report3.getTable("TableName").addColumn("colA", GATKReportDataType.String.getDefaultValue(), "%s");
report3.getTable("TableName").addColumn("colB", GATKReportDataType.Byte.getDefaultValue(), "%c"); report3.getTable("TableName").addColumn("colB", GATKReportDataType.Character.getDefaultValue(), "%c");
report3.getTable("TableName").set(3, "colA", "df5f"); report3.getTable("TableName").set(3, "colA", "df5f");
report3.getTable("TableName").set(3, "colB", 'c'); report3.getTable("TableName").set(3, "colB", 'c');
@ -146,13 +147,13 @@ public class GATKReportUnitTest extends BaseTest {
table.addColumn("SomeInt", GATKReportDataType.Integer.getDefaultValue(), true, "%d"); table.addColumn("SomeInt", GATKReportDataType.Integer.getDefaultValue(), true, "%d");
table.addColumn("SomeFloat", GATKReportDataType.Decimal.getDefaultValue(), true, "%.16E"); table.addColumn("SomeFloat", GATKReportDataType.Decimal.getDefaultValue(), true, "%.16E");
table.addColumn("TrueFalse", false, true, "%B"); table.addColumn("TrueFalse", false, true, "%B");
table.set("12df", "SomeInt", 34); table.set("12df", "SomeInt", Byte.MAX_VALUE);
table.set("12df", "SomeFloat", 34.0); table.set("12df", "SomeFloat", 34.0);
table.set("12df", "TrueFalse", true); table.set("12df", "TrueFalse", true);
table.set("5f", "SomeInt", -1); table.set("5f", "SomeInt", Short.MAX_VALUE);
table.set("5f", "SomeFloat", 0.000003); table.set("5f", "SomeFloat", Double.MAX_VALUE);
table.set("5f", "TrueFalse", false); table.set("5f", "TrueFalse", false);
table.set("RZ", "SomeInt", 904948230958203958L); table.set("RZ", "SomeInt", Long.MAX_VALUE);
table.set("RZ", "SomeFloat", 535646345.657453464576); table.set("RZ", "SomeFloat", 535646345.657453464576);
table.set("RZ", "TrueFalse", true); table.set("RZ", "TrueFalse", true);

View File

@ -136,7 +136,7 @@ object PipelineTest extends BaseTest with Logging {
println(" value (min,target,max) table key metric") println(" value (min,target,max) table key metric")
for (validation <- evalSpec.validations) { for (validation <- evalSpec.validations) {
val table = report.getTable(validation.table) val table = report.getTable(validation.table)
val key = table.getPrimaryKey(validation.key) val key = table.getPrimaryKeyByData(validation.key)
val value = String.valueOf(table.get(key, validation.metric)) val value = String.valueOf(table.get(key, validation.metric))
val inRange = if (value == null) false else validation.inRange(value) val inRange = if (value == null) false else validation.inRange(value)
val flag = if (!inRange) "*" else " " val flag = if (!inRange) "*" else " "