Inferring species phylogeny and gene flow from genomic data