2009-04-13 23:29:55 +08:00
|
|
|
package org.broadinstitute.sting.gatk.walkers;
|
|
|
|
|
|
|
|
|
|
import org.broadinstitute.sting.gatk.LocusContext;
|
|
|
|
|
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
2009-07-10 07:59:53 +08:00
|
|
|
public class PrintLocusContextWalker extends LocusWalker<LocusContext, Integer> implements TreeReducible<Integer> {
|
|
|
|
|
public LocusContext map(RefMetaDataTracker tracker, char ref, LocusContext context) {
|
2009-06-26 06:51:38 +08:00
|
|
|
out.printf( "In map: ref = %s, loc = %s, reads = %s%n", ref,
|
2009-04-13 23:29:55 +08:00
|
|
|
context.getLocation(),
|
|
|
|
|
Arrays.deepToString( getReadNames(context.getReads()) ) );
|
|
|
|
|
return context;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Integer reduceInit() { return 0; }
|
|
|
|
|
|
|
|
|
|
public Integer reduce(LocusContext context, Integer sum) {
|
|
|
|
|
return sum + 1;
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-02 03:34:09 +08:00
|
|
|
public Integer treeReduce(Integer lhs, Integer rhs) {
|
|
|
|
|
return lhs + rhs;
|
|
|
|
|
}
|
|
|
|
|
|
2009-04-13 23:29:55 +08:00
|
|
|
private String[] getReadNames( List<SAMRecord> reads ) {
|
|
|
|
|
String[] readNames = new String[ reads.size() ];
|
2009-04-23 02:28:02 +08:00
|
|
|
for( int i = 0; i < reads.size(); i++ ) {
|
|
|
|
|
readNames[i] = String.format("%nname = %s, start = %d, end = %d", reads.get(i).getReadName(), reads.get(i).getAlignmentStart(), reads.get(i).getAlignmentEnd());
|
|
|
|
|
}
|
|
|
|
|
//Arrays.sort(readNames);
|
2009-04-13 23:29:55 +08:00
|
|
|
return readNames;
|
|
|
|
|
}
|
|
|
|
|
}
|