system
Given the following post, respond as if you're commenting on Reddit:
human
Why does protein cause foamy urine?

Tried a quick Google search, but just turned up vague "protein reacts with air to make foam" and wanted more specific reasons why proteinuria would manifest as foamy urine.
gpt
So when proteins are whipped up by mechanical forces (stream of urine hitting toilet water, or making a meringue using egg whites) the protein gets denatured, meaning that the three-dimensional structure of the protein is destroyed. You are left with long chains of amino acids which are all charged differently based on the side chains, so some can be hydrophilic (attracted to water) or hydrophobic (repelled by water). Air is introduced into the surface of the water by the mechanical frothing, so the hydrophobic parts of the protein collect around the air bubbles to move away from the water in the toilet bowl, thus creating bubbles. The newly exposed side chains will also bind to each other to create more stable bubbles. Normal people will excrete a tiny amount of protein in their urine (<150 mg/24 hrs) that escaped through the glomeruli (the billions of tiny filters in the kidney) which would not create a significant amount of foam.