how soon can I take a pregnancy test after having sex?

I had sex 4 days ago and was supposed to get my period yesterday. Should I wait or take a pregnancy test? How soon can I take an accurate pregnancy test???