I do not think that there is any connection between filing a patent and publishing a scientific paper. A patent has many features that a paper does not have. I would say that filing a patent first is even safer than publishing a paper first.
As Avishag said, if your paper publication is one year old before filing a patent application, the published paper might act as an prior art for your own patent application, and may stop its grant.