Class: BioChEMBL::ChEMBLID
- Inherits:
-
String
- Object
- String
- BioChEMBL::ChEMBLID
- Defined in:
- lib/bio-chembl/chemblid.rb
Overview
Instance Attribute Summary collapse
-
#data_type ⇒ Object
Returns the value of attribute data_type.
Class Method Summary collapse
-
.valid_format?(str) ⇒ Boolean
Checking the format of the ChEMBL ID.
Instance Method Summary collapse
-
#initialize(str) ⇒ ChEMBLID
constructor
A new instance of ChEMBLID.
-
#is_assay? ⇒ Boolean
Is the ChEMBL ID of Assay ?.
-
#is_compound? ⇒ Boolean
Is the ChEMBL ID of Compound ?.
-
#is_target? ⇒ Boolean
Is the ChEMBL ID of Target ?.
-
#resolve ⇒ Object
Get the data of the ChEMBL ID (Slow).
Constructor Details
#initialize(str) ⇒ ChEMBLID
Returns a new instance of ChEMBLID.
52 53 54 55 56 |
# File 'lib/bio-chembl/chemblid.rb', line 52 def initialize(str) @data_type = nil validate_chemblId(str) super(str) end |
Instance Attribute Details
#data_type ⇒ Object
Returns the value of attribute data_type.
29 30 31 |
# File 'lib/bio-chembl/chemblid.rb', line 29 def data_type @data_type end |
Class Method Details
.valid_format?(str) ⇒ Boolean
Checking the format of the ChEMBL ID
33 34 35 36 37 38 39 40 |
# File 'lib/bio-chembl/chemblid.rb', line 33 def self.valid_format?(str) begin self.new(str) true rescue Exception false end end |
Instance Method Details
#is_assay? ⇒ Boolean
Is the ChEMBL ID of Assay ?
113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/bio-chembl/chemblid.rb', line 113 def is_assay? if @data_type == Assay return true else begin Assay.find(self) @data_type = Assay return true rescue Exception return false end end end |
#is_compound? ⇒ Boolean
Is the ChEMBL ID of Compound ?
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/bio-chembl/chemblid.rb', line 81 def is_compound? if @data_type == Compound return true else begin Compound.find(self) @data_type = Compound return true rescue Exception return false end end end |
#is_target? ⇒ Boolean
Is the ChEMBL ID of Target ?
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/bio-chembl/chemblid.rb', line 97 def is_target? if @data_type == Target return true else begin Target.find(self) @data_type = Target return true rescue Exception return false end end end |
#resolve ⇒ Object
Get the data of the ChEMBL ID (Slow)
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bio-chembl/chemblid.rb', line 59 def resolve if @data_type == Compound return Compound.find(self.to_s) elsif @data_type == Target return Target.find(self.to_s) elsif @data_type == Assay return Assay.find(self.to_s) else if is_compound? elsif is_target? elsif is_assay? end if @data_type == nil raise ArgumentError, "This ChEMBL ID is not exist, #{self.to_s}" else resolve end end end |