From 83300582161dd08d76a19c62adf0ed4040ebefcc Mon Sep 17 00:00:00 2001 From: asivache Date: Tue, 29 Dec 2009 22:41:58 +0000 Subject: [PATCH] method added: getEventStringsWithCounts() Returns list of Pairs , where each pair consists of a unique indel event observed at the site and the total number of observations of that event. String representation for insertions is verbose (e.g. +ACT), while deletions are represented as "5D" (since read backed pileup has no reference information, so we can not get actual sequence of deleted bases) git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@2479 348d0f76-0448-11de-a6fe-93d51630548a --- .../pileup/ReadBackedExtendedEventPileup.java | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/java/src/org/broadinstitute/sting/utils/pileup/ReadBackedExtendedEventPileup.java b/java/src/org/broadinstitute/sting/utils/pileup/ReadBackedExtendedEventPileup.java index 7885681db..c0d660975 100644 --- a/java/src/org/broadinstitute/sting/utils/pileup/ReadBackedExtendedEventPileup.java +++ b/java/src/org/broadinstitute/sting/utils/pileup/ReadBackedExtendedEventPileup.java @@ -2,8 +2,7 @@ package org.broadinstitute.sting.utils.pileup; import org.broadinstitute.sting.utils.GenomeLoc; import org.broadinstitute.sting.utils.StingException; -import org.broadinstitute.sting.utils.BaseUtils; -import org.broadinstitute.sting.gatk.iterators.IterableIterator; +import org.broadinstitute.sting.utils.Pair; import java.util.*; @@ -290,6 +289,35 @@ public class ReadBackedExtendedEventPileup implements Iterable> getEventStringsWithCounts() { + Map events = new HashMap(); + + for ( ExtendedEventPileupElement e : this ) { + Integer cnt; + String indel = null; + switch ( e.getType() ) { + case INSERTION: + indel = "+"+e.getEventBases(); + break; + case DELETION: + indel = Integer.toString(e.getEventLength())+"D"; + break; + case NOEVENT: continue; + default: throw new StingException("Unknown event type encountered: "+e.getType()); + } + + cnt = events.get(indel); + if ( cnt == null ) events.put(indel,1); + else events.put(indel,cnt.intValue()+1); + } + + List> eventList = new ArrayList>(events.size()); + for ( Map.Entry m : events.entrySet() ) { + eventList.add( new Pair(m.getKey(),m.getValue())); + } + return eventList; + } + /** * Get an array of the mapping qualities