Fix a nasty bug in reading GATK reports with a single line

-- Old version would break during reading with (as usual) a cryptic error message
-- Fixed by avoiding collapsing into a single vector type from a matrix when you subset to a single row.  I believe this code confirms thats R is truly the worst programming language ever
This commit is contained in:
Mark DePristo 2012-09-08 19:45:56 -04:00
parent 5bce3a738d
commit 4a84ff4fce
1 changed files with 7 additions and 1 deletions

View File

@ -111,7 +111,13 @@ gsa.read.gatkreportv1 <- function(lines) {
headerRowCount = -1;
finishTable <- function() {
.gsa.assignGATKTableToEnvironment(tableName, tableHeader, tableRows[1:rowCount,], tableEnv);
if ( rowCount == 1 )
# good I hate R. Work around to avoid collapsing into an unstructured vector when
# there's only 1 row
sub <- t(as.matrix(tableRows[1:rowCount,]))
else
sub <- tableRows[1:rowCount,]
.gsa.assignGATKTableToEnvironment(tableName, tableHeader, sub, tableEnv);
}
for (line in lines) {