Stresses associated with a pig trap are calculated from its design pressure, which needs to at least match the design pressure of the attached pipeline and downstream piping. The design code for the trap provides the means of calculating stresses.
Which code? This depends on where the interface is defined between the pipeline to the trap and the downstream piping. If the trap is considered to be part of the pipeline, then it can be designed to ASME B31.4, ASME B31.8, or similar pipeline code. If part of the plant being fed by the pipeline, it can be designed to ASME B31.3 or similar pressure piping code. After all, the trap is basically bits of pipe welded together. You can also treat the trap as a pressure vessel and design to ASME VIII or similar PV code.