Try to rescue a gene symbol
 @param symbol [String] Gene symbol
 @param method [Symbol] :auto or :manual
 @param rehearsal [Boolean] When set to true, neither outputing warnings nor modifying rescue history
 @return [String] "" if rescue failed
760241
def rescue_symbol(symbol, method = @rescue_method, rehearsal = false)
      return @rescue_history[symbol] if @rescue_history[symbol]

      case method
      when :auto
        auto_rescue = ''

        if @symbol2hgncid[symbol.upcase]
          auto_rescue = symbol.upcase
        elsif @symbol2hgncid[symbol.downcase]
          auto_rescue = symbol.downcase
        elsif @symbol2hgncid[symbol.delete('-')]
          auto_rescue = symbol.delete('-')
        elsif @symbol2hgncid[symbol.upcase.delete('-')]
          auto_rescue = symbol.upcase.delete('-')
        elsif @symbol2hgncid[symbol.downcase.delete('-')]
          auto_rescue = symbol.downcase.delete('-')
          # Add more rules here
        end

        # Record
        unless rehearsal
          BioTCM.logger.warn('HGNC') { "Unrecognized symbol \"#{symbol}\", \"#{auto_rescue}\" used instead" }
          @rescue_history[symbol] = auto_rescue
        end

        return auto_rescue
      when :manual
        # Try automatic rescue first
        if (auto_rescue = rescue_symbol(symbol, :auto, true)) != ''
          print "\"#{symbol}\" unrecognized. Use \"#{auto_rescue}\" instead? [Yn] "
          unless gets.chomp == 'n'
            @rescue_history[symbol] = auto_rescue unless rehearsal # rubocop:disable Metrics/BlockNesting
            return auto_rescue
          end
        end

        # Manually rescue
        loop do
          print "Please correct \"#{symbol}\" or press enter directly to return empty String instead:\n"
          unless (manual_rescue = gets.chomp) == '' || @symbol2hgncid[manual_rescue]
            puts "Failed to recognize \"#{manual_rescue}\""
            next
          end
          unless rehearsal
            @rescue_history[symbol] = manual_rescue
            File.open(@rescue_history_filepath, 'a').print(symbol, "\t", manual_rescue, "\n")
          end
          return manual_rescue
        end
      end
    end
329508
def method_missing(meth, *args, &block)
      if args.empty? && !block_given? && (match = /\Ato_(\w+)\Z/.match(meth.to_s))
        begin
          convert_to(match[1])
        rescue ExpressionError
          super(meth, *args, &block)
        end
      else
        super(meth, *args, &block)
      end
    end
1284650
def _method_error_handler(self, response: Dict[str, Any]):
        
        exp = response.get('MESSAGE')
        code = response.get("CODE")
        ID = exp.get("ID")
        e = abort(code, ID=ID, message=exp.get('MESSAGE'))
        self.tasks[ID].set_exception(e)
        return True
390084
boolean attemptClearSymbolIDValues()
    {
        boolean sidsRemain = false;
        if (_fieldName != null)
        {
            _fieldId = UNKNOWN_SYMBOL_ID;
        } else if (_fieldId > UNKNOWN_SYMBOL_ID)
        {
            // retaining the field SID, as it couldn't be cleared due to loss of context
            // TODO - for SID handling consistency; this should attempt resolution first
            sidsRemain = true;
        }

        if (_annotations != null)
        {
            for (int i = 0; i < _annotations.length; i++)
            {
                SymbolToken annotation = _annotations[i];

                // _annotations may have nulls at the end.
                if (annotation == null) break;

                String text = annotation.getText();
                // TODO - for SID handling consistency; this should attempt resolution first, not just drop entry
                if (text != null && annotation.getSid() != UNKNOWN_SYMBOL_ID)
                {
                    _annotations[i] =
                        newSymbolToken(text, UNKNOWN_SYMBOL_ID);
                }
            }
        }

        return !sidsRemain;
    }
321349
def are_genes_in_api(my_clue_api_client, gene_symbols):
    
    if len(gene_symbols) > 0:
        query_gene_symbols = gene_symbols if type(gene_symbols) is list else list(gene_symbols)

        query_result = my_clue_api_client.run_filter_query(resource_name,
            {"where":{"gene_symbol":{"inq":query_gene_symbols}}, "fields":{"gene_symbol":True}})
        logger.debug("query_result:  {}".format(query_result))

        r = set([x["gene_symbol"] for x in query_result])
        return r
    else:
        logger.warning("provided gene_symbols was empty, cannot run query")
        return set()
427696
private boolean isFeatureMethod(MethodNode method) {
    for (Statement stat : AstUtil.getStatements(method)) {
      String label = stat.getStatementLabel();
      if (label == null) continue;

      // assertion: is (meant to be) a feature method, so we'll return true in the end
      if (method.isStatic())
        errorReporter.error(method, "Feature methods must not be static");

      return true;
    }

    return false;
  }
