X-ray emission from pre-main-sequence stars, molecular clouds and star formation