haplotypeRouteByHaplotype = new LinkedHashMap<>(haplotypes.size());
final Iterator<Haplotype> haplotypeIterator = haplotypes.iterator();
final Set<Haplotype> nonFoundHaplotypes = new HashSet<>(haplotypes.size());
while (haplotypeIterator.hasNext()) {
final Haplotype haplotype = haplotypeIterator.next();
final HaplotypeRoute haplotypeRoute = buildHaplotypeRoute(haplotype);
if (haplotypeRoute == null) {
haplotypeIterator.remove();
nonFoundHaplotypes.add(haplotype);
if (haplotype.isReference()) {
referenceHaplotype = null;
referenceRoute = null;
referenceVertices = Collections.emptySet();
referenceBases = null;
}
} else {
if (haplotype.isReference()) {
referenceHaplotype = haplotype;
referenceRoute = haplotypeRoute;
referenceVertices = haplotypeRoute.vertexSet();
referenceBases = haplotypeRoute.getBases();
}
haplotypeRouteByHaplotype.put(haplotype, haplotypeRoute);
}
}
haplotypesByVertex = buildHaplotypesByVertex();