Example #1
0
    def __read_reac_prop(self):
        '''Read reaction properties and create Nodes.'''
        reac_prop_keys = [
            'id', 'equation', 'description', 'balance', 'ec', 'Source'
        ]

        for values in self.__read_data('reac_prop.tsv'):
            if not values[0].startswith('#'):
                values[0] = self.__parse_id(values[0])
                values[5] = self.__parse_id(values[5])

                props = dict(zip(reac_prop_keys, values))
                props.pop('Source')

                try:
                    participants = chem_utils.parse_equation(
                        props.pop('equation'))

                    for participant in participants:
                        participant[0] = self.__parse_id(participant[0])

                        if participant[0] not in self.__chem_data:
                            self.__add_chem(participant[0])

                    props['reac_defn'] = participants
                    self.__reac_data[values[0]] = props
                except ValueError:
                    print 'WARNING: Suspected polymerisation reaction: ' + \
                        values[0] + '\t' + str(props)
Example #2
0
    def __read_reac_prop(self):
        '''Read reaction properties and create Nodes.'''
        reac_prop_keys = ['id', 'equation', 'description', 'balance', 'ec',
                          'Source']

        for values in self.__read_data('reac_prop.tsv'):
            if not values[0].startswith('#'):
                values[0] = self.__parse_id(values[0])
                values[5] = self.__parse_id(values[5])

                props = dict(zip(reac_prop_keys, values))
                props.pop('Source')

                try:
                    participants = chem_utils.parse_equation(
                        props.pop('equation'))

                    for participant in participants:
                        participant[0] = self.__parse_id(participant[0])

                        if participant[0] not in self.__chem_data:
                            self.__add_chem(participant[0])

                    props['reac_defn'] = participants
                    self.__reac_data[values[0]] = props
                except ValueError:
                    print 'WARNING: Suspected polymerisation reaction: ' + \
                        values[0] + '\t' + str(props)
 def test_parse_equation(self):
     '''Tests parse_equation method.'''
     eqn = '5.6 Fe4S + -3.2 water = 17.8 SiO2'
     self.assertEqual(chm_util.parse_equation(eqn),
                      [['Fe4S', -5.6], ['water', 3.2], ['SiO2', 17.8]])
 def test_parse_equation(self):
     '''Tests parse_equation method.'''
     eqn = '5.6 Fe4S + -3.2 water = 17.8 SiO2'
     self.assertEqual(chm_util.parse_equation(eqn),
                      [['Fe4S', -5.6], ['water', 3.2], ['SiO2', 17.8]])