How to calculate the number of folds present in a protein
There are various ways that you could do this.


CATH is a hierarchical classification system
SCOP is another such system with a different hierarchy
PTGL is the protein topology graph library
Tops motif will scan PDB files and match patterns against it


How you actually apply these tools or lookup within these systems is documented on their websites. However, it depends on what you want to do - look up published structures, or new experimental data.

I should point out that writing software from scratch to determine the fold of a protein may be tricky.