Skip to content

Commit

Permalink
Merge remote-tracking branch 'unstable/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanbanks committed May 1, 2012
2 parents 2761da9 + 462450c commit ef08235
Show file tree
Hide file tree
Showing 288 changed files with 19,121 additions and 7,930 deletions.
4 changes: 2 additions & 2 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -955,8 +955,8 @@
<jvmarg value="-Dpipeline.run=${pipeline.run}" />
<jvmarg value="-Djava.io.tmpdir=${java.io.tmpdir}" />
<jvmarg line="${cofoja.jvm.args}"/>
<!-- <jvmarg value="-Xdebug"/> -->
<!-- <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/> -->
<!-- <jvmarg value="-Xdebug"/> -->
<!-- <jvmarg value="-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"/> -->

<classfileset dir="${java.public.test.classes}" includes="**/@{testtype}.class"/>
<classfileset dir="${java.private.test.classes}" erroronmissingdir="false">
Expand Down
2 changes: 1 addition & 1 deletion LICENSE → licensing/GATK1_LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2011 The Broad Institute
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
Expand Down
Binary file added licensing/GATK2_beta_license.doc
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
.gsa.assignGATKTableToEnvironment <- function(tableName, tableHeader, tableRows, tableEnv) {
d = data.frame(tableRows, row.names=NULL, stringsAsFactors=FALSE);
colnames(d) = tableHeader;

for (i in 1:ncol(d)) {
# use the general type.convert infrastructure of read.table to convert column data to R types
v = type.convert(d[,i])
d[,i] = v;
}

usedNames = ls(envir=tableEnv, pattern=tableName);

if (length(usedNames) > 0) {
tableName = paste(tableName, ".", length(usedNames), sep="");
}

assign(tableName, d, envir=tableEnv);
}

Expand All @@ -28,74 +28,163 @@

starts = c(1, columnStarts);
stops = c(columnStarts - 1, nchar(line));

sapply(line, splitStartStop)[,1];
}

# Load all GATKReport tables from a file
gsa.read.gatkreport <- function(filename) {
con = file(filename, "r", blocking = TRUE);
lines = readLines(con);
close(con);

# Old implementaton for v0.*
gsa.read.gatkreportv0 <- function(lines) {

tableEnv = new.env();

tableName = NA;
tableHeader = c();
tableRows = c();
version = NA;

for (line in lines) {
if (length(grep("^##:GATKReport.v", line, ignore.case=TRUE)) > 0) {
headerFields = unlist(strsplit(line, "[[:space:]]+"));

if (!is.na(tableName)) {
.gsa.assignGATKTableToEnvironment(tableName, tableHeader, tableRows, tableEnv);
}

tableName = headerFields[2];
tableHeader = c();
tableRows = c();

# For differences in versions see
# $STING_HOME/public/java/src/org/broadinstitute/sting/gatk/report/GATKReportVersion.java
if (length(grep("^##:GATKReport.v0.1[[:space:]]+", line, ignore.case=TRUE)) > 0) {
version = "v0.1";

} else if (length(grep("^##:GATKReport.v0.2[[:space:]]+", line, ignore.case=TRUE)) > 0) {
version = "v0.2";
columnStarts = c();

}

} else if (length(grep("^[[:space:]]*$", line)) > 0 | length(grep("^[[:space:]]*#", line)) > 0) {
# do nothing
} else if (!is.na(tableName)) {

if (version == "v0.1") {
row = unlist(strsplit(line, "[[:space:]]+"));

} else if (version == "v0.2") {
if (length(tableHeader) == 0) {
headerChars = unlist(strsplit(line, ""));
# Find the first position of non space characters, excluding the first character
columnStarts = intersect(grep("[[:space:]]", headerChars, invert=TRUE), grep("[[:space:]]", headerChars) + 1);
}

row = .gsa.splitFixedWidth(line, columnStarts);
}

if (length(tableHeader) == 0) {
tableHeader = row;
tableHeader = row;
} else {
tableRows = rbind(tableRows, row);
}
}
}

if (!is.na(tableName)) {
.gsa.assignGATKTableToEnvironment(tableName, tableHeader, tableRows, tableEnv);
}

gatkreport = as.list(tableEnv, all.names=TRUE);
}

# Load all GATKReport v1 tables from file
gsa.read.gatkreportv1 <- function(lines) {
#print("loading with optimized v1 reader")
nLines = length(lines)
tableEnv = new.env();

tableName = NA;
tableHeader = c();
tableRows = NULL;
version = "";
rowCount = 0
headerRowCount = -1;

finishTable <- function() {
.gsa.assignGATKTableToEnvironment(tableName, tableHeader, tableRows[1:rowCount,], tableEnv);
}

for (line in lines) {

if (length(grep("^#:GATKReport.v1", line, ignore.case=TRUE)) > 0) {
version = "v1.0";
headerRowCount = 0;
}

if ( (headerRowCount %% 2 == 1) && (version == "v1.0") ) {
#print("Trying to start a table with line:");
#print(line);

#Get table header
headerFields = unlist(strsplit(line, ":"));

if (!is.na(tableName)) {
finishTable()
}

tableName = headerFields[3];
tableHeader = c();
tableRows = NULL
rowCount = 0

columnStarts = c();
}

if (length(grep("^#:GATKTable", line, ignore.case=TRUE)) > 0) {
headerRowCount = headerRowCount+1;
#print("Header Row count is at:")
#print(headerRowCount);
} else if (!is.na(tableName)) {
if ( version == "v1.0") {
if (length(tableHeader) == 0) {
headerChars = unlist(strsplit(line, ""));
# Find the first position of non space characters, excluding the first character
columnStarts = intersect(grep("[[:space:]]", headerChars, invert=TRUE), grep("[[:space:]]", headerChars) + 1);
tableRows = matrix(nrow=nLines, ncol=length(columnStarts)+1);
}

row = .gsa.splitFixedWidth(line, columnStarts);
}

if (length(tableHeader) == 0) {
tableHeader = row;
} else if ( nchar(line) > 0 ) {
rowCount = rowCount + 1
tableRows[rowCount,] <- row
}
}
}

if (!is.na(tableName)) {
finishTable()
}

gatkreport = as.list(tableEnv, all.names=TRUE);
}

# Load all GATKReport tables from a file
gsa.read.gatkreport <- function(filename) {
con = file(filename, "r", blocking = TRUE);
lines = readLines(con);
close(con);

# get first line
line = lines[1];

if (length(grep("^#:GATKReport.v1", line, ignore.case=TRUE)) > 0) {
gsa.read.gatkreportv1(lines)
}
else if (length(grep("^##:GATKReport.v0", line, ignore.case=TRUE)) > 0) {
gsa.read.gatkreportv0(lines)
}
}
Loading

0 comments on commit ef08235

Please sign in to comment.