Class: ProphetTool

Inherits:
SearchTool show all
Includes:
LibXML
Defined in:
lib/protk/prophet_tool.rb

Instance Attribute Summary

Attributes inherited from Tool

#option_parser, #options

Instance Method Summary collapse

Methods inherited from SearchTool

#current_database, #jobid_from_filename

Methods inherited from Tool

#input_base_path, #jobid_from_filename, #jobid_prefix, #jobid_prefix=, #method_missing, #output_base_path, #run

Constructor Details

#initialize(option_support = {}) ⇒ ProphetTool

Initializes the commandline options



20
21
22
23
24
25
26
# File 'lib/protk/prophet_tool.rb', line 20

def initialize(option_support={})
  option_support[:prefix_suffix]=true;
  option_support[:over_write]=true;
  
  super(option_support)

end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tool

Instance Method Details

#extract_db(file_name) ⇒ Object

Obtain the database name from the given input file



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/protk/prophet_tool.rb', line 32

def extract_db(file_name)
  reader = XML::Reader.file(file_name)
  throw "Failed to open xml file #{file_name}" unless reader!=nil

  while(reader.read)
    # For pep.xml files
    #
    if ( reader.name == "search_database" )
      dbnode=reader.expand
      dbvalue=dbnode['local_path']
      reader.close
      return dbvalue
    end

    # For prot.xml files
    #
    if ( reader.name == "protein_summary_header" )
      dbnode=reader.expand
      dbvalue=dbnode['reference_database']
      reader.close
      return dbvalue
    end
    
    
    
  end

end

#extract_engine(file_name) ⇒ Object

Obtain the search engine name from the input file The name of the engine is returned in lowercase and should contain no spaces Names of common engines are searched for and extracted in simplified form if possible



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/protk/prophet_tool.rb', line 67

def extract_engine(file_name)
  reader = XML::Reader.file(file_name)
  throw "Failed to open xml file #{file_name}" unless reader!=nil

  while(reader.read)
    if ( reader.name == "search_summary" )
      dbnode=reader.expand
      dbvalue=dbnode['search_engine']
      reader.close
      engine_name=dbvalue.gsub(/ /,"_")
      engine_name=engine_name.gsub(/\(/,"")
      engine_name=engine_name.gsub(/\)/,"")
      engine_name=engine_name.gsub(/\!/,"")        
      return engine_name.downcase
    end
  end
end