File: se-permutation.rb

package info (click to toggle)
genometools 1.6.1%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 50,412 kB
  • sloc: ansic: 271,241; ruby: 30,339; python: 4,880; sh: 3,193; makefile: 1,194; perl: 219; pascal: 159; haskell: 37; sed: 5
file content (45 lines) | stat: -rwxr-xr-x 1,112 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env ruby

require_relative "SEmatch"

if ARGV.length != 2
  STDERR.puts "#{$0} <matchfile1> <matchfile2>"
  exit 1
end
sematchlist = Array.new(2) {Array.new()}

0.upto(1).each do |idx|
  sematch = SEmatch.new(ARGV[idx])
  sematch.each do |m|
    sematchlist[idx].push(m)
  end
end

if sematchlist[0].length != sematchlist[1].length
  STDERR.puts "sematchlist[0].length = #{sematchlist[0].length} != " +
              "#{sematchlist[1].length} = sematchlist[1].length"
  exit 1
end

0.upto(sematchlist[0].length-1).each do |idx|
  m0 = sematchlist[0][idx]
  m1 = sematchlist[1][idx]
  m1.each_pair do |k,v|
    if k == :origline
      next
    end
    if not m0.has_key?(k)
      STDERR.puts "#{$0}: match #{idx}: missing key #{k} in #{ARGV[0]}"
      exit 1
    end
    if m0[k] != v
      STDERR.puts "#{$0}: match #{idx}: key #{k}: has values #{m0[k]} != #{v}"
      exit 1
    end
  end
end
if sematchlist[0].length > 0
  keycount = sematchlist[1][0].length
  puts "#{sematchlist[0].length} matches with #{keycount} columns processed"
end
puts "#{ARGV[1]} is a subset of the columns of #{ARGV[0]}"