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


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/protk/mascot_util.rb', line 45

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])
     spec_id= spec[1]

  #   $stdout.write "#{spec_id} \r"

     
     rt_table[spec_id]=rt[1]
   end

 end
#    $stdout.write "\n"

 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
37
38
39
40
41
# 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

  if ( tstring=~/(.*)\..*?\..*?$/)
    return tstring
  end    
  
  throw "Unrecognised title string format #{tstring}"
  
end