Class: MascotUtil

Inherits:
Object
  • Object
show all
Defined in:
lib/protk/mascot_util.rb

Class Method Summary collapse

Class Method Details

.index_mgf_times(mgf_file) ⇒ Object

Create a hashtable which maps spectrum references to retention times for an mgf file



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/protk/mascot_util.rb', line 40

def self.index_mgf_times(mgf_file)
 rt_table=Hash.new()
 mgf=File.new(mgf_file)

 mgf.each(sep="END IONS") do |line|

   spec=line.match(/TITLE=(.*?)$/)

   rt=line.match(/RTINSECONDS=(.*?)$/)

   if ( spec!=nil && rt!=nil)
     # Remove charge from the end of the title
     spec_id= remove_charge_from_title_string(spec[1])
     
     rt_table[spec_id]=rt[1]
   end
   
 end

 return rt_table
  
end

.input_basename(dat_file) ⇒ Object

Reads a mascot dat file and returns the basename of the original search file



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/protk/mascot_util.rb', line 7

def self.input_basename(dat_file)

  dat=File.new(dat_file)
  filename=""
  dat.each_line do |line|
    if ( line=~ /^File/i)
      p line
      m=line.match(/^File=.*?[\/\\]?(.*)\.[md][ga][tf]/i)
      if ( m!=nil )
        filename=m[1]
      end
    end
  end

  return filename

end

.remove_charge_from_title_string(tstring) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/protk/mascot_util.rb', line 25

def self.remove_charge_from_title_string(tstring)
  if ( tstring=~/(.*)\..*?\..*?\.$/)
    return tstring.chop
  end
  
  if ( tstring=~/(.*)\..*?\..*?\.\d$/)
    return tstring.chop!.chop
  end
  
  throw "Unrecognised title string format #{tstring}"
  
end