Sha256: 33fa778c09f84e1b82cc45101f6f39623a6aa3210f28bb02d11320d5f1781560

Contents?: true

Size: 1.07 KB

Versions: 260

Compression:

Stored size: 1.07 KB

Contents

#!/usr/bin/env ruby

require 'rbbt-util'
require 'rbbt/util/simpleopt'

$0 = "rbbt #{$previous_commands*""} #{ File.basename(__FILE__) }" if $previous_commands

options = SOPT.setup <<EOF

Description

$ rbbt tsv attach <file1> <file2> [<file3> ...] [options]

Use - to read from STDIN

-f--fields* Fields to attach (all if not specified)
-i--identifiers* Identifier file
-h--help Print this help

EOF
if options[:help]
  if defined? rbbt_usage
    rbbt_usage 
  else
    puts SOPT.usage
  end
  exit 0
end

file1, *rest = ARGV
fields = options[:fields]
identifiers = options[:identifiers] 

if identifiers.nil?
  require 'rbbt/sources/organism'
  Organism.identifiers(Organism.default_code("Hsa"))
end

fields = fields ? fields.split(/[,|]/).collect{|f| f.strip} : nil

tsv = TSV.open(file1, :unnamed => true)
tsv = tsv.to_double if tsv.type == :flat

rest.each do |file2|
  file_fields = TSV.parse_header(file2).all_fields - tsv.all_fields
  these_fields = fields ? fields & file_fields : nil
  tsv = tsv.attach file2, :fields => these_fields, :identifiers => identifiers
end

puts tsv.to_s

Version data entries

260 entries across 260 versions & 1 rubygems

Version Path
rbbt-util-5.26.86 share/rbbt_commands/tsv/attach
rbbt-util-5.26.85 share/rbbt_commands/tsv/attach
rbbt-util-5.26.84 share/rbbt_commands/tsv/attach
rbbt-util-5.26.83 share/rbbt_commands/tsv/attach
rbbt-util-5.26.82 share/rbbt_commands/tsv/attach
rbbt-util-5.26.81 share/rbbt_commands/tsv/attach
rbbt-util-5.26.80 share/rbbt_commands/tsv/attach
rbbt-util-5.26.79 share/rbbt_commands/tsv/attach
rbbt-util-5.26.78 share/rbbt_commands/tsv/attach
rbbt-util-5.26.77 share/rbbt_commands/tsv/attach
rbbt-util-5.26.76 share/rbbt_commands/tsv/attach
rbbt-util-5.26.75 share/rbbt_commands/tsv/attach
rbbt-util-5.26.74 share/rbbt_commands/tsv/attach
rbbt-util-5.26.73 share/rbbt_commands/tsv/attach
rbbt-util-5.26.72 share/rbbt_commands/tsv/attach
rbbt-util-5.26.71 share/rbbt_commands/tsv/attach
rbbt-util-5.26.70 share/rbbt_commands/tsv/attach
rbbt-util-5.26.69 share/rbbt_commands/tsv/attach
rbbt-util-5.26.68 share/rbbt_commands/tsv/attach
rbbt-util-5.26.67 share/rbbt_commands/tsv/attach