File: reset_fasta_ids.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 (15 lines) | stat: -rwxr-xr-x 397 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env ruby
# add unique IDS to the fasta headers of file piped through stdin or file input
#

id = 1
ARGF.each_line do |line|
  if line.match(/^>\w+ (.*)$/)
    # print ">#{id.to_s(16)}#{id.to_s(16)}#{id.to_s(16)} #$1\n"
    # id += 1 + Math.log(id).to_i * Math.log(id).to_i * Math.log(id).to_i
    print ">0x#{id.to_s(16).rjust(4, '0')} #$1\n"
    id += 1
  else
    puts line
  end
end