rbbt-util 5.21.86 → 5.21.87

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14c71affcd04cfc765824f452e0455dd0a59befe
4
- data.tar.gz: 57821f59ec541b8cb173fbcf64861ca793a0a032
3
+ metadata.gz: 88ef613a2ceb07588403878b6f87982221a4d7fb
4
+ data.tar.gz: d9d54cd91f619d9bead8d8d072f115eff635774b
5
5
  SHA512:
6
- metadata.gz: 81cd59fb9a32bddf24ca25a7bb614faab5ced6bfdff678454b688992674c84029312d8c52dc2a29f9c3511945daf6be91e90375ba8b661e184a08330229be203
7
- data.tar.gz: 2e45a91dcd62e667d9f16e83ff1c20f58bbf2111ab631e82a0e287cfa97a8e5c46af6fe6f0c79f75b99c30d6fceb62d91dcca2fe72eec4bc28d313386483df1f
6
+ metadata.gz: 65fc0ea4c70a2ca5902e786addebf0741d11f6ad402087cf1e8516b953365fa1ae8c42091185a8a6d6352e710cb1b7269dba00c7c149ea8b55bfb93445865c28
7
+ data.tar.gz: f5a050a28355d674cbb95d887686bb13a74feac6ecd1540548912acc34ac4442c829e103223871d9e98d2a925324562734c829237df05de924ae5bddebc04b10
data/lib/rbbt/tsv/util.rb CHANGED
@@ -237,7 +237,7 @@ module TSV
237
237
  new[k] = [v]
238
238
  end
239
239
  when :list
240
- self
240
+ return self
241
241
  end
242
242
  self.annotate(new)
243
243
  new.type = :list
@@ -92,6 +92,7 @@ end
92
92
  end
93
93
 
94
94
  def self.is_filename?(string)
95
+ return true if defined? PATH and Path === string
95
96
  return true if string.respond_to? :exists
96
97
  return true if String === string and string.length < 265 and File.exist? string
97
98
  return false
data/share/Rlib/util.R CHANGED
@@ -89,29 +89,32 @@ rbbt.load.data <- function(filename, sep = "\t", ...){
89
89
 
90
90
  rbbt.flat.tsv <- function(filename, sep = "\t", comment.char ="#", ...){
91
91
  f = file(filename, 'r');
92
- headers = readLines(f, 1);
93
- if (length(grep("^#: ", headers)) > 0){
94
- headers = readLines(f, 1);
92
+ line = readLines(f, 1);
93
+ if (length(grep("^#: ", line)) > 0){
94
+ line = readLines(f, 1);
95
+ }
96
+ if (comment.char=="" || length(grep("^# ", line)) > 0){
97
+ line = readLines(f, 1);
95
98
  }
96
99
  result = list();
97
100
  while( TRUE ){
98
- line = readLines(f, 1);
99
- if (length(line) == 0){ break;}
100
101
  parts = unlist(strsplit(line, sep, fixed = TRUE));
101
102
  id = parts[1];
102
103
  result[[id]] = parts[2:length(parts)];
104
+ line = readLines(f, 1);
105
+ if (length(line) == 0){ break;}
103
106
  }
104
107
  close(f);
105
108
  return(result);
106
109
  }
107
110
 
108
- rbbt.tsv.columns <- function(filename, sep="\t"){
111
+ rbbt.tsv.columns <- function(filename, sep="\t", comment.char="#"){
109
112
  f = file(filename, 'r');
110
113
  headers = readLines(f, 1);
111
114
  if (length(grep("^#:", headers)) > 0){
112
115
  headers = readLines(f, 1);
113
116
  }
114
- if (length(grep("^#", headers)) > 0){
117
+ if (comment.char == "" || length(grep("^#", headers)) > 0){
115
118
  fields = strsplit(headers, sep)[[1]];
116
119
  close(f);
117
120
  return(fields);
@@ -121,9 +124,14 @@ rbbt.tsv.columns <- function(filename, sep="\t"){
121
124
  }
122
125
 
123
126
  rbbt.tsv <- function(filename, sep = "\t", comment.char ="#", row.names=1, check.names=FALSE, fill=TRUE, as.is=TRUE, quote='', ...){
124
- data=read.table(file=filename, sep=sep, fill=fill, as.is=as.is, quote=quote, row.names= row.names, comment.char = comment.char, ...);
127
+
128
+ if (comment.char == ""){
129
+ data=read.table(file=filename, sep=sep, fill=fill, as.is=as.is, quote=quote, row.names= row.names, comment.char = comment.char, skip=1, ...);
130
+ }else{
131
+ data=read.table(file=filename, sep=sep, fill=fill, as.is=as.is, quote=quote, row.names= row.names, comment.char = comment.char, ...);
132
+ }
125
133
 
126
- columns = rbbt.tsv.columns(filename, sep)
134
+ columns = rbbt.tsv.columns(filename, sep, comment.char=comment.char)
127
135
  if (! is.null(columns)){
128
136
  names(data) <- columns[2:length(columns)];
129
137
  }
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.86
4
+ version: 5.21.87
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miguel Vazquez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake