Okay, I caved in:
CallsetConcordance now gets possible concordance types by looking at classes that implement ConcordanceType instead of having them hard-coded in. Thanks to Kiran this was pretty easy... git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1939 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
1f0d852a48
commit
64ac956885
|
|
@ -26,32 +26,23 @@ public class CallsetConcordanceWalker extends RefWalker<Integer, Integer> {
|
||||||
|
|
||||||
private ArrayList<ConcordanceType> requestedTypes;
|
private ArrayList<ConcordanceType> requestedTypes;
|
||||||
|
|
||||||
private HashMap<String, ConcordanceType> initializeConcordanceTypes(String prefix) {
|
|
||||||
HashMap<String, ConcordanceType> types = new HashMap<String, ConcordanceType>();
|
|
||||||
|
|
||||||
//
|
|
||||||
// Add new concordance types here!
|
|
||||||
//
|
|
||||||
types.put("SNPGenotypeConcordance", new SNPGenotypeConcordance(prefix));
|
|
||||||
types.put("SimpleVenn", new SimpleVenn(prefix));
|
|
||||||
types.put("IndelSubsets", new IndelSubsets(prefix));
|
|
||||||
|
|
||||||
return types;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prepare the output file and the list of available features.
|
* Prepare the output file and the list of available features.
|
||||||
*/
|
*/
|
||||||
public void initialize() {
|
public void initialize() {
|
||||||
HashMap<String, ConcordanceType> concordanceTypes = initializeConcordanceTypes(OUTPUT_PATH);
|
|
||||||
|
|
||||||
|
// get the possible concordance types
|
||||||
|
List<Class<? extends ConcordanceType>> classes = PackageUtils.getClassesImplementingInterface(ConcordanceType.class);
|
||||||
|
|
||||||
|
// print and exit if that's what was requested
|
||||||
if (LIST_ONLY) {
|
if (LIST_ONLY) {
|
||||||
Iterator<String> types = concordanceTypes.keySet().iterator();
|
|
||||||
out.println("\nAvailable concordance types:");
|
out.println("\nAvailable concordance types:");
|
||||||
while ( types.hasNext() )
|
for (int i = 0; i < classes.size(); i++)
|
||||||
out.println("\t" + types.next());
|
out.println("\t" + classes.get(i).getSimpleName());
|
||||||
|
out.println();
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
requestedTypes = new ArrayList<ConcordanceType>();
|
requestedTypes = new ArrayList<ConcordanceType>();
|
||||||
|
|
||||||
// initialize requested concordance types
|
// initialize requested concordance types
|
||||||
|
|
@ -59,22 +50,37 @@ public class CallsetConcordanceWalker extends RefWalker<Integer, Integer> {
|
||||||
for ( String requestedTypeString : TYPES ) {
|
for ( String requestedTypeString : TYPES ) {
|
||||||
String[] requestedPieces = requestedTypeString.split(":");
|
String[] requestedPieces = requestedTypeString.split(":");
|
||||||
String requestedType = requestedPieces[0];
|
String requestedType = requestedPieces[0];
|
||||||
ConcordanceType type = concordanceTypes.get(requestedType);
|
|
||||||
if ( type == null )
|
|
||||||
throw new StingException("The requested concordance type (" + requestedType + ") isn't a valid option");
|
|
||||||
|
|
||||||
HashMap<String,String> requestedArgs = new HashMap<String,String>();
|
boolean foundClass = false;
|
||||||
if ( requestedPieces.length == 2 ) {
|
for ( Class type : classes ) {
|
||||||
String[] argStrings = requestedPieces[1].split(",");
|
|
||||||
for (int i = 0; i < argStrings.length; i++ ) {
|
if (requestedType.equalsIgnoreCase(type.getSimpleName())) {
|
||||||
String[] arg = argStrings[i].split("=");
|
foundClass = true;
|
||||||
if ( arg.length == 2 )
|
try {
|
||||||
requestedArgs.put(arg[0], arg[1]);
|
ConcordanceType concordance = (ConcordanceType)type.newInstance();
|
||||||
|
HashMap<String,String> requestedArgs = new HashMap<String,String>();
|
||||||
|
if ( requestedPieces.length == 2 ) {
|
||||||
|
String[] argStrings = requestedPieces[1].split(",");
|
||||||
|
for (int i = 0; i < argStrings.length; i++ ) {
|
||||||
|
String[] arg = argStrings[i].split("=");
|
||||||
|
if ( arg.length == 2 )
|
||||||
|
requestedArgs.put(arg[0], arg[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
concordance.initialize(OUTPUT_PATH, requestedArgs);
|
||||||
|
requestedTypes.add(concordance);
|
||||||
|
break;
|
||||||
|
} catch (InstantiationException e) {
|
||||||
|
throw new StingException(String.format("Cannot instantiate concordance class '%s': must be concrete class", type.getSimpleName()));
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
throw new StingException(String.format("Cannot instantiate concordance class '%s': must have no-arg constructor", type.getSimpleName()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type.initialize(requestedArgs);
|
if ( !foundClass )
|
||||||
requestedTypes.add(type);
|
throw new StingException("The requested concordance type (" + requestedType + ") isn't a valid concordance option");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import java.util.HashMap;
|
||||||
|
|
||||||
public interface ConcordanceType {
|
public interface ConcordanceType {
|
||||||
|
|
||||||
public void initialize(HashMap<String,String> args);
|
public void initialize(String prefix, HashMap<String,String> args);
|
||||||
public void computeConcordance(RefMetaDataTracker tracker, ReferenceContext ref);
|
public void computeConcordance(RefMetaDataTracker tracker, ReferenceContext ref);
|
||||||
public void cleanup();
|
public void cleanup();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,13 +23,10 @@ public class IndelSubsets implements ConcordanceType {
|
||||||
private int sizeCutoff = 2;
|
private int sizeCutoff = 2;
|
||||||
|
|
||||||
private PrintWriter[][][][] writers = new PrintWriter[2][2][2][2];
|
private PrintWriter[][][][] writers = new PrintWriter[2][2][2][2];
|
||||||
private String prefix;
|
|
||||||
|
|
||||||
public IndelSubsets(String prefix) {
|
public IndelSubsets() {}
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialize(HashMap<String,String> args) {
|
public void initialize(String prefix, HashMap<String,String> args) {
|
||||||
if ( args.get("sizeCutoff") != null )
|
if ( args.get("sizeCutoff") != null )
|
||||||
sizeCutoff = Integer.valueOf(args.get("sizeCutoff"));
|
sizeCutoff = Integer.valueOf(args.get("sizeCutoff"));
|
||||||
if ( args.get("homopolymerCutoff") != null )
|
if ( args.get("homopolymerCutoff") != null )
|
||||||
|
|
|
||||||
|
|
@ -28,13 +28,10 @@ public class SNPGenotypeConcordance implements ConcordanceType {
|
||||||
private PrintWriter comboVarWriter = null;
|
private PrintWriter comboVarWriter = null;
|
||||||
private PrintWriter coverageVar1Writer = null;
|
private PrintWriter coverageVar1Writer = null;
|
||||||
private PrintWriter coverageVar2Writer = null;
|
private PrintWriter coverageVar2Writer = null;
|
||||||
private String prefix;
|
|
||||||
|
|
||||||
public SNPGenotypeConcordance(String prefix) {
|
public SNPGenotypeConcordance() {}
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialize(HashMap<String,String> args) {
|
public void initialize(String prefix, HashMap<String,String> args) {
|
||||||
try {
|
try {
|
||||||
sameVarWriter = new PrintWriter(prefix + ".snp_concordance.sameConfidentVariant.calls");
|
sameVarWriter = new PrintWriter(prefix + ".snp_concordance.sameConfidentVariant.calls");
|
||||||
oneVarWriter = new PrintWriter(prefix + ".snp_concordance.bothVariantOnlyOneIsConfident.calls");
|
oneVarWriter = new PrintWriter(prefix + ".snp_concordance.bothVariantOnlyOneIsConfident.calls");
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,10 @@ public class SimpleVenn implements ConcordanceType {
|
||||||
private PrintWriter discord_writer = null;
|
private PrintWriter discord_writer = null;
|
||||||
private PrintWriter set1_writer = null;
|
private PrintWriter set1_writer = null;
|
||||||
private PrintWriter set2_writer = null;
|
private PrintWriter set2_writer = null;
|
||||||
private String prefix;
|
|
||||||
|
|
||||||
public SimpleVenn(String prefix) {
|
public SimpleVenn() {}
|
||||||
this.prefix = prefix;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void initialize(HashMap<String,String> args) {
|
public void initialize(String prefix, HashMap<String,String> args) {
|
||||||
try {
|
try {
|
||||||
union_writer = new PrintWriter(prefix + ".venn.union.calls");
|
union_writer = new PrintWriter(prefix + ".venn.union.calls");
|
||||||
intersect_writer = new PrintWriter(prefix + ".venn.intersection.calls");
|
intersect_writer = new PrintWriter(prefix + ".venn.intersection.calls");
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue