def does_match_composition(self, formula1, formula2): c1 = Composition(formula1) c2 = Composition(formula2) return(c1.almost_equals(c2))
'Alphabetic Formula'] form = form.replace('[', '') form = form.replace(']', '') try: redform = Composition(form).reduced_formula except: print 'Could not parse composition for key:{} with composition:{}'.format( doc['key'], form) y += 1 continue alphaform_comp = Composition(redform).alphabetical_formula alphaform_frac = Composition(alphaform_comp).fractional_composition structure_comp = doc['metadata']['_structure'][ 'reduced_cell_formula_abc'] structure_frac = Composition(structure_comp).fractional_composition if alphaform_frac != structure_frac and not alphaform_frac.almost_equals( structure_frac, 0.15): for document in db['pauling_file'].find({'key': doc['key']}): try: struct_lst = CifParser.from_string( document['cif_string']).get_structures() except: pass if len(struct_lst) > 1: matched = False for struct in struct_lst[1:]: another_frac = Composition( struct.composition).fractional_composition if alphaform_frac == another_frac or alphaform_frac.almost_equals( another_frac, 0.15): matched = True # '''
form = doc['metadata']['_Springer']['geninfo']['Refined Formula'] else: form = doc['metadata']['_Springer']['geninfo']['Alphabetic Formula'] form = form.replace('[', '') form = form.replace(']', '') try: redform = Composition(form).reduced_formula except: print 'Could not parse composition for key:{} with composition:{}'.format(doc['key'], form) y += 1 continue alphaform_comp = Composition(redform).alphabetical_formula alphaform_frac = Composition(alphaform_comp).fractional_composition structure_comp = doc['metadata']['_structure']['reduced_cell_formula_abc'] structure_frac = Composition(structure_comp).fractional_composition if alphaform_frac != structure_frac and not alphaform_frac.almost_equals(structure_frac, 0.15): for document in db['pauling_file'].find({'key': doc['key']}): try: struct_lst = CifParser.from_string(document['cif_string']).get_structures() except: pass if len(struct_lst) > 1: matched = False for struct in struct_lst[1:]: another_frac = Composition(struct.composition).fractional_composition if alphaform_frac == another_frac or alphaform_frac.almost_equals(another_frac, 0.15): matched = True # ''' db['pauling_file'].update({'key': doc['key']}, {'$set': {'structure': struct.as_dict()}}) db['pauling_file'].update({'key': doc['key']}, { '$set': {'metadata._structure': get_meta_from_structure(struct)}})