Skip to content

Commit

Permalink
Allow for no barcode files case. (#1675)
Browse files Browse the repository at this point in the history
This PR fixes an error case that can happen when the NewIlluminaDataProvider is used in ExtractIlluminaBarcodes which makes the barcode files.
Add an explicit check for the presence of a lane directory in CheckIlluminaDirectory
Modify an EIB test to check for the condition where NewIlluminaDataProvider was expecting to find barcode files in the basecalls directory.
  • Loading branch information
gbggrant authored May 1, 2021
1 parent 949d7f9 commit e6a2827
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/picard/illumina/CheckIlluminaDirectory.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ protected int doWork() {
log.info("Expected cycles: " + StringUtil.intValuesToString(outputCycles));

for (final Integer lane : LANES) {
IOUtil.assertDirectoryIsReadable(new File(BASECALLS_DIR, IlluminaFileUtil.longLaneStr(lane)));

if (IlluminaFileUtil.hasCbcls(BASECALLS_DIR, lane)) {
final List<Integer> tiles = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ class NewIlluminaDataProvider extends BaseIlluminaDataProvider {
ParameterizedFileUtil.makeBarcodeRegex(lane)));

final File[] barcodeFiles = getTiledFiles(barcodesDirectory, barcodeRegex);
if (Arrays.stream(barcodeFiles).noneMatch(Objects::nonNull)) {
throw new PicardException("No barcode files found in the barcodesDirectory " + barcodesDirectory.getAbsolutePath());
}

IOUtil.assertFilesAreReadable(Arrays.asList(barcodeFiles));
this.barcodeFileMap = new HashMap<>();
for (File barcodeFile : barcodeFiles) {
barcodeFileMap.put(fileToTile(barcodeFile.getName()), new BarcodeFileReader(barcodeFile));
Expand Down
12 changes: 12 additions & 0 deletions src/test/java/picard/illumina/ExtractIlluminaBarcodesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import htsjdk.samtools.metrics.MetricsFile;
import htsjdk.samtools.util.IOUtil;
import org.apache.commons.io.FileUtils;
import org.testng.Assert;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
Expand Down Expand Up @@ -85,10 +86,12 @@ private void setUp() throws Exception {
Assert.assertTrue(basecallsDir.delete());
Assert.assertTrue(basecallsDir.mkdir());
IOUtil.copyDirectoryTree(SINGLE_DATA_DIR, basecallsDir);

dual = File.createTempFile("eib_dual", ".tmp");
Assert.assertTrue(dual.delete());
Assert.assertTrue(dual.mkdir());
IOUtil.copyDirectoryTree(DUAL_DATA_DIR, dual);

qual = File.createTempFile("eib_qual", ".tmp");
Assert.assertTrue(qual.delete());
Assert.assertTrue(qual.mkdir());
Expand All @@ -103,6 +106,14 @@ private void setUp() throws Exception {
Assert.assertTrue(cbcl.delete());
Assert.assertTrue(cbcl.mkdir());
IOUtil.copyDirectoryTree(CBCL_DATA_DIR, cbcl);
// For the cbcl test, we are deleting the '*barcode.txt.gz' files that exist in the test Basecalls directory
// This is to prevent the error conditon that was briefly introduced which expected to find such files in that
// directory before EIB was run on it.
final File basecallsDir = new File(cbcl, "BaseCalls");
Collection<File> barcodeFiles = FileUtils.listFiles(basecallsDir, new String[]{"txt.gz"}, false);
for (final File barcodeFile : barcodeFiles) {
Assert.assertTrue(barcodeFile.delete());
}
}

@AfterTest
Expand All @@ -111,6 +122,7 @@ private void tearDown() {
IOUtil.deleteDirectoryTree(dual);
IOUtil.deleteDirectoryTree(qual);
IOUtil.deleteDirectoryTree(noSymlink);
IOUtil.deleteDirectoryTree(cbcl);
}

@Test
Expand Down

0 comments on commit e6a2827

Please sign in to comment.