-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes indexing for codecs that implement getPathToDataFile (#1429)
* Updated IndexFactory so it is possible to index files with codecs that override getPathToDataFile. * Moved VCFRedirectCodec to it's own top level test class to share between tests * Fixes #1428 Co-authored-by: Jonn Smith <[email protected]> Co-authored-by: Louis Bergelson <[email protected]>
- Loading branch information
1 parent
f70befd
commit c21055b
Showing
6 changed files
with
93 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package htsjdk.tribble; | ||
|
||
import htsjdk.samtools.util.IOUtil; | ||
import htsjdk.samtools.util.RuntimeIOException; | ||
import htsjdk.variant.vcf.VCFCodec; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
/** | ||
* Test codec which redirects to another location after reading the input file | ||
* It's an example of a codec which uses {@link FeatureCodec#getPathToDataFile(String)} | ||
*/ | ||
public class VCFRedirectCodec extends VCFCodec { | ||
public static final String REDIRECTING_CODEC_TEST_FILE_ROOT = "src/test/resources/htsjdk/tribble/AbstractFeatureReaderTest/redirectingCodecTest/"; | ||
|
||
@Override | ||
public boolean canDecode(final String potentialInput) { | ||
return super.canDecode(this.getPathToDataFile(potentialInput)); | ||
} | ||
|
||
@Override | ||
public String getPathToDataFile(final String path) { | ||
try { | ||
final Path inputPath = IOUtil.getPath(path); | ||
final Path dataFilePath = IOUtil.getPath(Files.readAllLines(inputPath).get(0)); | ||
return inputPath.getParent().resolve(dataFilePath).toString(); | ||
} catch (final IOException e) { | ||
throw new RuntimeIOException(e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...t/resources/htsjdk/tribble/AbstractFeatureReaderTest/redirectingCodecTest/vcf.gz.redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
src/test/resources/htsjdk/tribble/AbstractFeatureReaderTest/redirectingCodecTest/dataFiles/test.vcf.gz | ||
dataFiles/test.vcf.gz |
2 changes: 1 addition & 1 deletion
2
...test/resources/htsjdk/tribble/AbstractFeatureReaderTest/redirectingCodecTest/vcf.redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
src/test/resources/htsjdk/tribble/AbstractFeatureReaderTest/redirectingCodecTest/dataFiles/test.vcf | ||
dataFiles/test.vcf |