HARMONY already does the score in this way if you select Guitar Staff, including the transposition down.
The difficulty for my program, as you say, is choosing one of the possible ways to play a specific note. However, you can override the automatic choice by specifying the string, which then makes it unique.