Sha256: 2a5ce1c7b4c17646f09ab6195b29f8971f162c8b3478b17c4153bcfee98dece7
Contents?: true
Size: 1.09 KB
Versions: 3
Compression:
Stored size: 1.09 KB
Contents
#!/usr/bin/env ruby require 'cri' 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 filtered = $stdin.readlines.select do |pept| 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 length_ok && lacks_ok && contains_ok end if opts[:unique] puts filtered.uniq else puts filtered end end end root_cmd.run(ARGV)
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
unipept-0.2.6 | bin/peptfilter |
unipept-0.2.5 | bin/peptfilter |
unipept-0.2.4 | bin/peptfilter |