From 7e5e4225914fa50875a55c8414757d7a82d4973a Mon Sep 17 00:00:00 2001 From: asivache Date: Thu, 21 May 2009 15:23:22 +0000 Subject: [PATCH] ReferenceOrdereData now inspects the ROD class using reflection. If the ROD declares a static Iterator 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 --- .../gatk/refdata/ReferenceOrderedData.java | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedData.java b/java/src/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedData.java index 50138e8fc..921193ce1 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedData.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/ReferenceOrderedData.java @@ -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 implements } public RODIterator iterator() { - return new RODIterator(new SimpleRODIterator()); - } + Iterator it; + try { + Method m = type.getDeclaredMethod("createIterator", String.class,java.io.File.class); + it = (Iterator) 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 implements private PushbackIterator it; private ROD prev = null; - public RODIterator(SimpleRODIterator it) { + public RODIterator(Iterator it) { this.it = new PushbackIterator(it); }