Mercurial > repos > stevecassidy > wrassp
view outputAssp.R @ 2:6f4db0e89117 draft
planemo upload commit 2acf1e5f5efe0ee3ef51a611a3f7c94ce73d3b89-dirty
| author | stevecassidy |
|---|---|
| date | Thu, 08 Dec 2016 01:45:31 -0500 |
| parents | dbcf9bc275e3 |
| children |
line wrap: on
line source
assp_to_est <- function(assp, outfile) { # convert to a dataframe result <- data.frame(assp[1]) for(idx in seq(2,length(attr(assp,'names')))) { result <- cbind(result, assp[idx]) } # add a column of timestamps start <- attr(assp, 'startTime') rate <- attr(assp, 'sampleRate') sampletime <- seq(start, by=1/rate, length.out=nrow(result)) # and a column of 1s for some reason #one <- rep(1, nrow(result)) result <- cbind(sampletime, result) # write header #write("EST_File Track", file=outfile) #write("DataType ascii", file=outfile, append=T) #write("BreaksPresent true", file=outfile, append=T) #write(paste("NumFrames", nrow(result)), file=outfile, append=T) #count <- 0 # count overall number of columns #vcount <- 1 # count variables in assp obj #for(name in attr(assp,'names')) { # for (coln in seq(ncol(data.frame(assp[vcount])))) { # colname = paste(name, coln, sep="_") # write(c(paste("Channel_", count, " ", colname, sep="")), file=outfile, append=T) # count <- count+1 # } # vcount <- vcount+1 #} #write(paste("NumChannels", count), file=outfile, append=T) #write("EST_Header_End", file=outfile, append=T) write.table(result, file=outfile, sep="\t", quote=F, row.names=F, col.names=T, append=F) }
