Return a record to be used for database storage. This only makes sense if self.id is set. See usage example
           above.

def get_pdb_sets(self):
        '''Return a record to be used for database storage. This only makes sense if self.id is set. See usage example
           above.'''

        assert(self.id != None)

        data = []
        for pdb_set in self.pdb_sets:

            pdb_set_record = dict(
                PPComplexID = self.id,
                SetNumber = pdb_set['set_number'],
                IsComplex = pdb_set['is_complex'],
                Notes = pdb_set['notes'],
            )

            chain_records = []
            for side, chain_details in sorted(pdb_set['chains'].iteritems()):
                chain_records.append(dict(
                    PPComplexID = self.id,
                    SetNumber = pdb_set['set_number'],
                    Side = side,
                    ChainIndex = chain_details['chain_index'],
                    PDBFileID = chain_details['pdb_file_id'],
                    Chain = chain_details['chain_id'],
                    NMRModel = chain_details['nmr_model'],
                ))

            data.append(dict(pdb_set = pdb_set_record, chain_records = chain_records))

        return data