# Buggy code
def generate_pan_db(self):
    meta_values = {
        "internal_genome_names": ",".join(self.internal_genome_names),
        "external_genome_names": ",".join(self.external_genome_names),
        "num_genomes": len(self.genomes),
        "min_percent_identity": self.min_percent_identity,
        "pc_min_occurrence": self.PC_min_occurrence,
        "mcl_inflation": self.mcl_inflation,
        "default_view": "PC_presence_absence",
        "use_ncbi_blast": self.use_ncbi_blast,
        "diamond_sensitive": self.sensitive,
        "minbit": self.minbit,
        "exclude_partial_gene_calls": self.exclude_partial_gene_calls,
        "gene_alignments_computed": False if self.skip_alignments else True,
        "genomes_storage_hash": self.genomes_storage_hash,
        "project_name": self.project_name,
        "PCs_clustered": False,
        "description": self.description
        if self.description
        else "_No description is provided_",
    }

    dbops.PanDatabase(self.pan_db_path, quiet=False).create(meta_values)


# Traceback (KeyError)
Traceback (most recent call last):
File "/home/vnsriniv/virtual-envs/anvio/bin/anvi-display-pan", line 4, in <module>
__import__('pkg_resources').run_script('anvio===3-master', 'anvi-display-pan')
File "/home/vnsriniv/virtual-envs/anvio/lib/python3.5/site-packages/pkg_resources/__init__.py", line 748, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/home/vnsriniv/virtual-envs/anvio/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1517, in run_script
exec(code, namespace, namespace)
File "/home/vnsriniv/virtual-envs/anvio/lib/python3.5/site-packages/anvio-3_master-py3.5-linux-x86_64.egg/EGG-INFO/scripts/anvi-display-pan", line 75, in <module>
d = interactive.Interactive(args)
File "/home/vnsriniv/virtual-envs/anvio/lib/python3.5/site-packages/anvio-3_master-py3.5-linux-x86_64.egg/anvio/interactive.py", line 155, in __init__
self.load_pan_mode()
File "/home/vnsriniv/virtual-envs/anvio/lib/python3.5/site-packages/anvio-3_master-py3.5-linux-x86_64.egg/anvio/interactive.py", line 744, in load_pan_mode
PanSuperclass.__init__(self, self.args)
File "/home/vnsriniv/virtual-envs/anvio/lib/python3.5/site-packages/anvio-3_master-py3.5-linux-x86_64.egg/anvio/dbops.py", line 784, in __init__
if self.p_meta['PCs_ordered']:
KeyError: 'PCs_ordered'

# Fixed code
def generate_pan_db(self):
    meta_values = {
        "internal_genome_names": ",".join(self.internal_genome_names),
        "external_genome_names": ",".join(self.external_genome_names),
        "num_genomes": len(self.genomes),
        "min_percent_identity": self.min_percent_identity,
        "pc_min_occurrence": self.PC_min_occurrence,
        "mcl_inflation": self.mcl_inflation,
        "default_view": "PC_presence_absence",
        "use_ncbi_blast": self.use_ncbi_blast,
        "diamond_sensitive": self.sensitive,
        "minbit": self.minbit,
        "exclude_partial_gene_calls": self.exclude_partial_gene_calls,
        "gene_alignments_computed": False if self.skip_alignments else True,
        "genomes_storage_hash": self.genomes_storage_hash,
        "project_name": self.project_name,
        "PCs_ordered": False,
        "description": self.description
        if self.description
        else "_No description is provided_",
    }

    dbops.PanDatabase(self.pan_db_path, quiet=False).create(meta_values)