Search in sources :

Example 1 with IterationHits

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;
}
Also used : Hit(gov.nih.nlm.ncbi.blast.Hit) IterationHits(gov.nih.nlm.ncbi.blast.IterationHits) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Iteration(gov.nih.nlm.ncbi.blast.Iteration) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

Hit (gov.nih.nlm.ncbi.blast.Hit)1 Iteration (gov.nih.nlm.ncbi.blast.Iteration)1 IterationHits (gov.nih.nlm.ncbi.blast.IterationHits)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1