The new program DYANA (DYnamics Algorithm for Nmr Applications) for efficient calculation of three-dimensional protein and nucleic acid structures from distance constraints and torsion angle constraints collected by nuclear magnetic resonance (NMR) experiments performs simulated annealing by molecular dynamics in torsion angle space and uses a fast recursive algorithm to integrate the equations of motions. Torsion angle dynamics can be more efficient than molecular dynamics in Cartesian coordinate space because of the reduced number of degrees of freedom and the concomitant absence of high-frequency bond and angle vibrations, which allows for the use of longer time-steps and/or higher temperatures in the structure calculation. It also represents a significant advance over the variable target function method in torsion angle space with the REDAC strategy used by the predecessor program DIANA. DYANA computation times per accepted conformer in the "bundle" used to represent the NMR structure compare favorably with those of other presently available structure calculation algorithms, and are of the order of 160 seconds for a protein of 165 amino acid residues when using a DEC Alpha 8400 5/300 computer. Test calculations starting from conformers with random torsion angle values further showed that DYANA is capable of efficient calculation of high-quality protein structures with up to 400 amino acid residues, and of nucleic acid structures.