If you use the engine a lot, I would go for the Yanmar, assuming it's low hours, but not because it's the better engine, but because it's lighter and very likely more fuel efficient.
You can double that figure, however, for the modifications to engine beds, shafts, etc. The engine replacement is usually half or less of the total cost of a repower.
If you keep the Westerbeke in good order, it might be a simpler process to source a replacement transmission. While the engine is out, consider a top-end rebuild. A rebuilt diesel with a new transmission is essentially a new engine, particularly if it is well-maintained. Absent, however, are the ancillary charges of modifying shafts, beds, and so on.
Imagine the Westerbeke with a rebuild, new hoses, new seals, cleaned out and realigned injectors, fresh paint in your mind's eye. Looks nice, doesn't it?