Sha256: 580ec03515ae2323760dc4062f12538424a24dd5cf5de8fe3f2c519b5ae83885
Contents?: true
Size: 1.24 KB
Versions: 4
Compression:
Stored size: 1.24 KB
Contents
#!/usr/bin/env ruby require 'cri' Signal.trap("PIPE", "EXIT") Signal.trap("INT", "EXIT") root_cmd = Cri::Command.new_basic_root.modify do name 'prot2pept' required :p, :pattern, "cleavage pattern to split input protein (default: ([KR])([^P]))" run do |opts, args, cmd| pattern = opts.fetch(:pattern, "([KR])([^P])") # decide if we have FASTA input fasta_header = $stdin.gets if fasta_header.start_with? '>' # fasta input, need to join lines while !$stdin.eof? prot = "" # Sometimes you just got to accept this weird and ugly code until $stdin.eof? || (line = gets).start_with?('>') prot += line.chomp end puts fasta_header puts prot.gsub(/#{pattern}/,"\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2").split("\n").reject(&:empty?) fasta_header = line end else # handle our already read line puts fasta_header.gsub(/#{pattern}/,"\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2").split("\n").reject(&:empty?) # we no longer have to join lines as input is now more sane $stdin.each_line do |prot| puts prot.gsub(/#{pattern}/,"\\1\n\\2").gsub(/#{pattern}/, "\\1\n\\2").split("\n").reject(&:empty?) end end end end root_cmd.run(ARGV)
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
unipept-0.6.4 | bin/prot2pept |
unipept-0.6.2 | bin/prot2pept |
unipept-0.6.1 | bin/prot2pept |
unipept-0.5.7 | bin/prot2pept |