rbbt-util 5.21.53 → 5.21.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/share/Rlib/util.R +23 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31829ae881d088a7cd47adc6dfc795b6689a3d4b
4
- data.tar.gz: 46740907e85c0bb6c868e1a6f33fb895e80bf602
3
+ metadata.gz: 2694c3dd908e3b5711942aa887313585c82eb817
4
+ data.tar.gz: 3f2383f88770be0bb1dabab5dd365f46ce46752f
5
5
  SHA512:
6
- metadata.gz: b819808000c038d237a9aa2b106be23e77c1ed4de6f6f5f523bad424bd20a2871c0448c046e33dbb68f38f1c87731a56ce3233622b1e764508bdb29528242433
7
- data.tar.gz: 1267267bdefc38cd739d0713ee00078db20623b3c5d6a3c9ea31a0dede5469da41ffe9b30a3412c13bd6cefc6452e5584bde00687691596d7c3b0877f317501f
6
+ metadata.gz: dd8982733ba669ea67403459e8fbe0742c5909cffedfe1725629bd704c716669ec64a3f177d00ed2daf6d85af83b8ed6a25fd1cda23f92b88e40c1c343d53d68
7
+ data.tar.gz: a2f22166721bd4a0d752afaf1062df290524fabe899e4fb383b85a2edfd5d4b27e3611781b5076bd26d73f16f9e123cdc12fb1f84df12887b7f50c646ae5e7b8
data/share/Rlib/util.R CHANGED
@@ -97,8 +97,7 @@ rbbt.flat.tsv <- function(filename, sep = "\t", comment.char ="#", ...){
97
97
  return(result);
98
98
  }
99
99
 
100
- rbbt.tsv <- function(filename, sep = "\t", comment.char ="#", row.names=1, check.names=FALSE, fill=TRUE, as.is=TRUE, quote='', ...){
101
- data=read.table(file=filename, sep=sep, fill=fill, as.is=as.is, quote=quote, row.names= row.names, comment.char = comment.char, ...);
100
+ rbbt.tsv.columns <- function(filename, sep="\t"){
102
101
  f = file(filename, 'r');
103
102
  headers = readLines(f, 1);
104
103
  if (length(grep("^#:", headers)) > 0){
@@ -106,13 +105,33 @@ rbbt.tsv <- function(filename, sep = "\t", comment.char ="#", row.names=1, check
106
105
  }
107
106
  if (length(grep("^#", headers)) > 0){
108
107
  fields = strsplit(headers, sep)[[1]];
109
- fields = fields[2:length(fields)];
110
- names(data) <- fields;
108
+ close(f);
109
+ return(fields);
111
110
  }
112
111
  close(f);
112
+ return(NULL);
113
+ }
114
+
115
+ rbbt.tsv <- function(filename, sep = "\t", comment.char ="#", row.names=1, check.names=FALSE, fill=TRUE, as.is=TRUE, quote='', ...){
116
+ data=read.table(file=filename, sep=sep, fill=fill, as.is=as.is, quote=quote, row.names= row.names, comment.char = comment.char, ...);
117
+
118
+ columns = rbbt.tsv.columns(filename, sep)
119
+ if (! is.null(columns)){
120
+ names(data) <- columns[2:length(columns)];
121
+ }
122
+
113
123
  return(data);
114
124
  }
115
125
 
126
+ rbbt.tsv.numeric <- function(filename, sep="\t", ...){
127
+
128
+ columns = rbbt.tsv.columns(filename, sep)
129
+
130
+ colClasses = c('character', rep('numeric', length(columns) - 1))
131
+
132
+ return(rbbt.tsv(filename, sep, colClasses= colClasses, ...))
133
+ }
134
+
116
135
  rbbt.tsv2matrix <- function(data){
117
136
  new <- data.matrix(data);
118
137
  colnames(new) <- colnames(data);
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbbt-util
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.21.53
4
+ version: 5.21.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-09 00:00:00.000000000 Z
11
+ date: 2016-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake