Add the information of a compound variant

            This adds a compound dict to variant['compounds']

            Args:
                compound (dict): A compound dictionary
492504
def add_compound(self, compound):
        
        logger.debug("Adding compound {0} to variant {1}".format(
            compound, self['variant_id']))
        self['compounds'].append(compound)
1368321
def update(self, *args, **kwargs):
        """"""
        super(TAG_Compound, self).update(*args, **kwargs)
        for key, item in self.items():
            if item.name is None:
                item.name = key
43030
def _add_thousand_g(self, variant_obj, info_dict):
        
        thousand_g = info_dict.get('1000GAF')
        if thousand_g:
            logger.debug("Updating thousand_g to: {0}".format(
                thousand_g))
            variant_obj.thousand_g = float(thousand_g)
            variant_obj.add_frequency('1000GAF', variant_obj.get('thousand_g'))
1155736
def add_variant(self, variant):
        
        LOG.debug("Upserting variant: {0}".format(variant.get('_id')))
        
        update = self._get_update(variant)
        
        message = self.db.variant.update_one(
            {'_id': variant['_id']},
            update,
            upsert=True
        )
        if message.modified_count == 1:
            LOG.debug("Variant %s was updated", variant.get('_id'))
        else:
            LOG.debug("Variant was added to database for first time")
        return
866854
def _add_info(self, msg, **kwargs):
        

        args, extensions = self._filter_args(msg, **kwargs)
        for key, val in args.items():
            setattr(msg, key, val)

        if extensions:
            if msg.extension_elements:
                msg.extension_elements.extend(extensions)
            else:
                msg.extension_elements = extensions
1279764
def combine_dicts(*args, **kwargs):
    
    dicts = [arg for arg in args if isinstance(arg, dict)]
    dicts.append(kwargs)
    super_dict = collections.defaultdict(dict)

    for d in dicts:
        for k, v in iteritems(d):
            if k:
                super_dict[k] = v
    return dict(super_dict)
1166148
def convert_compound_entry(self, compound):
        """"""
        d = OrderedDict()
        d['id'] = compound.id

        order = {
            key: i for i, key in enumerate(
                ['name', 'formula', 'formula_neutral', 'charge', 'kegg',
                 'cas'])}
        prop_keys = (
            set(compound.properties) - {'boundary', 'compartment'})
        for prop in sorted(prop_keys,
                           key=lambda x: (order.get(x, 1000), x)):
            if compound.properties[prop] is not None:
                d[prop] = compound.properties[prop]

        return d
538569
def p_compound_variable(p):
    ''''''
    if len(p) == 2:
        p[0] = ast.Variable(p[1], lineno=p.lineno(1))
    else:
        p[0] = ast.Variable(p[3], lineno=p.lineno(1))
890188
def merge(self, other):
        """"""
        for key, value in other.items():
            if key in self and (isinstance(self[key], Compound)
                                and isinstance(value, dict)):
                self[key].merge(value)
            else:
                self[key] = value
999697
def merge(self, other):
        
        ignore = self.ignore
        extra = self.extras
        if isinstance(other, Dict):
            other_keys = other.keys
            ignore += other.ignore
            extra += other.extras
        elif isinstance(other, (list, tuple)):
            other_keys = list(other)
        elif isinstance(other, dict):
            return self.__class__(other, *self.keys)
        else:
            raise TypeError('You must merge Dict only with Dict'
                            ' or list of Keys')
        return self.__class__(*(self.keys + other_keys), ignore_extra=ignore,
                              allow_extra=extra)
521718
def add_ingredients(self):
        
        for ingredient in self.recipe._cauldron.values():
            if hasattr(ingredient.meta, 'anonymizer'):
                anonymizer = ingredient.meta.anonymizer

                # Build a FakerAnonymizer if we have a string
                if isinstance(anonymizer, basestring):

                    # Check for extra parameters
                    kwargs = {}
                    anonymizer_locale = getattr(
                        ingredient.meta, 'anonymizer_locale', None
                    )
                    anonymizer_postprocessor = getattr(
                        ingredient.meta, 'anonymizer_postprocessor', None
                    )
                    if anonymizer_postprocessor is not None:
                        kwargs['postprocessor'] = anonymizer_postprocessor
                    if anonymizer_locale is not None:
                        kwargs['locale'] = anonymizer_locale

                    anonymizer = FakerAnonymizer(anonymizer, **kwargs)

                # Strip out all FakerAnonymizers
                ingredient.formatters = [
                    f for f in ingredient.formatters
                    if not isinstance(f, FakerAnonymizer)
                ]
                if self._anonymize:
                    if ingredient.meta.anonymizer not in ingredient.formatters:
                        ingredient.formatters.append(anonymizer)
                else:
                    if ingredient.meta.anonymizer in ingredient.formatters:
                        ingredient.formatters.remove(anonymizer)
957089
def set_info(self, info):
        
        idx = info.get(self.name)
        if idx is not None:
            self.__dict__.update(idx)
1193904
def add_reaction(self, reaction_id):
        """"""

        if reaction_id in self._reaction_set:
            return

        reaction = self._database.get_reaction(reaction_id)
        self._reaction_set.add(reaction_id)
        for compound, _ in reaction.compounds:
            self._compound_set.add(compound)
1228688
def add_variables(
        self, variables: Union[List["Variable"], "Variable"], index: int = None
    ) -> None:
        
        if isinstance(variables, Variable):
            addvars = copy.deepcopy([variables])
        else:
            addvars = copy.deepcopy(variables)

        if index is None:
            self.variables.extend(addvars)
        else:
            self.variables[index:index] = addvars
621525
def _parse_compound_info(self, line):
        
        for k, regexes in six.iteritems(self.compound_regex):
            for reg in regexes:
                if self.compound_info[k]:
                    continue
                m = re.search(reg, line, re.IGNORECASE)
                if m:
                    self.compound_info[k] = m.group(1).strip()

        self._get_other_names(line)
1117433
def parse_compound(self):
        """"""
        compound_tag = Compound()

        for token in self.collect_tokens_until('CLOSE_COMPOUND'):
            item_key = token.value
            if token.type not in ('NUMBER', 'STRING', 'QUOTED_STRING'):
                raise self.error(f'Expected compound key but got {item_key!r}')

            if token.type == 'QUOTED_STRING':
                item_key = self.unquote_string(item_key)

            if self.next().current_token.type != 'COLON':
                raise self.error(f'Expected colon but got '
                                 f'{self.current_token.value!r}')
            self.next()
            compound_tag[item_key] = self.parse()
        return compound_tag
171955
def addVariantOld(self,
                      literal='',
                      sense=0,
                      gloss='',
                      examples=[]):
        '''

        '''
        var = Variant(literal=literal,
                      sense=sense,
                      gloss=gloss,
                      examples=examples)
        self.variants.append(var)