Class: ODDB::CyP450

Inherits:
Object show all
Includes:
OddbYaml, Persistence
Defined in:
src/model/cyp450.rb,
test/test_model/cyp450.rb,
ext/export/src/oddb_yaml.rb

Constant Summary

EXPORT_PROPERTIES =
[
  '@cyp_id',
]

Constants included from OddbYaml

EXPORT_PROPERTIES, YAML_URI

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from OddbYaml

#to_yaml_properties, #to_yaml_type

Methods included from PersistenceMethods

#checkout, #data_origin, #data_origins, #diff, #init, #nil_if_empty, #parent, #pointer_descr, #structural_ancestors, #undiffable?, #update_values

Constructor Details

- (CyP450) initialize(cyp_id)

A new instance of CyP450



12
13
14
15
16
# File 'src/model/cyp450.rb', line 12

def initialize(cyp_id)
  @cyp_id = cyp_id
  @inhibitors = {}
  @inducers = {}
end

Instance Attribute Details

- (Object) cyp_id (readonly)

Returns the value of attribute cyp_id



9
10
11
# File 'src/model/cyp450.rb', line 9

def cyp_id
  @cyp_id
end

- (Object) inducers

Returns the value of attribute inducers



10
11
12
# File 'src/model/cyp450.rb', line 10

def inducers
  @inducers
end

- (Object) inhibitors

Returns the value of attribute inhibitors



10
11
12
# File 'src/model/cyp450.rb', line 10

def inhibitors
  @inhibitors
end

Instance Method Details

- (Object) create_cyp450inducer(substance_name)



39
40
41
42
43
# File 'src/model/cyp450.rb', line 39

def create_cyp450inducer(substance_name)
  conn = ODDB::CyP450InducerConnection.new(substance_name)
  conn.cyp450 = self
  @inducers.store(substance_name, conn)
end

- (Object) create_cyp450inhibitor(substance_name)



44
45
46
47
48
# File 'src/model/cyp450.rb', line 44

def create_cyp450inhibitor(substance_name)
  conn = ODDB::CyP450InhibitorConnection.new(substance_name)
  conn.cyp450 = self
  @inhibitors.store(conn.substance_name, conn)
end

- (Object) cyp450inducer(substance_name)



49
50
51
# File 'src/model/cyp450.rb', line 49

def cyp450inducer(substance_name)
  @inducers[substance_name]
end

- (Object) cyp450inhibitor(substance_name)



52
53
54
# File 'src/model/cyp450.rb', line 52

def cyp450inhibitor(substance_name)
  @inhibitors[substance_name]
end

- (Object) delete_cyp450inducer(substance_name)



55
56
57
58
59
60
# File 'src/model/cyp450.rb', line 55

def delete_cyp450inducer(substance_name)
  if(ind = @inducers.delete(substance_name))
    @inducers.odba_isolated_store
    ind
  end
end

- (Object) delete_cyp450inhibitor(substance_name)



61
62
63
64
65
66
# File 'src/model/cyp450.rb', line 61

def delete_cyp450inhibitor(substance_name)
  if(inh = @inhibitors.delete(substance_name))
    @inhibitors.odba_isolated_store
    inh
  end  
end

- (Object) interactions_with(substance)



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'src/model/cyp450.rb', line 17

def interactions_with(substance)
  return [] unless substance
  connections = []
  keys = {}
  substance.connection_keys.each do |key|
    keys.store key, 1
  end
  substance._search_keys.each do |key|
    keys.store key.downcase, 1
  end
  @inhibitors.each { |connection_key, connection| 
    if(keys.include?(connection_key))
      connections.push(connection)
    end
  }
  @inducers.each { |connection_key, connection| 
    if(keys.include?(connection_key))
      connections.push(connection)
    end
  }
  connections
end

- (Object) to_yaml(opts = {})



162
163
164
165
166
167
168
169
170
171
172
# File 'ext/export/src/oddb_yaml.rb', line 162

def to_yaml( opts = {} )
  YAML::quick_emit( self.object_id, opts ) { |out|
    out.map( taguri ) { |map|
      to_yaml_properties.each { |m|
        map.add( m[1..-1], instance_variable_get( m ) )
      }
      map.add('inhibitors', self.inhibitors.values)
      map.add('inducers', self.inducers.values)
    }
  }
end