Sha256: 959499cb2943c3386833018109fe37ae077786a0415587798a7fc01f0f09d40c

Contents?: true

Size: 1.27 KB

Versions: 37

Compression:

Stored size: 1.27 KB

Contents

require 'bel_parser/vendor/ast'
require 'bel_parser/parsers/ast/node'
require 'bel_parser/language/term_transformation'

module BELParser
  module Language
    module Version1_0
      module Upgrades
        class ProteinModificationTransformation
          include AST::Processor::Mixin
          include BELParser::Parsers::AST::Sexp
          include BELParser::Language::TermTransformation

          def on_term(term_node)
            if ['pmod', 'proteinmodification'].include?(term_node.function.identifier.string_literal)
              # straightforward replacement of first argument to pmod with pmodtype value
              term_node.updated([term_node.function, update_pmod(term_node.arguments[0]), term_node.arguments[1], term_node.arguments[2] ].flatten)
            else
              term_node.updated([process(term_node.function), term_node.arguments.map! {|arg| process(arg)}].flatten())
            end
          end

          def update_pmod(argument_node)
            param_value = argument_node.child.value.children[0].string_literal
            argument(
              parameter(
                prefix(
                  identifier('default')),
                value(
                  identifier(PMODTYPES[param_value]))))
          end
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
bel_parser-1.1.6-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.6 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.5 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.4-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.4 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.3-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.3 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.2-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.2 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.1-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.1.1 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.8-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.8 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.7-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.7 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.6-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.6 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.5-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.5 lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb
bel_parser-1.0.4-java lib/bel_parser/language/version1_0/upgrades/protein_modification_transformation.rb