How to Keyframing and Posing Bones based on Head and Tail Data

I am trying to create a custom armature that fits motion capture data. The data gives me head and tail coordinates for bones across a number of frames.

For example, in Frame 1, bone1.head = Vector(1.0, 2.0, 3.0) and bone1.tail = Vector(1.5, 2.0, 3.0) in Frame 2, bone1.head = Vector(0.0, 2.0, 3.0) and bone1.tail = Vector(0.5, 2.0, 3.0)

I can set the frames properly, but when I use keyframe_insert(data_path="rotation_quaternion" or keyframe_insert(data_path="location"), the animation never changes. Perhaps this is because I don't change anything in the POSE mode, all my edits are made in EDIT mode, since I have to changehead and tail.

To fix this, I've tried calculating the rotation quaternion difference between the vectors and changing that in POSE mode, but I got stuck there as well.

Given bone data structured by head and tail coordinates, what is the best way to keyframe_insert so that the rotation and translation changes are captured?