As first shown by Anfinsen (1973), protein folding is a reversible process: under "denaturing" conditions, proteins typically unfold into a random state (which still preserves the chain connectivity of the primary amino acid sequence), and refold again into their unique native state if the natural folding conditions are restored.
all the information that is necessary to determine the folded structure has to be encoded in the primary sequence.