ReferenceOrdereData now inspects the ROD class using reflection. If the ROD declares a static Iterator<ROD> createIterator(String rodName, File rodFile) factory method, it is wrapped and used by the ReferenceOrderedData to read records from rodFile. If the ROD does not provide such factory method, the old behavior is the default: ReferenceOrderedData uses its own simple default iterator to read the file line by line (assuming there is only one line per record/position).

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@768 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
asivache 2009-05-21 15:23:22 +00:00
parent 26dd3cd50e
commit 7e5e422591
1 changed files with 21 additions and 3 deletions

View File

@ -7,6 +7,7 @@ import java.io.FileNotFoundException;
import java.util.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.broadinstitute.sting.gatk.iterators.PushbackIterator;
import org.broadinstitute.sting.utils.GenomeLoc;
@ -150,8 +151,25 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
}
public RODIterator iterator() {
return new RODIterator(new SimpleRODIterator());
}
Iterator<ROD> it;
try {
Method m = type.getDeclaredMethod("createIterator", String.class,java.io.File.class);
it = (Iterator<ROD>) m.invoke(null, name, file);
} catch ( java.lang.NoSuchMethodException e ) {
it = new SimpleRODIterator();
} catch ( java.lang.NullPointerException e ) {
throw new RuntimeException(e);
} catch ( java.lang.SecurityException e ) {
throw new RuntimeException(e);
} catch ( java.lang.IllegalAccessException e ) {
throw new RuntimeException(e);
} catch ( java.lang.IllegalArgumentException e ) {
throw new RuntimeException(e);
} catch ( java.lang.reflect.InvocationTargetException e ) {
throw new RuntimeException(e);
}
return new RODIterator(it);
}
// ----------------------------------------------------------------------
//
@ -275,7 +293,7 @@ public class ReferenceOrderedData<ROD extends ReferenceOrderedDatum> implements
private PushbackIterator<ROD> it;
private ROD prev = null;
public RODIterator(SimpleRODIterator it) {
public RODIterator(Iterator<ROD> it) {
this.it = new PushbackIterator<ROD>(it);
}