I just cannot imagine Powell to O'Farrell being any real danger. (Yes, bad stuff can happen anywhere at anytime, I know.) I used to live on the fringe of the Tenderloin and there were several streets I'd avoid. Powell anywhere, and O'Farrell within a couple blocks of Union Square aren't even on the "possibly-avoid" radar. If you walk with a purpose and don't appear lost, you should be fine. The most annoying part of the trip you propose is the up-to-20 minute wait for BART and then $8+ for the trip.