Computing minimum distortion embeddings into a path for bipartite permutation graphs and threshold graphs