Sha256: 90a1c48e7e54e39f85697025f4794ee619b93aa65a76d5439fbe089f094537b4

Contents?: true

Size: 1.17 KB

Versions: 15

Compression:

Stored size: 1.17 KB

Contents

#!/usr/bin/ruby -w


if ARGV.size < 2
  puts "usage: #{File.basename(__FILE__)} protxml pepxml"
  puts "Based on some kind of truncated prot xml file, takes a pepxml file"
  puts "and deletes all search hits/peptides that aren't in the prot xml file!"
  exit
end

protxml = ARGV[0]
pepxml = ARGV[1]

hash = {}
File.open(protxml) do |fh|
  while line = fh.gets
    if line =~ /peptide_sequence="(.*?)" charge="(\d)" /
      hash[[$1.dup,$2.dup]] = 1
    end
  end
end

p hash

out = File.open(pepxml + ".small", "w")

in_hit = false
cur_charge = nil
stored_lines = ""
print_it = false
File.open(pepxml) do |fh|
  while line = fh.gets
    if line =~ /<search_result .*? assumed_charge="(\d)".*?>/
      cur_charge = $1.dup
      in_hit = true
    end
    if line =~ /<search_hit .*? peptide="(.*?)"/
      if hash.key?([$1.dup,cur_charge])
        print_it = true
      else
        print_it = false
      end
    end
    if line =~ /<\/search_result>/
      if print_it == true
        stored_lines << line
        out.print stored_lines
      end
      stored_lines = ""
      in_hit == false
    elsif !in_hit
      out.print line
    else
      stored_lines << line
    end
  end


end

out.close

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
mspire-0.4.9 script/create_little_pepxml.rb
mspire-0.1.3 script/create_little_pepxml.rb
mspire-0.2.0 script/create_little_pepxml.rb
mspire-0.2.2 script/create_little_pepxml.rb
mspire-0.2.4 script/create_little_pepxml.rb
mspire-0.3.0 script/create_little_pepxml.rb
mspire-0.1.7 script/create_little_pepxml.rb
mspire-0.2.1 script/create_little_pepxml.rb
mspire-0.1.5 script/create_little_pepxml.rb
mspire-0.3.9 script/create_little_pepxml.rb
mspire-0.3.1 script/create_little_pepxml.rb
mspire-0.4.4 script/create_little_pepxml.rb
mspire-0.4.2 script/create_little_pepxml.rb
mspire-0.4.5 script/create_little_pepxml.rb
mspire-0.4.7 script/create_little_pepxml.rb