-
Notifications
You must be signed in to change notification settings - Fork 369
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added reverse cycle and base dir lookup for tile metrics. (#1158)
* Added reverse cycle and base dir lookup for tile metrics. Similar to https://github.com/broadinstitute/zamboni/blob/ccbfbd6e22b6eee65546ae612ce2626ed9f549f6/Client/src/scala/org/broadinstitute/zamboni/client/illumina/IlluminaRunConfigurationParser.scala#L425
- Loading branch information
Showing
4 changed files
with
110 additions
and
9 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
83 changes: 83 additions & 0 deletions
83
src/test/java/picard/illumina/parser/TileMetricsUtilTest.java
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,83 @@ | ||
package picard.illumina.parser; | ||
|
||
import htsjdk.samtools.util.IOUtil; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.util.stream.IntStream; | ||
|
||
public class TileMetricsUtilTest { | ||
@Test | ||
public void testFindTileMetrics() throws IOException { | ||
Path baseDir = createTestDirs(0, true); | ||
File tileMetricsFile = TileMetricsUtil.renderTileMetricsFileFromBasecallingDirectory( | ||
baseDir.toFile(), 0, false); | ||
|
||
Assert.assertEquals(tileMetricsFile.getAbsolutePath(), | ||
baseDir.resolve(TileMetricsUtil.INTEROP_SUBDIRECTORY_NAME) | ||
.resolve(TileMetricsUtil.TILE_METRICS_OUT_FILE_NAME).toString()); | ||
|
||
IOUtil.deleteDirectoryTree(baseDir.toFile()); | ||
} | ||
|
||
@Test(expectedExceptions = IllegalStateException.class) | ||
public void testMissingTileMetrics() throws IOException { | ||
Path baseDir = createTestDirs(0, false); | ||
TileMetricsUtil.renderTileMetricsFileFromBasecallingDirectory( | ||
baseDir.toFile(), 0, false); | ||
|
||
IOUtil.deleteDirectoryTree(baseDir.toFile()); | ||
} | ||
|
||
// put tile metrics file in 1 random cycle dir and interop based ensure we get the one in base | ||
@Test | ||
public void testFindTileMetricsNovaSeqInBaseInterOp() throws IOException { | ||
Path baseDir = createTestDirs(1, true); | ||
File tileMetricsFile = TileMetricsUtil.renderTileMetricsFileFromBasecallingDirectory( | ||
baseDir.toFile(), 1, true); | ||
|
||
Assert.assertEquals(tileMetricsFile.getAbsolutePath(), | ||
baseDir.resolve(TileMetricsUtil.INTEROP_SUBDIRECTORY_NAME) | ||
.resolve(TileMetricsUtil.TILE_METRICS_OUT_FILE_NAME).toString()); | ||
|
||
IOUtil.deleteDirectoryTree(baseDir.toFile()); | ||
} | ||
|
||
// put a file named tile metrics in 2 cycle directories and ensure that we get the one in the highest cycle | ||
@Test | ||
public void testFindTileMetricsNovaSeqInCycleDirs() throws IOException { | ||
Path baseDir = createTestDirs(2, false); | ||
File tileMetricsFile = TileMetricsUtil.renderTileMetricsFileFromBasecallingDirectory( | ||
baseDir.toFile(), 2, true); | ||
|
||
Assert.assertEquals(tileMetricsFile.getAbsolutePath(), | ||
baseDir.resolve(TileMetricsUtil.INTEROP_SUBDIRECTORY_NAME).resolve("C2.1") | ||
.resolve(TileMetricsUtil.TILE_METRICS_OUT_FILE_NAME).toString()); | ||
|
||
IOUtil.deleteDirectoryTree(baseDir.toFile()); | ||
} | ||
|
||
private Path createTestDirs(int numCycleMetricsFiles, boolean baseMetricsFile) throws IOException { | ||
Path baseDir = Files.createTempDirectory("TileMetricsUtilTest"); | ||
// create 10 cycle dirs put tile metrics in the last one. | ||
Path baseOpDir = Files.createDirectory(baseDir.resolve(TileMetricsUtil.INTEROP_SUBDIRECTORY_NAME)); | ||
IntStream.range(1, numCycleMetricsFiles + 1).forEach(i -> { | ||
try { | ||
Path cycleDir = Files.createDirectory(baseOpDir.resolve("C" + i + ".1")); | ||
if (i == numCycleMetricsFiles) { | ||
Files.createFile(cycleDir.resolve(TileMetricsUtil.TILE_METRICS_OUT_FILE_NAME)); | ||
} | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
}); | ||
if (baseMetricsFile) { | ||
Files.createFile(baseOpDir.resolve(TileMetricsUtil.TILE_METRICS_OUT_FILE_NAME)); | ||
} | ||
return baseDir; | ||
} | ||
} |
Binary file modified
BIN
+20.6 KB
(200%)
...umina/IlluminaLaneMetricsCollectorTest/tileRuns/NovaSeq/InterOp/C192.1/TileMetricsOut.bin
Binary file not shown.