535143
private static boolean hasErrors(Symbol symbol) {
    switch(symbol.kind) {
      case ALTERNATIVE:
        return hasErrors(symbol, ((Symbol.Alternative) symbol).symbols);
      case EXPLICIT_ACTION:
        return false;
      case IMPLICIT_ACTION:
        return symbol instanceof Symbol.ErrorAction;
      case REPEATER:
        Symbol.Repeater r = (Symbol.Repeater) symbol;
        return hasErrors(r.end) || hasErrors(symbol, r.production);
      case ROOT:
      case SEQUENCE:
        return hasErrors(symbol, symbol.production);
      case TERMINAL:
        return false;
      default:
        throw new RuntimeException("unknown symbol kind: " + symbol.kind);
    }
  }
1081329
def method_missing(method, *args, &block)
      # Check string keys first, original and downcase
      string_method = method.to_s

      if raw_hash.key?(string_method)
        return self[string_method]
      elsif raw_hash.key?(string_method.downcase)
        return self[string_method.downcase]
      end

      if string_method =~ /[A-Z+]/
        string_method = string_method.snakecase
      end

      index = string_method.downcase.to_sym
      # Check symbol key and return local hash entry.
      return self[index] if raw_hash.has_key?(index)
      # Then delegate to hash object.
      if raw_hash.respond_to?(method)
        return raw_hash.send(method, *args)
      end
      # Finally return nil.
      nil
    end
300042
private ProtoNetwork failGeneScaffolding(final ProtoNetwork pn,
            final StringBuilder bldr, String gsLocation, String errorMessage) {
        bldr.append("GENE SCAFFOLDING RESOURCE RESOLUTION FAILURE in ");
        bldr.append(gsLocation);
        bldr.append("\n\treason: ");
        bldr.append(errorMessage);
        stageWarning(bldr.toString());

        // could not resolve gene scaffolding resource so return original
        // proto network.
        return pn;
    }
781497
def method_missing(sym, *args, &block)
      cache_method_call(sym) if ::Builder::XmlBase.cache_method_calls
      tag!(sym, *args, &block)
    end
980578
function joinMethods(methods) {
  var mode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'value';
  var simpleJoinedMethod;
  var _iteratorNormalCompletion4 = true;
  var _didIteratorError4 = false;
  var _iteratorError4 = undefined;

  try {
    var _loop3 = function _loop3() {
      var method = _step4.value;
      var old = simpleJoinedMethod;

      if (old) {
        simpleJoinedMethod = function simpleJoinedMethod() {
          for (var _len4 = arguments.length, args = new Array(_len4), _key5 = 0; _key5 < _len4; _key5++) {
            args[_key5] = arguments[_key5];
          }

          return method.call.apply(method, [this, mode === 'value' ? old.call.apply(old, [this].concat(args)) : old].concat(args));
        };
      } else {
        simpleJoinedMethod = method;
      }
    };

    for (var _iterator4 = methods[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
      _loop3();
    }
  } catch (err) {
    _didIteratorError4 = true;
    _iteratorError4 = err;
  } finally {
    try {
      if (!_iteratorNormalCompletion4 && _iterator4.return != null) {
        _iterator4.return();
      }
    } finally {
      if (_didIteratorError4) {
        throw _iteratorError4;
      }
    }
  }

  return simpleJoinedMethod;
}
1018255
def method(self, symbol_name):
        

        s = self.symbol(symbol_name)

        def bind(fn):
            setattr(s, fn.__name__, fn)
        return bind
1247002
private <Analysis> Analysis getMethodAnalysisNoException(Class<Analysis> analysisClass, Method method) {
        try {
            return getMethodAnalysis(analysisClass, method);
        } catch (CheckedAnalysisException e) {
            IllegalStateException ise = new IllegalStateException("should not happen");
            ise.initCause(e);
            throw ise;
        }
    }
789284
def run_callback(method, *args)
      case method
      when Symbol
        send(method, *args)
      when Proc
        instance_exec(*args, &method)
      else
        raise "Please register with callbacks using a symbol or a block/proc."
      end
    end
1361772
def _try_prop_method(self, instance, value, method_name):
        
        error_messages = []
        for prop in self.props:
            try:
                return getattr(prop, method_name)(instance, value)
            except GENERIC_ERRORS as err:
                if hasattr(err, 'error_tuples'):
                    error_messages += [
                        err_tup.message for err_tup in err.error_tuples
                    ]
        if error_messages:
            extra = 'Possible explanation:'
            for message in error_messages:
                extra += '\n    - {}'.format(message)
        else:
            extra = ''
        self.error(instance, value, extra=extra)
925446
private void genMethodTypeSignature(ExecutableElement method, StringBuilder sb) {
    genOptFormalTypeParameters(method.getTypeParameters(), sb);
    sb.append('(');
    for (VariableElement param : method.getParameters()) {
      genTypeSignature(param.asType(), sb);
    }
    sb.append(')');
    genTypeSignature(method.getReturnType(), sb);
    List<? extends TypeMirror> thrownTypes = method.getThrownTypes();
    if (hasGenericSignature(thrownTypes)) {
      for (TypeMirror thrownType : thrownTypes) {
        sb.append('^');
        genTypeSignature(thrownType, sb);
      }
    }
  }
684526
def method_missing meth, *args, &block
      meth_s = meth.to_s
      if @method && meth_s =~ API_REGEX

        if meth_s.end_with?('!')
          # `foo! bar' is syntactic sugar for `foo.! bar'
          self[meth_s[0...-1]].!(args[0] || {})

        else
          # chain the method name onto URL path
          self[meth_s]
        end
      else
        super
      end
    end