Edit distance for structured motifs