New methods for haplotyping and de novo assembly of genomes and metagenomes