Outer membrane protein G (OmpG) from Escherichia coli has exhibited pH-dependent gating that can be employed by bacteria to alter the permeability of their outer membranes in response to environmental changes. We developed a computational model, Protein Topology of Zoetic Loops (Pretzel), to investigate the roles of OmpG extracellular loops implicated in gating. The key interactions predicted by our model were verified by single-channel recording data. Our results indicate that the gating equilibrium is primarily controlled by an electrostatic interaction network formed between the gating loop and charged residues in the lumen. The results shed light on the mechanism of OmpG gating and will provide a fundamental basis for the engineering of OmpG as a nanopore sensor. Our computational Pretzel model could be applied to other outer membrane proteins that contain intricate dynamic loops that are functionally important.