An Inverse Statistical Physics Method for Biological Sequence Analysis