<commit_before>#!/usr/bin/env ruby

require 'trollop'
require 'nokogiri'
require 'set'

require 'ms/ident/pepxml'
require 'ms/ident/peptide_hit/qvalue'

EXT = Ms::Ident::PeptideHit::Qvalue::FILE_EXTENSION
combine_base  = "combined"

opts = Trollop::Parser.new do
  banner %Q{usage: #{File.basename(__FILE__)} <target>.xml <decoy>.xml ...
outputs: <fwd>.phq.tsv
phq.tsv?: see schema/peptide_hit_qvalues.phq.tsv
}
  opt :combine, "groups target and decoy hits together from all files, writing to #{combine_base}#{EXT}", :default => false
  opt :z_together, "do not group by charge state", :default => false
  opt :decoy_first, "decoy files are before target files", :default => false
  opt :verbose, "be verbose", :default => false
end

opt = opts.parse(ARGV)
if ARGV.size == 0 || (ARGV.size%2 != 0)
  puts "\n\n!! only even numbers of files accepted (target decoy target decoy ...) !!\n\n" if (ARGV.size%2 != 0)
  opts.educate
  exit 
end

$VERBOSE = opt.delete(:verbose)

files = ARGV.to_a

files.each_slice(2).map!(&:reverse) if opt[:decoy_first]

groups_of_search_hits = files.map do |file|
  Ms::Ident::Pepxml.search_hits(file)
end

to_run = {}
if opt[:combine]
  all_target = [] ; all_decoy = []<commit_msg>progress<commit_after>#!/usr/bin/env ruby

require 'trollop'
require 'nokogiri'
require 'set'

require 'ms/ident/pepxml'
require 'ms/ident/peptide_hit/qvalue'

EXT = Ms::Ident::PeptideHit::Qvalue::FILE_EXTENSION
combine_base  = "combined"

opts = Trollop::Parser.new do
  banner %Q{usage: #{File.basename(__FILE__)} <target>.xml <decoy>.xml ...
outputs: <fwd>.phq.tsv
phq.tsv?: see schema/peptide_hit_qvalues.phq.tsv
}
  opt :combine, "groups target and decoy hits together from all files, writing to #{combine_base}#{EXT}", :default => false
  opt :z_together, "do not group by charge state", :default => false
  opt :decoy_first, "decoy files are before target files", :default => false
  opt :verbose, "be verbose", :default => false
end

opt = opts.parse(ARGV)
if ARGV.size == 0 || (ARGV.size%2 != 0)
  puts "\n\n!! only even numbers of files accepted (target decoy target decoy ...) !!\n\n" if (ARGV.size%2 != 0)
  opts.educate
  exit 
end

$VERBOSE = opt.delete(:verbose)

files = ARGV.to_a

(files=files.each_slice(2).map(&:reverse).flatten) if opt[:decoy_first]

groups_of_search_hits = files.map do |file|
  Ms::Ident::Pepxml.search_hits(file)
end

to_run = {}
if opt[:combine]
  all_target = [] ; all_decoy = []
{'fraction_non_alphanumeric': 0.15666118421052633, 'fraction_numerical': 0.004934210526315789, 'mean_word_length': 4.738207547169812, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4728833', 'n_tokens_mistral': 946, 'n_tokens_neox': 919, 'n_words': 232}