Class: GlyDevKit::GlycanFormatConverter
- Inherits:
-
Object
- Object
- GlyDevKit::GlycanFormatConverter
- Defined in:
- lib/glydevkit/glycan_format_converter.rb
Instance Method Summary collapse
-
#iupac2wurcs(iupac, style) ⇒ Hash
Converts an IUPAC string to WURCS format.
-
#wurcs2glycam(wurcs) ⇒ String
Converts a WURCS string to GLYCAM format.
-
#wurcs2glycoct(wurcs) ⇒ Hash
Converts a WURCS string to GlycoCT format.
-
#wurcs2iupac(wurcs, style) ⇒ Hash
Converts a WURCS string to IUPAC format.
Instance Method Details
#iupac2wurcs(iupac, style) ⇒ Hash
Converts an IUPAC string to WURCS format.
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/glydevkit/glycan_format_converter.rb', line 117 def iupac2wurcs(iupac, style) ret = {} ret["input"] = iupac begin if style == "condensed" ici = IUPACCondensedImporter.new gc = ici.start(iupac) else iei = IUPACExtendedImporter.new gc = iei.start(iupac) end ee = ExporterEntrance.new(gc) wurcs = ee.toWURCS ret["wurcs"] = wurcs rescue GlyCoImporterException, GlycanException, WURCSException => e ret["message"] = e.to_s rescue StandardError => e ret["message"] = e.to_s end return ret end |
#wurcs2glycam(wurcs) ⇒ String
Converts a WURCS string to GLYCAM format.
98 99 100 101 102 103 104 105 106 |
# File 'lib/glydevkit/glycan_format_converter.rb', line 98 def wurcs2glycam(wurcs) wi = WURCSImporter.new ee = ExporterEntrance.new(wi.start(wurcs)) begin ee.toIUPAC(IUPACStyleDescriptor::GLYCANWEB) rescue => e e.printStackTrace() end end |
#wurcs2glycoct(wurcs) ⇒ Hash
Converts a WURCS string to GlycoCT format.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/glydevkit/glycan_format_converter.rb', line 69 def wurcs2glycoct(wurcs) ret = {} ret["input"] = wurcs begin converter = WURCSToGlycoCT.new converter.start(wurcs) = converter.getErrorMessages if .empty? ret["GlycoCT"] = converter.getGlycoCT ret["message"] = "" else ret["GlycoCT"] = "" ret["message"] = end rescue Exception => e ret["GlycoCT"] = "" ret["message"] = e.to_s end return ret end |
#wurcs2iupac(wurcs, style) ⇒ Hash
Converts a WURCS string to IUPAC format.
31 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/glydevkit/glycan_format_converter.rb', line 31 def wurcs2iupac(wurcs, style) ret = {} ret["input"] = wurcs begin wi = WURCSImporter.new gc = wi.start(wurcs) ee = ExporterEntrance.new(gc) if style == "condensed" iupaccondensed = ee.toIUPAC(IUPACStyleDescriptor::CONDENSED) ret["IUPACcondensed"] = iupaccondensed elsif style == "extended" iupacextended = ee.toIUPAC(IUPACStyleDescriptor::GREEK) ret["IUPACextended"] = iupacextended else glycam = ee.toIUPAC(IUPACStyleDescriptor::GLYCANWEB) ret["GLYCAM"] = glycam end rescue GlyCoExporterException, GlycanException, TrivialNameException, WURCSException => e logger.error("{}", e) ret["message"] = e.to_s rescue Exception => e logger.error("{}", e) ret["message"] = e.to_s end return ret end |