comparison outputAssp.R @ 1:dbcf9bc275e3 draft

planemo upload commit 063e049d569aeb45e1008cbf044f2dad850eca3d-dirty
author stevecassidy
date Wed, 07 Dec 2016 19:10:51 -0500
parents
children
comparison
equal deleted inserted replaced
0:6d6dc275b107 1:dbcf9bc275e3
1 assp_to_est <- function(assp, outfile) {
2
3 # convert to a dataframe
4 result <- data.frame(assp[1])
5 for(idx in seq(2,length(attr(assp,'names')))) {
6 result <- cbind(result, assp[idx])
7 }
8 # add a column of timestamps
9 start <- attr(assp, 'startTime')
10 rate <- attr(assp, 'sampleRate')
11 sampletime <- seq(start, by=1/rate, length.out=nrow(result))
12 # and a column of 1s for some reason
13 #one <- rep(1, nrow(result))
14 result <- cbind(sampletime, result)
15
16 # write header
17 #write("EST_File Track", file=outfile)
18 #write("DataType ascii", file=outfile, append=T)
19 #write("BreaksPresent true", file=outfile, append=T)
20 #write(paste("NumFrames", nrow(result)), file=outfile, append=T)
21
22 #count <- 0 # count overall number of columns
23 #vcount <- 1 # count variables in assp obj
24 #for(name in attr(assp,'names')) {
25 # for (coln in seq(ncol(data.frame(assp[vcount])))) {
26 # colname = paste(name, coln, sep="_")
27 # write(c(paste("Channel_", count, " ", colname, sep="")), file=outfile, append=T)
28 # count <- count+1
29 # }
30 # vcount <- vcount+1
31 #}
32 #write(paste("NumChannels", count), file=outfile, append=T)
33 #write("EST_Header_End", file=outfile, append=T)
34
35
36 write.table(result, file=outfile, sep="\t", quote=F, row.names=F, col.names=T, append=F)
37 }