MCPcopy Create free account
hub / github.com/BirolLab/RNA-Bloom / updateNormalizedCounts

Method updateNormalizedCounts

src/rnabloom/util/PafUtils.java:276–350  ·  view source on GitHub ↗
(ArrayList<Overlap> targets, HashMap<String, Float> counts)

Source from the content-addressed store, hash-verified

274 }
275
276 private static void updateNormalizedCounts(ArrayList<Overlap> targets, HashMap<String, Float> counts) {
277 if (!targets.isEmpty()) {
278 if (targets.size() == 1) {
279 Overlap t = targets.get(0);
280 Float c = counts.get(t.tName);
281 if (c == null) {
282 c = (t.tEnd - t.tStart)/(float) t.tLen;
283 }
284 else {
285 c += (t.tEnd - t.tStart)/(float) t.tLen;
286 }
287 counts.put(t.tName, c);
288 }
289 else {
290 Collections.sort(targets);
291
292 ArrayList<Overlap> targetsKept = new ArrayList<>();
293 HashMap<Overlap, ArrayList<Overlap>> multiTargets = new HashMap<>();
294 for (Overlap m : targets) {
295 Overlap c = getOverlapContainer(m, targetsKept, 0.95f);
296 if (c == null) {
297 // region not contained
298 targetsKept.add(m);
299 }
300 else if (m.qEnd - m.qStart >= (c.qEnd - c.qStart) * 0.95f) {
301 // region multimaps
302 ArrayList<Overlap> multimaps = multiTargets.get(c);
303 if (multimaps == null) {
304 multimaps = new ArrayList<>();
305 multiTargets.put(c, multimaps);
306 }
307 multimaps.add(m);
308 }
309 }
310
311 for (Overlap t : targetsKept) {
312 ArrayList<Overlap> multimaps = multiTargets.get(t);
313 if (multimaps != null) {
314 // fractional assignment of multimapped region
315 float fraction = 1f/(multimaps.size() + 1);
316
317 Float c = counts.get(t.tName);
318 if (c == null) {
319 c = (t.tEnd - t.tStart)/(float) t.tLen * fraction;
320 }
321 else {
322 c += (t.tEnd - t.tStart)/(float) t.tLen * fraction;
323 }
324 counts.put(t.tName, c);
325
326 for (Overlap mm : multimaps) {
327 c = counts.get(mm.tName);
328 if (c == null) {
329 c = (mm.tEnd - mm.tStart)/(float) mm.tLen * fraction;
330 }
331 else {
332 c += (mm.tEnd - mm.tStart)/(float) mm.tLen * fraction;
333 }

Callers 1

Calls 4

getOverlapContainerMethod · 0.95
getMethod · 0.65
addMethod · 0.65
sizeMethod · 0.45

Tested by

no test coverage detected