Dear Xun,
such kind of questions (if I understood you well) has been addressed recently in our article in Acta Cryst (2014) D70, 2593-2606 with the tools available through phenix (otherwise, I have a stand-alone python program, in a testing stage; let me know if you wish it).
Best regards,
Sacha Urzhumtsev