From 9f2b757c9f84cbe75f45570bb0b02602d27f2ddc Mon Sep 17 00:00:00 2001 From: Takuto Sato Date: Tue, 30 Jul 2024 12:57:21 -0400 Subject: [PATCH] more edit --- src/main/java/picard/nio/PicardBucketUtils.java | 15 ++++++++------- src/test/java/picard/sam/RevertSamTest.java | 8 +++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/main/java/picard/nio/PicardBucketUtils.java b/src/main/java/picard/nio/PicardBucketUtils.java index b0a3781001..5bfdc32d56 100644 --- a/src/main/java/picard/nio/PicardBucketUtils.java +++ b/src/main/java/picard/nio/PicardBucketUtils.java @@ -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); } @@ -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, "", "/")); } /** diff --git a/src/test/java/picard/sam/RevertSamTest.java b/src/test/java/picard/sam/RevertSamTest.java index 151b0fa66a..00461b55b7 100755 --- a/src/test/java/picard/sam/RevertSamTest.java +++ b/src/test/java/picard/sam/RevertSamTest.java @@ -23,6 +23,7 @@ */ package picard.sam; +import htsjdk.io.IOPath; import htsjdk.samtools.*; import htsjdk.samtools.util.CloserUtil; import htsjdk.utils.ValidationUtils; @@ -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"; @@ -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 @@ -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();