Sha256: dd502aff91d4056e8db480999ec014a90dcabf626a0f14171b41c26fd5b2aa42
Contents?: true
Size: 1.11 KB
Versions: 4
Compression:
Stored size: 1.11 KB
Contents
#!/usr/bin/env ruby require 'cri' trap "INT" do $interupted = true end Signal.trap("PIPE", "EXIT") root_cmd = Cri::Command.new_basic_root.modify do name 'peptfilter' flag :i, :unique, "only output unique peptides" required :l, :minlen, "minimum length (default: 5)" required :u, :maxlen, "minimum length (default: 50)" required :a, :lacks, "a string whose letters represent amino acids that may not occur in the peptide" required :c, :contains, "a string whose letters represent amino acids that must all occur in the peptide" run do |opts, args, cmd| minlen = opts.fetch(:minlen, "5").to_i maxlen = opts.fetch(:maxlen, "50").to_i lacks = opts.fetch(:lacks, "").chars.to_a contains = opts.fetch(:contains, "").chars.to_a $stdin.each_line do |pept| break if $interupted pept = pept.chomp length_ok = pept.length >= minlen && pept.length <= maxlen lacks_ok = (pept.chars.to_a & lacks).size == 0 contains_ok = (pept.chars.to_a & contains).size == contains.size if length_ok && lacks_ok && contains_ok puts pept end end end end root_cmd.run(ARGV)
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
unipept-0.3.2 | bin/peptfilter |
unipept-0.3.1 | bin/peptfilter |
unipept-0.3.0 | bin/peptfilter |
unipept-0.2.10 | bin/peptfilter |