package org.broadinstitute.sting.gatk.walkers;

import org.broadinstitute.sting.gatk.LocusContext;
import org.broadinstitute.sting.gatk.refdata.ReferenceOrderedDatum;
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;

import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;

import net.sf.samtools.SAMRecord;

/**
 * Created by IntelliJ IDEA.
 * User: hanna
 * Date: 13 Apr, 2009
 * Time: 11:23:14 AM
 * To change this template use File | Settings | File Templates.
 */
public class PrintLocusContextWalker extends LocusWalker<LocusContext, Integer> {
    public LocusContext map(RefMetaDataTracker tracker, char ref, LocusContext context) {
        out.printf( "In map: ref = %c, loc = %s, reads = %s%n", ref,
                                                                context.getLocation(),
                                                                Arrays.deepToString( getReadNames(context.getReads()) ) );
        return context;
    }

    public Integer reduceInit() { return 0; }

    public Integer reduce(LocusContext context, Integer sum) {
        out.printf( "In reduce: loc = %s, reads = %s, sum =%d%n", context.getLocation(),
                                                                  Arrays.deepToString( getReadNames(context.getReads()) ),
                                                                  sum );


        return sum + 1;
    }

    private String[] getReadNames( List<SAMRecord> reads ) {
        String[] readNames = new String[ reads.size() ];
        for( int i = 0; i < reads.size(); i++ )
            readNames[i] = reads.get(i).getReadName();
        return readNames;
    }
}

@@ -1094,295 +1094,8 @@
 ) %7B%0A
-        out.printf( %22In reduce: loc = %25s, reads = %25s, sum =%25d%25n%22, context.getLocation(),%0A                                                                  Arrays.deepToString( getReadNames(context.getReads()) ),%0A                                                                  sum );%0A%0A%0A
     
@@ -1286,16 +1286,18 @@
 ); i++ )
+ %7B
 %0A       
@@ -1320,33 +1320,195 @@
 %5D = 
-reads.get(i).getReadName(
+String.format(%22%25nname = %25s, start = %25d, end = %25d%22, reads.get(i).getReadName(), reads.get(i).getAlignmentStart(), reads.get(i).getAlignmentEnd());%0A        %7D%0A        //Arrays.sort(readNames
 );%0A 

Make PrintLocusContextWalker less verbose.