Sha256: 8bac85f20bef04a70ece677e0b597cf6b0aabea7edf6ffbe9ab7c3357e70033c
Contents?: true
Size: 1.07 KB
Versions: 110
Compression:
Stored size: 1.07 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("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("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
110 entries across 110 versions & 1 rubygems