getLength function

Generic function to get the length of sequences