A class to wrap the Tabix line reading capability.
| 49 | * A class to wrap the Tabix line reading capability. |
| 50 | */ |
| 51 | public class TabixLineReader implements LineReader { |
| 52 | |
| 53 | private static LineReader getDelegate(File input, TabixIndexReader tir, RegionRestriction region) throws IOException { |
| 54 | final LineReader reader; |
| 55 | if (region == null) { |
| 56 | reader = new SingleRestrictionLineReader(input, tir); |
| 57 | } else { |
| 58 | reader = new SingleRestrictionLineReader(input, tir, region); |
| 59 | } |
| 60 | return reader; |
| 61 | } |
| 62 | |
| 63 | private static LineReader getDelegate(File input, TabixIndexReader tir, ReferenceRanges<String> ranges) throws IOException { |
| 64 | final LineReader reader; |
| 65 | if (ranges == null || ranges.allAvailable()) { |
| 66 | reader = new SingleRestrictionLineReader(input, tir); |
| 67 | } else { |
| 68 | reader = new MultiRestrictionLineReader(input, tir, ranges); |
| 69 | } |
| 70 | return reader; |
| 71 | } |
| 72 | |
| 73 | |
| 74 | private final LineReader mDelegate; |
| 75 | |
| 76 | /** |
| 77 | * |
| 78 | * @param input input text file |
| 79 | * @param tabix index for input file |
| 80 | * @param region the region to extract, may be null for no restriction |
| 81 | * @throws IOException if an IO error occurs |
| 82 | */ |
| 83 | public TabixLineReader(File input, File tabix, RegionRestriction region) throws IOException { |
| 84 | this(getDelegate(input, new TabixIndexReader(tabix), region)); |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * |
| 89 | * @param input input text file |
| 90 | * @param tabix index for input file |
| 91 | * @param ranges the ranges to extract, may be null for no restrictions |
| 92 | * @throws IOException if an IO error occurs |
| 93 | */ |
| 94 | public TabixLineReader(File input, File tabix, ReferenceRanges<String> ranges) throws IOException { |
| 95 | this(getDelegate(input, new TabixIndexReader(tabix), ranges)); |
| 96 | } |
| 97 | |
| 98 | /** |
| 99 | * Used only by <code>VCFMerge</code>. |
| 100 | * @param input input text file |
| 101 | * @param tir tabix line reader |
| 102 | * @param region the region restriction, may be null for no restriction |
| 103 | * @throws IOException if an IO error occurs |
| 104 | */ |
| 105 | public TabixLineReader(File input, TabixIndexReader tir, ReferenceRanges<String> region) throws IOException { |
| 106 | this(getDelegate(input, tir, region)); |
| 107 | } |
| 108 |
nothing calls this directly
no outgoing calls
no test coverage detected