Patterns of locomotor activity of a freely moving organism can help characterize its
behavioral phenotypes. To infer behavior from such activity in Drosophila melanogaster, we use a
real-time image acquisition system to track the movement of multiple flies in three dimensions. When
dealing with fly movement trajectories, we must take into account that similar movement patterns can
be expressed in different orientations and speeds. In this paper, we present methods to transform the
three-dimensional fly movement trajectories into a space that is translation, rotation, scale and timescale
invariant. We then propose an approach motivated by sequence alignment to detect similar
movement patterns from fly trajectories in order to infer specific behaviors. We demonstrate the
accuracy of the methods and highlight their usefulness in studies aimed at characterizing behavioral
phenotypes.