# Class PicardBucketUtils

java.lang.Object
picard.nio.PicardBucketUtils

public class PicardBucketUtils extends Object
Derived from BucketUtils.java in GATK

## Field Summary

Fields
Modifier and Type
Field
Description
`static final String`
`FILE_SCHEME`
`static final String`
`GCLOUD_PICARD_STAGING_DIRECTORY`
`static final String`
`GOOGLE_CLOUD_STORAGE_FILESYSTEM_SCHEME`
`static final String`
`HDFS_SCHEME`
`static final String`
`HTTP_FILESYSTEM_PROVIDER_SCHEME`
`static final String`
`HTTPS_FILESYSTEM_PROVIDER_SCHEME`

## Method Summary

Modifier and Type
Method
Description
`static PicardHtsPath`
`getLocalTempFilePath(String prefix, String extension)`
Creates a temporary file in a local directory.
`static PicardHtsPath`
`getRandomGCSDirectory(String relativePath)`
Creates a PicardHtsPath object to a "directory" on a Google Cloud System filesystem with a randomly generated URI.
`static PicardHtsPath`
`getTempFilePath(htsjdk.io.IOPath directory, String prefix, String extension)`
This overload of getTempFilePath takes the directory of type PicardHtsPath instead of String.
`static PicardHtsPath`
`getTempFilePath(String directory, String extension)`
Calls getTempFilePath with the empty string as the prefix.
`static PicardHtsPath`
`getTempFilePath(String directory, String prefix, String extension)`
Get a temporary file path based on the prefix and extension provided.
`static boolean`
`isEligibleForPrefetching(htsjdk.io.IOPath pathSpec)`
`static boolean`
`isEligibleForPrefetching(Path path)`
`static boolean`
`isGcsUrl(htsjdk.io.IOPath pathSpec)`
Return true if this `PicardHTSPath` represents a gcs URI.
`static Path`
`randomRemotePath(String stagingLocation, String prefix, String suffix)`
Picks a random name, by putting some random letters between "prefix" and "suffix".

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### GOOGLE_CLOUD_STORAGE_FILESYSTEM_SCHEME

public static final String GOOGLE_CLOUD_STORAGE_FILESYSTEM_SCHEME

See Also:
  - Constant Field Values

### HTTP_FILESYSTEM_PROVIDER_SCHEME

public static final String HTTP_FILESYSTEM_PROVIDER_SCHEME

See Also:
  - Constant Field Values

### HTTPS_FILESYSTEM_PROVIDER_SCHEME

public static final String HTTPS_FILESYSTEM_PROVIDER_SCHEME

See Also:
  - Constant Field Values

### HDFS_SCHEME

public static final String HDFS_SCHEME

See Also:
  - Constant Field Values

### FILE_SCHEME

public static final String FILE_SCHEME

See Also:
  - Constant Field Values

### GCLOUD_PICARD_STAGING_DIRECTORY

public static final String GCLOUD_PICARD_STAGING_DIRECTORY

See Also:
  - Constant Field Values

## Method Details

### getTempFilePath

public static PicardHtsPath getTempFilePath(String directory, String prefix, String extension)
Get a temporary file path based on the prefix and extension provided. This file (and possible indexes associated with it) will be scheduled for deletion on shutdown.

Parameters:
  `directory` - the directory where the temporary fill will be placed. May be null. For remote paths this should be a valid URI to root the temporary file in (e.g. gs://hellbender/staging/) If the directory is not a GCS or hadoop URL (or if it is null), the resulting temp file will be placed in the local tmp folder.
  `prefix` - the prefix to prepend before the randomly generated characters. Must have length >= 3 for local temp files.
  `extension` - an extension for the temporary file path. Must start with a period e.g. ".txt"
Returns:
  a new temporary path of the form [directory]/[prefix][random chars][.extension]

### getTempFilePath

public static PicardHtsPath getTempFilePath(htsjdk.io.IOPath directory, String prefix, String extension)
This overload of getTempFilePath takes the directory of type PicardHtsPath instead of String.

See Also:
  - `getTempFilePath(String, String, String)`

### getTempFilePath

public static PicardHtsPath getTempFilePath(String directory, String extension)
Calls getTempFilePath with the empty string as the prefix.

See Also:
  - `getTempFilePath(String, String, String)`

### getLocalTempFilePath

public static PicardHtsPath getLocalTempFilePath(String prefix, String extension)
Creates a temporary file in a local directory.

See Also:
  - `getTempFilePath(String, String, String)`

### getRandomGCSDirectory

public static PicardHtsPath getRandomGCSDirectory(String relativePath)
Creates a PicardHtsPath object to a "directory" on a Google Cloud System filesystem with a randomly generated URI. Note that the notion of directories does not exist in GCS. Thus, by "directory," we mean a path object with a randomly generated URI ending in "/", which the caller can use as a root URI/path for other files to be created e.g. via PicardHtsPath::resolve. Note that this method does *not* create an actual directory/file on GCS that one can write to, delete, or otherwise manipulate. See: https://stackoverflow.com/questions/51892343/google-gsutil-create-folder

Parameters:
  `relativePath` - The relative location for the new "directory" under the harcoded staging bucket with a TTL set e.g. "test/RevertSam/".
Returns:
  A PicardHtsPath object to a randomly generated "directory" e.g. "gs://hellbender-test-logs/staging/picard/test/RevertSam/{randomly-generated-string}/"

### randomRemotePath

public static Path randomRemotePath(String stagingLocation, String prefix, String suffix)
Picks a random name, by putting some random letters between "prefix" and "suffix".

Parameters:
  `stagingLocation` - The folder where you want the file to be. Must start with "gs://" or "hdfs://"
  `prefix` - The beginning of the file name
  `suffix` - The end of the file name, e.g. ".tmp"

### isGcsUrl

public static boolean isGcsUrl(htsjdk.io.IOPath pathSpec)
Return true if this `PicardHTSPath` represents a gcs URI.

Parameters:
  `pathSpec` - specifier to inspect
Returns:
  true if this `PicardHTSPath` represents a gcs URI.

### isEligibleForPrefetching

public static boolean isEligibleForPrefetching(htsjdk.io.IOPath pathSpec)

Parameters:
  `pathSpec` - specifier to inspect
Returns:
  true if this `GATKPath` represents a remote storage system which may benefit from prefetching (gcs or http(s))

### isEligibleForPrefetching

public static boolean isEligibleForPrefetching(Path path)

Parameters:
  `path` - path to inspect
Returns:
  true if this `Path` represents a remote storage system which may benefit from prefetching (gcs or http(s))