DNA conformation in complex with proteins is far from its canonical B-form. The affinity of complex formation and structure of DNA depend on its attachment configuration and sequence. In this article, we develop a mechanical model to address the problem of DNA structure and energy under deformation. DNA in nucleosome core particle is described as an example. The structure and energy of nucleosomal DNA is calculated based on its sequence and positioning state. The inferred structure has remarkable similarity with X-ray data. Although there is no sequence-specific interaction of bases and the histone core, we found considerable sequence dependency for the nucleosomal DNA positioning. The affinity of nucleosome formation for several sequences is examined and the differences are compatible with observations. We argue that structural energy determines the natural state of nucleosomal DNA and is the main reason for affinity differences in vitro. This theory can be utilized for the DNA structure and energy determination in protein–DNA complexes in general.An animated Interactive 3D Complement (I3DC) is available in Proteopedia at http://proteopedia.org/w/Journal:JBSD:17