Class: Ms::Mascot::Predict
- Inherits:
-
Tap::FileTask
- Object
- Tap::FileTask
- Ms::Mascot::Predict
- Defined in:
- lib/ms/mascot/predict.rb
Overview
Ms::Mascot::Predict::manifest predicts the spectra for a protein sequence
Fragments a protein sequence and calculates the fragment spectra for each peptide. The peptide spectra are formatted as mgf and dumped to the target.
% rap predict MAEELVLERCDLELETNGRDHHTADLCREKLVVRRGQPFWLTLHFEGRNYEASVDSLTFS
I[16:30:19] digest MAEELVLERCD... to 15 peptides
I[16:30:19] fragment MAEELVLER
I[16:30:19] fragment MAEELVLERCDLELETNGR
I[16:30:19] fragment CDLELETNGR
I[16:30:19] fragment CDLELETNGRDHHTADLCR
I[16:30:19] fragment DHHTADLCR
I[16:30:19] fragment DHHTADLCREK
I[16:30:19] fragment EKLVVR
I[16:30:19] fragment LVVR
I[16:30:19] fragment LVVRR
I[16:30:19] fragment RGQPFWLTLHFEGR
I[16:30:19] fragment GQPFWLTLHFEGR
I[16:30:19] fragment GQPFWLTLHFEGRNYEASVDSLTFS
I[16:30:19] fragment NYEASVDSLTFS
Instance Method Summary collapse
-
#default_path(sequence) ⇒ Object
Infers a default path for the output mgf file from the sequence; the path is the sequence if the sequence is less than 10 characters, otherwise it’s like: “<first five>_<last five>.mgf”.
- #process(sequence, target = nil) ⇒ Object
-
#workflow ⇒ Object
Sequences digest and fragment.
Instance Method Details
#default_path(sequence) ⇒ Object
Infers a default path for the output mgf file from the sequence; the path is the sequence if the sequence is less than 10 characters, otherwise it’s like: “<first five>_<last five>.mgf”
68 69 70 71 |
# File 'lib/ms/mascot/predict.rb', line 68 def default_path(sequence) sequence = "#{sequence[0,5]}_#{sequence[-5,5]}" if sequence.length > 10 "#{sequence}.mgf" end |
#process(sequence, target = nil) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/ms/mascot/predict.rb', line 73 def process(sequence, target=nil) sequence = sequence.gsub(/\s/, "") @entries = [] digest.execute(sequence) # prepare and dump the predicted spectra # to the target path. target = default_path(sequence) if target == nil prepare(target) File.open(target, "wb") do |file| @entries.each do |entry| entry.dump(file, config) file.puts end end target end |
#workflow ⇒ Object
Sequences digest and fragment. When fragment completes, it will add a new mgf entry to the internal entries collection.
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ms/mascot/predict.rb', line 42 def workflow digest.on_complete do |_results| _results._iterate.each do |_result| next if min_length && _result._current.length < min_length fragment._execute(_result) end end fragment.on_complete do |_result| parent_ion_mass, data = _result._current next if data.empty? peptide = _result._values[-2] headers = { 'TITLE' => "#{peptide} (#{fragment.series.join(', ')})", 'CHARGE' => fragment.charge, 'PEPMASS' => parent_ion_mass} @entries << Mgf::Entry.new(headers, data) end end |