Experiments show that MgSO4 salt has a non-monotonic effect as a function of MgSO4 concentration on the ejection of DNA from bacteriophage lambda. There is a concentration, N0, at which the minimum amount of DNA is ejected.At lower or higher concentrations, more DNA is ejected. We propose that this non-monotonic behavioris due to the overcharging of DNA at high concentration of Mg⁺² counterions.As the Mg⁺² concentration increases from zero, the net charge of ejected DNA changes its sign from negative to positive.N0 corresponds to the concentration at which DNA is neutral.Our theory fits experimental data well.The DNA-DNA electrostatic attraction is found to be -0.004 kBT/nucleotide.Simulations of DNA-DNA interaction of a hexagonal DNA bundle support our theory.They also show the non-monotonic DNA-DNA interaction and reentrant behavior of DNA condensation by divalent counterions.Three problems in understanding the capsid assembly for a retrovirus are studied:First, the way in which the viral membrane affects the structure of in vivo assembled HIV-1 capsid is studied.We show that conical and cylindrical capsids have similar energy at high surface tension of the viral membrane,which leads to the various shapes of HIV-1 capsids. Secondly, the problem of RNA genome packaging inside spherical virusesis studied using RNA condensation theory. For weak adsorption strength of capsid protein, most RNA genomes are located at the center of the capsid. For strong adsorption strength, RNA genomes peak near the capsid surface and the amount of RNA packaged is proportional to the capsid area instead its volume. Theory fits experimental data reasonably well.Thirdly, the condensation of RNA molecules by nucleocapsid (NC) protein is studied.The interaction between RNA molecules and NC proteins is important for the reverse transcription of viral RNA which relates to the viral infectivity.For strong adsorption strength of the NC protein, there is a screening effect by RNA molecules around a single NC protein.