Sha256: 84008866993f8881f3073f75787de8683ff3af6080b14f41d176a7cd179307eb
Contents?: true
Size: 1.11 KB
Versions: 710
Compression:
Stored size: 1.11 KB
Contents
#!/usr/bin/env ruby require 'rbbt-util' require 'rbbt/util/simpleopt' options = SOPT.setup <<EOF Change the ID format of a column in a tsv file $ rbbt command command [options] -f file Use - to read from STDIN. The `field` is the tsv column to change. the `target` is the target format, as appearing in the `identifiers` file or in `Organism.identifiers(Organism.default_code("Hsa"))`. -f--file* File to process -f--field* Field to change -t--target* Target format -i--identifiers* Identifier file to use -h--help Help EOF rbbt_usage and exit 0 if options[:help] SOPT.require options, :file, :field, :target require 'rbbt/sources/organism' identifiers = options[:identifiers] || Organism.identifiers(Organism.default_code("Hsa")).find begin index = TSV.index(identifiers, :persist => true, :target => target, :merge => true) rescue raise ParameterException, "Could not build index for '#{target}': #{ identifiers }" end tsv = TSV.open file tsv.process field do |value| if Array === value index.values_at *value else index[value] end end tsv.fields = tsv.fields.collect{|f| f == field ? target : f} puts tsv
Version data entries
710 entries across 710 versions & 1 rubygems