# OEMolRecord¶

OEMolRecord is a specialized OERecord with some extra methods for handling molecules. The presence of convenience methods for handling molecules is the only difference between an OEMolRecord and an OERecord. The underlying representation is identical, and either class can be copy-constructed from the other with no loss of information.

The following example shows how an OEMolRecord can be used, and illustrates that OEMolRecords are just OERecords with some additional methods.

OEMol toluene;
OESmilesToMol(toluene, "c1ccccc1C");
OEMolRecord molRecord;
molRecord.SetMol(toluene);  // Sets the molecule on a field named "Molecule"
cout <<  molRecord.HasMol() << endl;  // true
OEMol betterBeToluene = molRecord.GetMol();

// Show that an OEMolRecord is just an OERecord underneath
auto moleculeField = molRecord.GetPrimaryMolField();
OERecord normalRecord(molRecord);
cout << normalRecord.HasField(moleculeField) << endl;  // true
OEMolRecord otherMolRecord(normalRecord);
cout << otherMolRecord.HasMol() << endl;  // true


## Conformer data on records¶

OEMolRecord also has methods for managing data for conformers. Each conformer of a molecule can get its own record to store conformer-specific data onto.

// Create some empty conformers
const OEConfBase *conf1 = toluene.NewConf();
const OEConfBase *conf2 = toluene.NewConf();

// We'll attach a record to each conformer
auto scoreField = OEMakeField("score", Types::Float);
OERecord conf1Record = molRecord.GetConfRecord(conf1);
OERecord conf2Record = molRecord.GetConfRecord(conf1);

// Now we put a score onto each conformer's record
conf1Record.SetValue(scoreField, 10.0);
molRecord.SetConfRecord(conf1, conf1Record);

conf2Record.SetValue(scoreField, 20.0);
molRecord.SetConfRecord(conf2, conf2Record);

/* IMPORTANT: You must set the conformers' parent molecule on the record
at some point after setting conformer records and before the record is
saved. Otherwise the conformer data will be lost. */
molRecord.SetMol(toluene);

// We only set a single value for each conformer, but we could have
// put any number of fields and values on each conformer's record.
cout << molRecord.GetConfRecord(conf2).GetValue(scoreField) << endl;  // 20.0