def convert_compartment_entry(self, compartment, adjacencies):
d = OrderedDict()<EOL>d['<STR_LIT:id>'] = compartment.id<EOL>if adjacencies is not None:<EOL><INDENT>d['<STR_LIT>'] = adjacencies<EOL><DEDENT>order = {key: i for i, key in enumerate(['<STR_LIT:name>'])}<EOL>prop_keys = set(compartment.properties)<EOL>for prop in sorted(prop_keys,<EOL>key=lambda x: (order.get(x, <NUM_LIT:1000>), x)):<EOL><INDENT>if compartment.properties[prop] is not None:<EOL><INDENT>d[prop] = compartment.properties[prop]<EOL><DEDENT><DEDENT>return d<EOL>
Convert compartment entry to YAML dict.

        Args:
            compartment: :class:`psamm.datasource.entry.CompartmentEntry`.
            adjacencies: Sequence of IDs or a single ID of adjacent
                compartments (or None).