rbbt-util 5.21.19 → 5.21.20
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rbbt/tsv/accessor.rb +35 -1
- data/share/rbbt_commands/tsv/unzip +3 -1
- data/share/rbbt_commands/tsv/zip +47 -0
- metadata +63 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0df0c7ae6b0b29814a176c029ed4c9f20e13307c
|
4
|
+
data.tar.gz: 228920d67af31815ef453b4f05b0c1bc32cf1175
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0af021e82639371b123a9b04ae7d1b89541bf19e7c446fd8ce38ecd25066d06f585d36872edb636e61856b82e3e45b67cc2aa67ffdb236904f81e7d93ca8f160
|
7
|
+
data.tar.gz: c1a0e4a399e442a2d8545d71f28636ffcccb0fb1c60422c84c47806cef041738fa22ed10fe9aeb7fd5a347c635e837a025c1df4c3f402c42e520d100482321fd
|
data/lib/rbbt/tsv/accessor.rb
CHANGED
@@ -695,7 +695,7 @@ Example:
|
|
695
695
|
end
|
696
696
|
|
697
697
|
if self.key_field and self.fields
|
698
|
-
new.key_field = [self.key_field, self.fields[field_pos]] *
|
698
|
+
new.key_field = [self.key_field, self.fields[field_pos]] * sep
|
699
699
|
new_fields = self.fields.dup
|
700
700
|
new_fields.delete_at field_pos
|
701
701
|
new.fields = new_fields
|
@@ -703,5 +703,39 @@ Example:
|
|
703
703
|
|
704
704
|
new
|
705
705
|
end
|
706
|
+
|
707
|
+
def zip(field = 0, merge = false, sep = ":")
|
708
|
+
new = {}
|
709
|
+
self.annotate new
|
710
|
+
|
711
|
+
new.type = :double if merge
|
712
|
+
|
713
|
+
new.with_unnamed do
|
714
|
+
if merge
|
715
|
+
self.through do |key,values|
|
716
|
+
new_key, new_value = key.split(sep)
|
717
|
+
new_values = values + [[new_value]]
|
718
|
+
if new.include? new_key
|
719
|
+
new[new_key] = Misc.zip_fields(Misc.zip_fields(new[new_key]) << new_values)
|
720
|
+
else
|
721
|
+
new[new_key] = new_values
|
722
|
+
end
|
723
|
+
end
|
724
|
+
else
|
725
|
+
self.through do |key,values|
|
726
|
+
new_key, new_value = key.split(sep)
|
727
|
+
new_values = values + [new_value]
|
728
|
+
new[new_key] = new_values
|
729
|
+
end
|
730
|
+
end
|
731
|
+
end
|
732
|
+
|
733
|
+
if self.key_field and self.fields
|
734
|
+
new.key_field = self.key_field.partition(sep).first
|
735
|
+
new.fields = new.fields + [field]
|
736
|
+
end
|
737
|
+
|
738
|
+
new
|
739
|
+
end
|
706
740
|
end
|
707
741
|
|
@@ -15,6 +15,7 @@ Display summary information. Works with Tokyocabinet HDB and BDB as well.
|
|
15
15
|
-tch--tokyocabinet File is a TC HDB
|
16
16
|
-tcb--tokyocabinet_bd File is a TC BDB
|
17
17
|
-hh--header_hash* Change the character used to mark the header line (defaults to #)
|
18
|
+
-zs--zip_sep* Separator between zipped fields
|
18
19
|
-f--field* Field to unzip
|
19
20
|
-m--merge Merge lines
|
20
21
|
-h--help Help
|
@@ -28,6 +29,7 @@ file = STDIN if file == '-'
|
|
28
29
|
|
29
30
|
field = options[:field] || 0
|
30
31
|
merge = options[:merge] || false
|
32
|
+
zs = options[:zip_sep] || ":"
|
31
33
|
|
32
34
|
case
|
33
35
|
when options[:tokyocabinet]
|
@@ -42,4 +44,4 @@ else
|
|
42
44
|
tsv = TSV.open(file, {:type => :double}.merge(options))
|
43
45
|
end
|
44
46
|
|
45
|
-
puts tsv.unzip(field, merge).to_s
|
47
|
+
puts tsv.unzip(field, merge, zs).to_s
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rbbt-util'
|
4
|
+
require 'rbbt/util/simpleopt'
|
5
|
+
|
6
|
+
$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands
|
7
|
+
|
8
|
+
options = SOPT.setup <<EOF
|
9
|
+
Zip fields in a TSV file
|
10
|
+
|
11
|
+
$ rbbt tsv zip [options] file.tsv <new_field>
|
12
|
+
|
13
|
+
Display summary information. Works with Tokyocabinet HDB and BDB as well.
|
14
|
+
|
15
|
+
-tch--tokyocabinet File is a TC HDB
|
16
|
+
-tcb--tokyocabinet_bd File is a TC BDB
|
17
|
+
-hh--header_hash* Change the character used to mark the header line (defaults to #)
|
18
|
+
-zs--zip_sep* Separator between zipped fields
|
19
|
+
-f--field* Field to unzip
|
20
|
+
-m--merge Merge lines
|
21
|
+
-h--help Help
|
22
|
+
EOF
|
23
|
+
|
24
|
+
SOPT.usage if options[:help]
|
25
|
+
|
26
|
+
file = ARGV.shift
|
27
|
+
|
28
|
+
file = STDIN if file == '-'
|
29
|
+
|
30
|
+
field = options[:field] || 0
|
31
|
+
merge = options[:merge] || false
|
32
|
+
zs = options[:zip_sep] || ":"
|
33
|
+
|
34
|
+
case
|
35
|
+
when options[:tokyocabinet]
|
36
|
+
tsv = Persist.open_tokyocabinet(file, false)
|
37
|
+
when options[:tokyocabinet_bd]
|
38
|
+
tsv = Persist.open_tokyocabinet(file, false, nil, TokyoCabinet::BDB)
|
39
|
+
else
|
40
|
+
if String === file
|
41
|
+
file = file.dup
|
42
|
+
Path.setup(File.expand_path(file))
|
43
|
+
end
|
44
|
+
tsv = TSV.open(file, {:type => :double}.merge(options))
|
45
|
+
end
|
46
|
+
|
47
|
+
puts tsv.zip(field, merge, zs).to_s
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbbt-util
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.21.
|
4
|
+
version: 5.21.20
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Miguel Vazquez
|
@@ -364,6 +364,7 @@ files:
|
|
364
364
|
- share/rbbt_commands/tsv/subset
|
365
365
|
- share/rbbt_commands/tsv/unzip
|
366
366
|
- share/rbbt_commands/tsv/values
|
367
|
+
- share/rbbt_commands/tsv/zip
|
367
368
|
- share/rbbt_commands/watch
|
368
369
|
- share/rbbt_commands/workflow/cmd
|
369
370
|
- share/rbbt_commands/workflow/example
|
@@ -486,82 +487,82 @@ signing_key:
|
|
486
487
|
specification_version: 4
|
487
488
|
summary: Utilities for the Ruby Bioinformatics Toolkit (rbbt)
|
488
489
|
test_files:
|
489
|
-
- test/
|
490
|
+
- test/test_helper.rb
|
490
491
|
- test/rbbt/resource/test_path.rb
|
491
|
-
- test/rbbt/
|
492
|
-
- test/rbbt/
|
493
|
-
- test/rbbt/
|
494
|
-
- test/rbbt/
|
495
|
-
- test/rbbt/
|
496
|
-
- test/rbbt/util/
|
492
|
+
- test/rbbt/association/test_item.rb
|
493
|
+
- test/rbbt/association/test_database.rb
|
494
|
+
- test/rbbt/association/test_open.rb
|
495
|
+
- test/rbbt/association/test_index.rb
|
496
|
+
- test/rbbt/association/test_util.rb
|
497
|
+
- test/rbbt/util/test_concurrency.rb
|
497
498
|
- test/rbbt/util/test_log.rb
|
499
|
+
- test/rbbt/util/test_chain_methods.rb
|
500
|
+
- test/rbbt/util/test_simpleopt.rb
|
501
|
+
- test/rbbt/util/simpleopt/test_parse.rb
|
502
|
+
- test/rbbt/util/simpleopt/test_get.rb
|
503
|
+
- test/rbbt/util/simpleopt/test_setup.rb
|
504
|
+
- test/rbbt/util/test_cmd.rb
|
505
|
+
- test/rbbt/util/test_semaphore.rb
|
506
|
+
- test/rbbt/util/concurrency/test_threads.rb
|
507
|
+
- test/rbbt/util/concurrency/processes/test_socket.rb
|
508
|
+
- test/rbbt/util/concurrency/test_processes.rb
|
509
|
+
- test/rbbt/util/test_tmpfile.rb
|
498
510
|
- test/rbbt/util/test_open.rb
|
511
|
+
- test/rbbt/util/test_filecache.rb
|
512
|
+
- test/rbbt/util/R/test_eval.rb
|
513
|
+
- test/rbbt/util/R/test_model.rb
|
514
|
+
- test/rbbt/util/test_simpleDSL.rb
|
515
|
+
- test/rbbt/util/log/test_progress.rb
|
516
|
+
- test/rbbt/util/test_colorize.rb
|
517
|
+
- test/rbbt/util/test_R.rb
|
499
518
|
- test/rbbt/util/misc/test_lock.rb
|
500
|
-
- test/rbbt/util/misc/test_multipart_payload.rb
|
501
|
-
- test/rbbt/util/misc/test_bgzf.rb
|
502
519
|
- test/rbbt/util/misc/test_pipes.rb
|
520
|
+
- test/rbbt/util/misc/test_bgzf.rb
|
503
521
|
- test/rbbt/util/misc/test_omics.rb
|
504
|
-
- test/rbbt/util/
|
505
|
-
- test/rbbt/util/test_R.rb
|
506
|
-
- test/rbbt/util/log/test_progress.rb
|
507
|
-
- test/rbbt/util/test_colorize.rb
|
508
|
-
- test/rbbt/util/test_simpleopt.rb
|
522
|
+
- test/rbbt/util/misc/test_multipart_payload.rb
|
509
523
|
- test/rbbt/util/test_excel2tsv.rb
|
510
|
-
- test/rbbt/util/test_filecache.rb
|
511
|
-
- test/rbbt/util/concurrency/test_processes.rb
|
512
|
-
- test/rbbt/util/concurrency/test_threads.rb
|
513
|
-
- test/rbbt/util/concurrency/processes/test_socket.rb
|
514
|
-
- test/rbbt/util/test_semaphore.rb
|
515
524
|
- test/rbbt/util/test_misc.rb
|
516
|
-
- test/rbbt/util/test_tmpfile.rb
|
517
|
-
- test/rbbt/util/R/test_model.rb
|
518
|
-
- test/rbbt/util/R/test_eval.rb
|
519
|
-
- test/rbbt/test_packed_index.rb
|
520
|
-
- test/rbbt/entity/test_identifiers.rb
|
521
|
-
- test/rbbt/test_association.rb
|
522
|
-
- test/rbbt/knowledge_base/test_traverse.rb
|
523
|
-
- test/rbbt/knowledge_base/test_registry.rb
|
524
|
-
- test/rbbt/knowledge_base/test_entity.rb
|
525
|
-
- test/rbbt/knowledge_base/test_enrichment.rb
|
526
|
-
- test/rbbt/knowledge_base/test_syndicate.rb
|
527
|
-
- test/rbbt/knowledge_base/test_query.rb
|
528
|
-
- test/rbbt/test_resource.rb
|
529
525
|
- test/rbbt/test_entity.rb
|
530
|
-
- test/rbbt/test_knowledge_base.rb
|
531
|
-
- test/rbbt/annotations/test_util.rb
|
532
|
-
- test/rbbt/association/test_index.rb
|
533
|
-
- test/rbbt/association/test_item.rb
|
534
|
-
- test/rbbt/association/test_open.rb
|
535
|
-
- test/rbbt/association/test_util.rb
|
536
|
-
- test/rbbt/association/test_database.rb
|
537
|
-
- test/rbbt/test_tsv.rb
|
538
526
|
- test/rbbt/workflow/step/test_dependencies.rb
|
539
|
-
- test/rbbt/workflow/test_task.rb
|
540
|
-
- test/rbbt/workflow/test_step.rb
|
541
527
|
- test/rbbt/workflow/test_doc.rb
|
542
|
-
- test/rbbt/
|
543
|
-
- test/rbbt/
|
544
|
-
- test/rbbt/
|
545
|
-
- test/rbbt/
|
546
|
-
- test/rbbt/
|
547
|
-
- test/rbbt/
|
548
|
-
- test/rbbt/persist/tsv/test_sharder.rb
|
549
|
-
- test/rbbt/persist/tsv/test_cdb.rb
|
550
|
-
- test/rbbt/persist/tsv/test_tokyocabinet.rb
|
551
|
-
- test/rbbt/persist/tsv/test_leveldb.rb
|
552
|
-
- test/rbbt/tsv/test_field_index.rb
|
528
|
+
- test/rbbt/workflow/test_step.rb
|
529
|
+
- test/rbbt/workflow/test_task.rb
|
530
|
+
- test/rbbt/test_association.rb
|
531
|
+
- test/rbbt/test_knowledge_base.rb
|
532
|
+
- test/rbbt/tsv/parallel/test_traverse.rb
|
533
|
+
- test/rbbt/tsv/parallel/test_through.rb
|
553
534
|
- test/rbbt/tsv/test_parallel.rb
|
554
|
-
- test/rbbt/tsv/
|
555
|
-
- test/rbbt/tsv/test_matrix.rb
|
535
|
+
- test/rbbt/tsv/test_accessor.rb
|
556
536
|
- test/rbbt/tsv/test_change_id.rb
|
557
|
-
- test/rbbt/tsv/test_parser.rb
|
558
537
|
- test/rbbt/tsv/test_stream.rb
|
559
|
-
- test/rbbt/tsv/test_util.rb
|
560
|
-
- test/rbbt/tsv/test_accessor.rb
|
561
538
|
- test/rbbt/tsv/test_filter.rb
|
539
|
+
- test/rbbt/tsv/test_matrix.rb
|
562
540
|
- test/rbbt/tsv/test_attach.rb
|
563
541
|
- test/rbbt/tsv/test_manipulate.rb
|
564
|
-
- test/rbbt/tsv/
|
565
|
-
- test/rbbt/tsv/
|
542
|
+
- test/rbbt/tsv/test_field_index.rb
|
543
|
+
- test/rbbt/tsv/test_index.rb
|
544
|
+
- test/rbbt/tsv/test_util.rb
|
545
|
+
- test/rbbt/tsv/test_parser.rb
|
546
|
+
- test/rbbt/test_packed_index.rb
|
547
|
+
- test/rbbt/test_persist.rb
|
566
548
|
- test/rbbt/test_fix_width_table.rb
|
567
|
-
- test/
|
549
|
+
- test/rbbt/knowledge_base/test_traverse.rb
|
550
|
+
- test/rbbt/knowledge_base/test_entity.rb
|
551
|
+
- test/rbbt/knowledge_base/test_query.rb
|
552
|
+
- test/rbbt/knowledge_base/test_enrichment.rb
|
553
|
+
- test/rbbt/knowledge_base/test_syndicate.rb
|
554
|
+
- test/rbbt/knowledge_base/test_registry.rb
|
555
|
+
- test/rbbt/entity/test_identifiers.rb
|
556
|
+
- test/rbbt/test_monitor.rb
|
557
|
+
- test/rbbt/test_workflow.rb
|
558
|
+
- test/rbbt/test_annotations.rb
|
559
|
+
- test/rbbt/annotations/test_util.rb
|
560
|
+
- test/rbbt/test_resource.rb
|
561
|
+
- test/rbbt/persist/tsv/test_tokyocabinet.rb
|
562
|
+
- test/rbbt/persist/tsv/test_kyotocabinet.rb
|
563
|
+
- test/rbbt/persist/tsv/test_lmdb.rb
|
564
|
+
- test/rbbt/persist/tsv/test_leveldb.rb
|
565
|
+
- test/rbbt/persist/tsv/test_cdb.rb
|
566
|
+
- test/rbbt/persist/tsv/test_sharder.rb
|
567
|
+
- test/rbbt/persist/test_tsv.rb
|
568
|
+
- test/rbbt/test_tsv.rb
|