Module: Sylfy::Service::LipidMap::REST
- Defined in:
- lib/sylfy/service/lipidmaprest.rb
Constant Summary collapse
- @@baseuri =
"http://www.lipidmaps.org/data"
Class Method Summary collapse
-
.lmsdOntoSearch(onto, outputtype = "TSV") ⇒ Object
Method for setting inchi data member.
-
.lmsdRecord(id, outputtype = "TSV") ⇒ Object
Method for setting inchi data member.
-
.lmsdSearch(str, mode, outputtype = "TSV") ⇒ Object
Method for setting inchi data member.
-
.lmsdStrSearch(string, field = 'LMID', exactMatch = true, outputtype = "TSV") ⇒ Object
Method for setting inchi data member.
-
.lmsdTxtSearch(hash, outputtype = "TSV") ⇒ Object
Method for setting inchi data member.
Class Method Details
.lmsdOntoSearch(onto, outputtype = "TSV") ⇒ Object
Method for setting inchi data member
Parameters:
- onto
-
string = “<ontoStr>” <ontoStr> = <ParamName> <ParamModifier> <ParamName> = carbons, doublebonds, triplebonds, rings, OH, NH2, OOH, ketones, epoxides, COOH, methyls, SH, Br, Cl, F, Methylenes, CHO, OMe, OAc, COOMe, Ester, Ether <ParamModifier> = eq, ge, le <ParamValue> = integer example: “carbons eq 20, triplebonds ge 2” or “carbons eq 10”
- option
-
:OutputType => TSV, CSV, SDF [defualt: TSV],
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
# File 'lib/sylfy/service/lipidmaprest.rb', line 165 def lmsdOntoSearch(onto, outputtype = "TSV") paramName = ["carbons", "doublebonds", "triplebonds", "rings", "OH", "NH2", "OOH", "ketones", "epoxides"] paramName = paramName + ["COOH", "methyls", "SH", "Br", "Cl", "F", "Methylenes", "CHO", "OMe", "OAc", "COOMe", "Ester", "Ether"] paramModifier = ["eq", "ge", "le"] i = 1 ontostr = "" onto.chomp.gsub(/, /, ',').split(/,/).each do |str| dat = str.split(/ /) if paramName.include?(dat[0]) && paramModifier.include?(dat[1]) && i < 5 ontostr += '&' if i > 1 ontostr += "OntologyParamName#{i}=#{dat[0]}&OntologyParamModifier#{i}=#{dat[1]}&OntologyParamValue#{i}=#{dat[2].to_i}" i += 1 end end if ontostr != '' return lmsdSearch(ontostr, "ProcessTextOntologySearch", outputtype) else raise Sylfy::Service::ParameterError, "ontology string error." end end |
.lmsdRecord(id, outputtype = "TSV") ⇒ Object
Method for setting inchi data member
Parameters:
- id
-
LipidMap id to search
- outputtype
-
TSV, CSV, SDF or MDLMOL [defualt: TSV]
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sylfy/service/lipidmaprest.rb', line 28 def lmsdRecord(id, outputtype = "TSV") uri = "#{@@baseuri}/LMSDRecord.php?LMID=#{id}" uri += "&Mode=File" uri += "&OutputType=#{["TSV", "CSV", "SDF"].include?(outputtype) ? outputtype : 'TSV'}" uri += "&OutputDelimiter=Comma&OutputQuote=Yes&OutputColumnHeader=Yes" begin doc = URI.parse(uri).read().strip() case outputtype when 'TSV', nil return CSV.parse(doc, :headers => true, :col_sep => "\t") when 'CSV' return CSV.parse(doc, :headers => true) else return doc end rescue OpenURI::HTTPError return nil end end |
.lmsdSearch(str, mode, outputtype = "TSV") ⇒ Object
Method for setting inchi data member
Parameters:
- str
-
search string
- mode
-
Search mode ProcessStrSearch, ProcessTextSearch or ProcessTextOntologySearch
- outputtype
-
TSV, CSV, SDF or MDLMOL [defualt: TSV]
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sylfy/service/lipidmaprest.rb', line 61 def lmsdSearch(str, mode, outputtype = "TSV") uri = "#{@@baseuri}/structure/LMSDSearch.php?#{str}&OutputMode=File&Mode=#{mode}" uri += "&OutputType=#{["TSV", "CSV", "SDF"].include?(outputtype) ? outputtype : 'TSV'}" uri += "&OutputDelimiter=Comma&OutputQuote=Yes&OutputColumnHeader=Yes" begin doc = URI.parse(uri).read().strip() case outputtype when 'TSV', nil return CSV.parse(doc, :headers => true, :col_sep => "\t") when 'CSV' return CSV.parse(doc, :headers => true) else return doc end rescue OpenURI::HTTPError return nil end end |
.lmsdStrSearch(string, field = 'LMID', exactMatch = true, outputtype = "TSV") ⇒ Object
Method for setting inchi data member
Parameters:
- string
-
search string
- field
-
field type: LMID, Name, Formula, SMILESString [defualt: LMID]
- exactMatch
-
Boolean [defualt: yes]
- outputtype
-
TSV, CSV, SDF or MDLMOL [defualt: TSV]
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/sylfy/service/lipidmaprest.rb', line 97 def lmsdStrSearch(string, field = 'LMID', exactMatch = true, outputtype = "TSV") searchType = exactMatch ? 'ExactMatch' : 'SubStructure' if ['LMID', 'Name', 'Formula', 'SMILESString'].include?(field) return lmsdSearch("#{field}=#{URI.encode(string)}&SearchType=#{searchType}", "ProcessStrSearch", outputtype) else raise Sylfy::Service::ParameterError, "#{field} field does not in service." end end |
.lmsdTxtSearch(hash, outputtype = "TSV") ⇒ Object
Method for setting inchi data member
Parameters:
- hash
-
searh hash
:LMID => LM_ID, :Name => part of any common name, :Formula => formula, :ExactMass => positive number, :ExactMassOffSet => positive number, :CoreClass => integer [1 to 8], 1=Fatty Acyls [FA] 2=Glycerolipids [GL] 3=Glycerophospholipids [GP] 4=Sphingolipids [SP] 5=Sterol Lipids [ST] 6=Prenol Lipids [PR] 7=Saccharolipids [SL] 8=Polyketides [PK] :MainClass => integer, e.g. FA10=101 FA11=111 ST05=505 :SubClass => integer e.g. ST0402=50402
- outputtype
-
TSV, CSV, SDF or MDLMOL [defualt: TSV]
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/sylfy/service/lipidmaprest.rb', line 139 def lmsdTxtSearch(hash, outputtype = "TSV") string = '' hash.each_pair do |k, v| string += '&' if string != '' string += "#{k.to_s}=#{v}" end return lmsdSearch(string, "ProcessTextSearch", outputtype) end |