You can see good implementations of all but sub 4pc over on github.
https://github.com/dazer/ShadowCraft-Engine
The sub 4pc numbers are in my personal build which I'm not currently hosting anywhere (maybe I should host them on github) but I'll put the relevant code snippets here for clarity in a few hours.
EDIT: Below, no FW overlap handling because I'm still don't have a good way to model that.
Code:
if self.stats.gear_buffs.rogue_t16_4pc_bonus():
print attacks_per_second['ambush'], attacks_per_second['backstab'], self.find_weakness_uptime
new_ambush_per_second = .04*attacks_per_second['backstab']
attacks_per_second['ambush']+=new_ambush_per_second
attacks_per_second['backstab']-=new_ambush_per_second
self.find_weakness_uptime += (600*new_ambush_per_second)*shadow_dance_frequency
print attacks_per_second['ambush'], attacks_per_second['backstab'], self.find_weakness_uptime, 60*new_ambush_per_second
print "========================================="