A free-rotating and self-avoiding chain model for deriving statistical potentials based on protein structures