Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jtprince committed Sep 20, 2012
1 parent e4ece63 commit 277b5d2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion lib/mspire/lipid/modification.rb
Expand Up @@ -75,7 +75,8 @@ def self.massdiff(formula, charge, gain=true)
# if no mass or formula is given then it searches command mods for the name
# @param [Symbol] name the name of the mod
# A number of opts are expected if they are not found in the FORMULAS,
# CHARGE, or MASSDIFFS hashes:
# CHARGE, or MASSDIFFS hashes. However, the massdiff will be inferred
# from the formula if it is not given:
#
# attributes:
# :formula = the chemical formula, lipidmaps style ("C2H4BrO") or
Expand Down
10 changes: 8 additions & 2 deletions script/find_nearest_lipid.rb
Expand Up @@ -14,6 +14,7 @@
opt :top_n, "how many closest ions to print", :default => 3
banner ""
text "modifications: (at least 1 charged mod is required)"
#opt :newmod, "<name>:<formula>:<charge>:<L/G>:<#occurences> L/G=loss or gain", :type => :string, :multi => true
opt :lithium, "search for i down to 1 lithium adducts", :default => 0
opt :sodium, "search for i down to 1 sodium adducts", :default => 0
opt :ammonium, "search for i down to 1 ammonium adducts", :default => 0
Expand All @@ -22,6 +23,8 @@
opt :proton_gain, "search for i down to 1 proton additions", :default => 0
opt :proton_loss, "search for i down to 1 proton losses", :default => 0
opt :water_loss, "if used, *all* mods are also considered with i down to 0 water losses", :default => 0
text ""
text "other:"
opt :textfile, "a text file with m/z values, one per line", :type => String
opt :lower_bound, "use lower bound searching (requires m/z's to be in sorted order)"
opt :sort, "sorts the m/z's"
Expand All @@ -35,6 +38,7 @@
end

CHARGED_MODS = [:lithium, :sodium, :ammonium, :proton_gain, :proton_loss]
UNCHARGED_MODS = [:water_loss, :carbon_dioxide_loss, :ammonia_loss]

unless CHARGED_MODS.any? {|key| opts[key] > 0 }
puts "*" * 78
Expand Down Expand Up @@ -81,8 +85,10 @@
if opts[key] > 0
opts[key].downto(1) do |num_charge_mod|
mods_to_use = [mods[key]] * num_charge_mod
opts[:water_loss].downto(0) do |i|
ions << Mspire::Lipid::Ion.new(lipid, mods_to_use + ([mods[:water_loss]]*i))
UNCHARGED_MODS.each do |umod|
opts[umod].downto(0) do |i|
ions << Mspire::Lipid::Ion.new(lipid, mods_to_use + ([mods[:umod]]*i))
end
end
end
end
Expand Down

0 comments on commit 277b5d2

Please sign in to comment.