use of gov.nih.nlm.ncbi.blast.IterationHits in project jvarkit by lindenb.
the class MergeSplittedBlast method merge.
private Iteration merge(Iteration iteration) {
if (iteration.getIterationHits().getHit().size() <= 1)
return iteration;
Map<String, List<Hit>> chrom2hits = new LinkedHashMap<String, List<Hit>>();
for (Hit hit : iteration.getIterationHits().getHit()) {
Split s = parse(hit);
if (s == null)
return iteration;
List<Hit> L = chrom2hits.get(s.chrom);
if (L == null) {
L = new ArrayList<Hit>();
chrom2hits.put(s.chrom, L);
}
L.add(hit);
}
Iteration newiteration = new Iteration();
List<Hit> newHits = new ArrayList<Hit>();
for (String chrom : chrom2hits.keySet()) {
List<Hit> L = chrom2hits.get(chrom);
Hit newHit = merge(L);
newHits.add(newHit);
}
newiteration.setIterationIterNum(iteration.getIterationIterNum());
newiteration.setIterationQueryID(iteration.getIterationQueryID());
newiteration.setIterationQueryLen(iteration.getIterationQueryLen());
newiteration.setIterationQueryDef(iteration.getIterationQueryDef());
newiteration.setIterationMessage(iteration.getIterationMessage());
newiteration.setIterationHits(new IterationHits());
newiteration.getIterationHits().getHit().addAll(newHits);
return newiteration;
}
Aggregations