Your question is a difficulty one which every scientist grapples with every day of their career. Broadly there are two mechanisms by which hypothesis testing can be biased.
The first is the obvious mechanism of biasing the data in favor an hypothesis. Sometimes this occurs through straightforward fraud (i.e. South Korean stem cell findings). But more frequently this source of bias is much more subtle; involving issues such as unrecognized selection bias in the data.
The second mechanism is far more difficult to prevent and is often seen in peer reviewed literature, this mechanism is the biasing of the hypothesis in favor of the data. Two typical examples are over fitting the data with a large number of extra parameters to obtain a better fit, or using an inappropriate statistical model on a large dataset to yield statistical significance (i.e. fitting a time dependent model of the speed of light on cosmological scales). Another example is confusing data analysis for hypothesis testing (i.e. low frequency heart rate modulation research).
There is no single algorithm to prevent this second form of bias, and using general data mining and data analysis tools will almost guarantee that you will over fit the data. The best practice available in the scientific field is an iterative practice: First look for the most obvious pattern that has the simplest explanation, test for the explanations fit with a reasonably course dataset. If the explanation fits, then refine your data and look at how your previous explanation fails on the refined data, propose and test a more nuanced hypothesis. Continue ad infinitum, or ad nausea which ever comes first. Thus a first step is to ask a simple question for which the extraneous factors and error sources can be controlled and don't analyze very detailed data, this will only lead you on a wild goose chase.