Output format is 10^6 times better - now uses the multiplexer to write tdf tracks that can (after conversion to binary with igvtools) can be loaded directly into igv.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@5381 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
a40a8006b5
commit
fc5a071de2
|
|
@ -23,7 +23,7 @@ import org.broadinstitute.sting.utils.collections.Pair;
|
|||
public class AssociationTestRunner {
|
||||
static Normal standardNormal = new Normal(0.0,1.0,null);
|
||||
|
||||
public static List<String> runTests(AssociationContext context) {
|
||||
public static String runTests(AssociationContext context) {
|
||||
List<String> results = new ArrayList<String>();
|
||||
if ( context instanceof TStatistic) {
|
||||
results.add(runStudentT((TStatistic) context));
|
||||
|
|
@ -37,7 +37,16 @@ public class AssociationTestRunner {
|
|||
results.add(runU((UStatistic) context));
|
||||
}
|
||||
|
||||
return results;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
if ( results.size() > 0 ) {
|
||||
buf.append(results.remove(0));
|
||||
for ( String s : results ) {
|
||||
buf.append('\t');
|
||||
buf.append(s);
|
||||
}
|
||||
}
|
||||
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String runStudentT(TStatistic context) {
|
||||
|
|
|
|||
|
|
@ -43,11 +43,13 @@ public class RegionalAssociationHandler {
|
|||
* 1) Run their associated test(s)
|
||||
* 2) Slide the windows
|
||||
*/
|
||||
public List<String> runTests() {
|
||||
List<String> testResults = new ArrayList<String>(associations.size());
|
||||
public Map<AssociationContext,String> runTests() {
|
||||
// todo -- maybe the tdf should be the whole window rather than just the most recent loc?
|
||||
Map<AssociationContext,String> testResults = new HashMap<AssociationContext,String>(associations.size());
|
||||
for ( AssociationContext w : associations ) {
|
||||
if ( w.isFull() ) {
|
||||
testResults.addAll(AssociationTestRunner.runTests(w));
|
||||
testResults.put(w,String.format("%s\t%d\t%d\t%s",maps.getReferenceContext().getLocus().getContig(),
|
||||
maps.getReferenceContext().getLocus().getStart(),maps.getReferenceContext().getLocus().getStop(),AssociationTestRunner.runTests(w)));
|
||||
w.slide();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
package org.broadinstitute.sting.oneoffprojects.walkers.association;
|
||||
|
||||
import org.broadinstitute.sting.gatk.walkers.Multiplexer;
|
||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: chartl
|
||||
* Date: 3/6/11
|
||||
* Time: 12:09 PM
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
public class RegionalAssociationMultiplexer implements Multiplexer<Class<? extends AssociationContext>> {
|
||||
|
||||
Set<Class<? extends AssociationContext>> contexts = null;
|
||||
|
||||
public RegionalAssociationMultiplexer(String[] toUse) {
|
||||
super();
|
||||
contexts = getAssociations(toUse);
|
||||
|
||||
}
|
||||
|
||||
public Collection<Class<? extends AssociationContext>> multiplex() {
|
||||
return contexts;
|
||||
}
|
||||
|
||||
public String transformArgument(final Class<? extends AssociationContext> context, String arg) {
|
||||
return String.format("%s.%s.tdf", arg, context.getSimpleName());
|
||||
}
|
||||
|
||||
private Set<Class<? extends AssociationContext>> getAssociations(String[] associationsToUse) {
|
||||
List<Class<? extends AssociationContext>> contexts = new PluginManager<AssociationContext>(AssociationContext.class).getPlugins();
|
||||
Map<String,Class<? extends AssociationContext>> classNameToClass = new HashMap<String,Class<? extends AssociationContext>>(contexts.size());
|
||||
for ( Class<? extends AssociationContext> clazz : contexts ) {
|
||||
classNameToClass.put(clazz.getSimpleName(),clazz);
|
||||
}
|
||||
|
||||
Set<Class<? extends AssociationContext>> validAssociations = new HashSet<Class<? extends AssociationContext>>();
|
||||
for ( String s : associationsToUse ) {
|
||||
validAssociations.add(classNameToClass.get(s));
|
||||
}
|
||||
return validAssociations;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,11 +7,13 @@ import org.broadinstitute.sting.gatk.contexts.ReferenceContext;
|
|||
import org.broadinstitute.sting.gatk.datasources.sample.Sample;
|
||||
import org.broadinstitute.sting.gatk.refdata.RefMetaDataTracker;
|
||||
import org.broadinstitute.sting.gatk.walkers.LocusWalker;
|
||||
import org.broadinstitute.sting.gatk.walkers.Multiplex;
|
||||
import org.broadinstitute.sting.gatk.walkers.TreeReducible;
|
||||
import org.broadinstitute.sting.utils.SampleUtils;
|
||||
import org.broadinstitute.sting.utils.classloader.PluginManager;
|
||||
import org.broadinstitute.sting.utils.exceptions.StingException;
|
||||
import org.broadinstitute.sting.utils.exceptions.UserException;
|
||||
import org.broadinstitute.sting.utils.wiggle.WiggleWriter;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
|
@ -27,7 +29,8 @@ public class RegionalAssociationWalker extends LocusWalker<MapHolder, RegionalAs
|
|||
public String[] associationsToUse = null;
|
||||
|
||||
@Output
|
||||
PrintStream out;
|
||||
@Multiplex(value=RegionalAssociationMultiplexer.class,arguments={"associationsToUse"})
|
||||
Map<AssociationContext,PrintStream> out;
|
||||
|
||||
public RegionalAssociationHandler reduceInit() {
|
||||
Set<AssociationContext> validAssociations = getAssociations();
|
||||
|
|
@ -47,17 +50,17 @@ public class RegionalAssociationWalker extends LocusWalker<MapHolder, RegionalAs
|
|||
} catch (Exception e) {
|
||||
throw new StingException("Error in map reduce",e);
|
||||
}
|
||||
List<String> testsHere = rac.runTests();
|
||||
Map<AssociationContext,String> testsHere = rac.runTests();
|
||||
// todo -- really awful shitty formatting
|
||||
if ( testsHere.size() > 0 ) {
|
||||
out.printf("%s%n",rac.getLocation().toString());
|
||||
for ( String s : testsHere ) {
|
||||
out.printf("%s%n",s);
|
||||
for ( Map.Entry<AssociationContext,String> result : testsHere.entrySet() ) {
|
||||
out.get(result.getKey().getClass()).printf("%s%n",result.getValue());
|
||||
}
|
||||
}
|
||||
return rac;
|
||||
}
|
||||
private Set<AssociationContext> getAssociations() {
|
||||
|
||||
public Set<AssociationContext> getAssociations() {
|
||||
List<Class<? extends AssociationContext>> contexts = new PluginManager<AssociationContext>(AssociationContext.class).getPlugins();
|
||||
Map<String,Class<? extends AssociationContext>> classNameToClass = new HashMap<String,Class<? extends AssociationContext>>(contexts.size());
|
||||
for ( Class<? extends AssociationContext> clazz : contexts ) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue