Class: GlyDevKit::WURCSFramework

Inherits:
Object
  • Object
show all
Defined in:
lib/glydevkit/wurcs_frame_work.rb

Instance Method Summary collapse

Instance Method Details

#get_anomeric_status(a_o_backbone) ⇒ String?

Retrieves the anomeric status of a backbone.

Examples:

status = get_anomeric_status(backbone)

Parameters:

  • a_o_backbone (Backbone)

    The backbone object to evaluate.

Returns:

  • (String, nil)

    A string representing the anomeric status, or nil if it cannot be determined.



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/glydevkit/wurcs_frame_work.rb', line 62

def get_anomeric_status(a_o_backbone)
  a_o_backbone.get_backbone_carbons.each do |t_o_bc|
    return "archetype_anomer" if %w[u U].include?(t_o_bc.get_descriptor.get_char.chr)
  end

  case a_o_backbone.get_anomeric_symbol.chr
  when 'x'
    "anomer_unknown"
  when 'a'
    "anomer_alpha"
  when 'b'
    "anomer_beta"
  else
    a_o_backbone.get_anomeric_position != 0 ? "openchain" : nil
  end
end

#get_ring_type(a_o_backbone) ⇒ String?

Retrieves the ring type of a backbone.

Parameters:

  • a_o_backbone (Object)

    Backbone object

Returns:

  • (String, nil)

    Ring type as a string or nil if not applicable



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/glydevkit/wurcs_frame_work.rb', line 84

def get_ring_type(a_o_backbone)
  a_o_backbone.get_backbone_carbons.each do |t_o_bc|
    return "archetype_ringtype" if %w[u U].include?(t_o_bc.get_descriptor.get_char.chr)
  end

  a_o_backbone.get_edges.each do |edge|
    next unless edge.is_anomeric && edge.get_modification.is_ring

    ring_start = edge.get_linkages[0].get_backbone_position
    ring_end = edge.get_modification.get_edges[1].get_linkages[0].get_backbone_position
    ring_size = ring_end - ring_start

    return case ring_size
           when 6 then "octanose"
           when 5 then "septanose"
           when 4 then "pyranose"
           when 3 then "furanose"
           when 2 then "oxetose"
           when 1 then "oxirose"
           end
  end
  nil
end

#getWURCSMass(w) ⇒ Float?

Calculates the mass of a WURCS data string.

Parameters:

  • w (String)

    WURCS format data

Returns:

  • (Float, nil)

    Mass or nil if an error occurs



112
113
114
115
116
117
118
119
# File 'lib/glydevkit/wurcs_frame_work.rb', line 112

def getWURCSMass(w)
  importer = WURCSImporter.new
  wurcs_array = importer.extractWURCSArray(w)
  WURCSMassCalculator.calcMassWURCS(wurcs_array)
rescue WURCSException, WURCSMassException, StandardError => e
  e.printStackTrace
  nil
end

#to_graph(w) ⇒ Object?

Converts WURCS data to a graph object.

Parameters:

  • w (String)

    WURCS format data

Returns:

  • (Object, nil)

    Graph object or nil if an error occurs



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/glydevkit/wurcs_frame_work.rb', line 43

def to_graph(w)
  wgn = WURCSGraphNormalizer.new
  begin
    factory = WURCSFactory.new(w)
    graph = factory.getGraph
    wgn.start(graph)
    graph
  rescue WURCSException => e
    e.printStackTrace
    nil
  end
end

#validator(w, maxbranch) ⇒ Hash

Validates a WURCS data string.

Examples:

wurcs = "WURCS=2.0/3,5,4/[a2122h-1b_1-5_2*NCC/3=O][a1122h-1b_1-5][a1122h-1a_1-5]/1-1-2-3-3/a4-b1_b4-c1_c3-d1_c6-e1"
result = validator(wurcs, 10)

Parameters:

  • w (String)

    The WURCS string to be validated.

  • maxbranch (Integer)

    The maximum allowed branch count for validation.

Returns:

  • (Hash)

    A hash containing the validation results, including any warnings, errors, and unverifiable issues.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/glydevkit/wurcs_frame_work.rb', line 20

def validator(w, maxbranch)
  validator = WURCSValidator.new
  validator.setMaxBranchCount(maxbranch)
  validator.start(w)
  report = validator.getReport()

  {
    "message" => {
      "VALIDATOR" => ["WURCSFramework-1.2.14"],
      "WARNING" => report.hasWarning(),
      "ERROR" => report.hasError(),
      "UNVERIFIABLE" => report.hasUnverifiable()
    },
    "StandardWURCS" => report.standard_string(),
    "RESULTS" => report.getResults()
  }
end