The James Clerk Maxwell telescope Legacy Survey of the Gould Belt: a molecular line study of the Ophiuchus molecular cloud