rnafusion icon indicating copy to clipboard operation
rnafusion copied to clipboard

When using --genomes_base the function exists_not_empty does not work properly

Open Proton-NTA opened this issue 3 months ago • 0 comments

Description of the bug

When using the parameter --genomes_base with the provided aws pre-build references the function exists_not_empty of BUILD_REFERENCES does not work properly, resulting in building the reference anew for starfusion. This happens as the path_to_check.toFile().eachFileRecurse() function finds the empty files in GRCh38/gencode_v46/starfusion/ctat_genome_lib_build_dir/__chkpts/.

For a quick fix I used the following code:

  // StopIteration needed for graceful short-circuting
  class StopIteration extends RuntimeException {}
  
  //
  // A function to test if a file exists and is not empty.
  //   Input: A string that represents a file path
  //   Output: A boolean
  //
  def exists_not_empty(path) {
      // Return false for invalid values
      if(!path) {
          return false
      }
  
      def path_to_check = file(path as String)
      // Return false if the path does not exist
      if(!path_to_check.exists()) {
          return false
      }
  
      // Don't check directories if the path is not local
      def is_local = path_to_check.getScheme() == "file"
      if(!is_local || !path_to_check.toFile().isDirectory()) {
          return !path_to_check.isEmpty()
      }
  
      // Find any file that is not empty and stop on first occurrence
      def is_empty = true
      try {
          path_to_check.toFile().eachFileRecurse(groovy.io.FileType.FILES) { file ->
              is_empty = file.toPath().isEmpty() && is_empty
              // if found, short-circuit to stop recursion
              if (!is_empty) {
                  throw new StopIteration()
              }
          }
      // catch when stop thrown
      } catch (StopIteration e) {}
      return !is_empty
  }

Command used and terminal output


Relevant files

No response

System information

No response

Proton-NTA avatar Oct 10 '25 10:10 Proton-NTA