Skip to content

Commit

Permalink
more edit
Browse files Browse the repository at this point in the history
  • Loading branch information
takutosato committed Jul 30, 2024
1 parent 35e413f commit 9f2b757
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/main/java/picard/nio/PicardBucketUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static PicardHtsPath getTempFilePath(final String directory, String prefi
* @see #getTempFilePath(String, String, String)
*
*/
public static PicardHtsPath getTempFilePath(final PicardHtsPath directory, String prefix, final String extension){
public static PicardHtsPath getTempFilePath(final IOPath directory, String prefix, final String extension){
return getTempFilePath(directory.getURIString(), prefix, extension);
}

Expand Down Expand Up @@ -105,13 +105,14 @@ public static PicardHtsPath getLocalTempFilePath(final String prefix, final Stri
*
* See: https://stackoverflow.com/questions/51892343/google-gsutil-create-folder
*
* @param parentDir The root path where the new "directory" is to live e.g. "gs://hellbender-test-logs/staging/picard/test/RevertSam/".
* @return A PicardHtsPath object pointing to e.g. "gs://hellbender-test-logs/staging/picard/test/RevertSam/{randomly-generated-string}/"
* @param relativePath The relative location for the new "directory" under the harcoded staging bucket with a TTL set e.g. "test/RevertSam/".
* @return A PicardHtsPath object to a randomly generated "directory" e.g. "gs://hellbender-test-logs/staging/picard/test/RevertSam/{randomly-generated-string}/"
*/
public static PicardHtsPath getRandomGCSDirectory(final PicardHtsPath parentDir){
ValidationUtils.validateArg(parentDir.getScheme().equals(PicardBucketUtils.GOOGLE_CLOUD_STORAGE_FILESYSTEM_SCHEME), "This method is supported only for a GCS path: " + parentDir.getURIString());
ValidationUtils.validateArg(parentDir.getURIString().endsWith("/"), "parentDir must end in backslash '/': " + parentDir.getURIString());
return PicardHtsPath.fromPath(PicardBucketUtils.randomRemotePath(parentDir.getURIString(), "", "/"));
public static PicardHtsPath getRandomGCSDirectory(final String relativePath){
ValidationUtils.validateArg(relativePath.endsWith("/"), "relativePath must end in backslash '/': " + relativePath);
// This Picard test staging bucket has a TTL of 180 days (DeleteAction with Age = 180)
final String stagingDirectory = "gs://hellbender-test-logs/staging/picard/";
return PicardHtsPath.fromPath(PicardBucketUtils.randomRemotePath(stagingDirectory + relativePath, "", "/"));
}

/**
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/picard/sam/RevertSamTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package picard.sam;

import htsjdk.io.IOPath;
import htsjdk.samtools.*;
import htsjdk.samtools.util.CloserUtil;
import htsjdk.utils.ValidationUtils;
Expand Down Expand Up @@ -64,7 +65,8 @@
* To change this template use File | Settings | File Templates.
*/
public class RevertSamTest extends CommandLineProgramTest {
private final static PicardHtsPath DEFAULT_CLOUD_TEST_OUTPUT_DIR = PicardHtsPath.resolve(GCloudTestUtils.TEST_OUTPUT_DEFAULT_GCLOUD, "test/RevertSam/");
private final static String DEFAULT_CLOUD_TEST_OUTPUT_RELATIVE_PATH = "test/RevertSam/";
private final static PicardHtsPath DEFAULT_CLOUD_TEST_OUTPUT_DIR = PicardHtsPath.resolve(GCloudTestUtils.TEST_OUTPUT_DEFAULT_GCLOUD, DEFAULT_CLOUD_TEST_OUTPUT_RELATIVE_PATH);
public static final String REVERT_SAM_LOCAL_TEST_DATA_DIR = "testdata/picard/sam/RevertSam/";
private static final String basicSamToRevert = REVERT_SAM_LOCAL_TEST_DATA_DIR + "revert_sam_basic.sam";
private static final String sampleLibraryOverrideSam = REVERT_SAM_LOCAL_TEST_DATA_DIR + "revert_sam_sample_library_override.sam";
Expand Down Expand Up @@ -612,7 +614,7 @@ public Object[][] getCloudTestData() {
final PicardHtsPath tempLocalCram = PicardBucketUtils.getLocalTempFilePath("RevertSam", ".cram");
return new Object[][]{
// Output by read group without the output map, write output bams in the cloud.
{NA12878_MEDIUM_GCLOUD, PicardBucketUtils.getRandomGCSDirectory(DEFAULT_CLOUD_TEST_OUTPUT_DIR), OUTPUT_BY_READ_GROUP, null, null },
{NA12878_MEDIUM_GCLOUD, PicardBucketUtils.getRandomGCSDirectory(DEFAULT_CLOUD_TEST_OUTPUT_RELATIVE_PATH), OUTPUT_BY_READ_GROUP, null, null },
// Output by read group using the output map, write output bams in the cloud
{NA12878_MEDIUM_GCLOUD, null, OUTPUT_BY_READ_GROUP, DEFAULT_CLOUD_TEST_OUTPUT_DIR.getURIString(), null },
// Output by read group using the local output map, write output bams in the cloud
Expand All @@ -637,7 +639,7 @@ public Object[][] getCloudTestData() {
*
* Also see RevertSam::createOutputMapFromReadGroups(), which does part of what this method does (creates a dictionary rather than two lists).
*/
private PicardHtsPath getTmpTestReadGroupMapTable(final PicardHtsPath sam, final String perReadGroupPathBase) {
private PicardHtsPath getTmpTestReadGroupMapTable(final IOPath sam, final String perReadGroupPathBase) {
ValidationUtils.validateArg(sam.getExtension().isPresent(), "The variable sam must be a SAM file but is missing an extension: " + sam.getURIString());

final String samExtension = sam.getExtension().get();
Expand Down

0 comments on commit 9f2b757

Please sign in to comment.