Package

fileutils

Permalink

package fileutils

Provides classes and methods for general bionformatic applications.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. fileutils
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. object TempFile

    Permalink
  2. def appendToFile(file: File, data: String): Unit

    Permalink

    Appends text to file.

    Appends text to file. Opens a new java.io.FileWriter on every call.

  3. def appendToFile(fileName: String, textData: String): Unit

    Permalink

    Appends text to file.

    Appends text to file. Opens a new java.io.FileWriter on every call.

  4. def cat(in: Iterable[File], out: File, header: Int = 0): Unit

    Permalink

    Concatenates text files together, dropping header lines for each, except the first.

  5. def createSource(s: File)(implicit codec: Codec): BufferedSource

    Permalink
  6. def createSourceFromZippedFile(file: String, bufferSize: Int = io.Source.DefaultBufSize)(implicit codec: Codec): BufferedSource

    Permalink

    Returns a scala.io.Source from the given GZipped file.

  7. def createSymbolicLink(from: File, to: File): File

    Permalink
  8. def exec(pb: ProcessBuilder, atMost: Duration = Duration.Inf)(stdOutFunc: (String) ⇒ Unit = x: String =>)(implicit stdErrFunc: (String) ⇒ Unit = (x: String) => ()): Int

    Permalink

    Execute command with user function to process each line of output.

    Execute command with user function to process each line of output.

    Based on from http://www.jroller.com/thebugslayer/entry/executing_external_system_commands_in Creates 3 new threads: one for the stdout, one for the stderror, and one waits for the exit code.

    pb

    Description of the executable process

    atMost

    Maximum time to wait for the process to complete. Default infinite.

    returns

    Exit code of the process.

  9. def execGetStreamsAndCode(pb: ProcessBuilder, unsuccessfulOnErrorStream: Boolean = true, atMost: Duration = Duration.Inf): (List[String], List[String], Boolean)

    Permalink

    Execute command.

    Execute command. Returns stdout and stderr as strings, and true if it was successful.

    A process is considered successful if its exit code is 0 and the error stream is empty. The latter criterion can be disabled with the unsuccessfulOnErrorStream parameter.

    pb

    The process description.

    unsuccessfulOnErrorStream

    if true, then the process is considered as a failure if its stderr is not empty.

    atMost

    max waiting time.

    returns

    (stdout,stderr,success) triples

  10. def execGetStreamsAndCodeWithLog(pb: ProcessBuilder, unsuccessfulOnErrorStream: Boolean = true, atMost: Duration = Duration.Inf)(implicit log: AnyRef { ... /* 2 definitions in type refinement */ }): (List[String], List[String], Boolean)

    Permalink

    Execute command.

    Execute command. Returns stdout and stderr as strings, and true if it was successful. Also writes to log.

    A process is considered successful if its exit code is 0 and the error stream is empty. The latter criterion can be disabled with the unsuccessfulOnErrorStream parameter.

    pb

    The process description.

    unsuccessfulOnErrorStream

    if true, then the process is considered as a failure if its stderr is not empty.

    atMost

    max waiting time.

    log

    A logger.

    returns

    (stdout,stderr,success) triples

  11. def fileIsEmpty(file: File): Boolean

    Permalink

    Returns true if file is empty.

  12. def getFileReader(fileName: File): BufferedReader

    Permalink

    Returns a java.io.BufferedReader.

  13. def getFileWriter(fileName: File, append: Boolean = false): BufferedWriter

    Permalink

    Returns a java.io.BufferedWriter.

  14. def isGZipFile(file: File): Boolean

    Permalink

    Returns true if the file is GZipped.

  15. def isGZipFile(file: String): Boolean

    Permalink

    Returns true if the file is GZipped.

  16. def openFileInputStream[T](fileName: File)(func: (BufferedInputStream) ⇒ T): T

    Permalink

    Opens a buffered java.io.BufferedInputStream on the file.

    Opens a buffered java.io.BufferedInputStream on the file. Closes it after the block is executed.

  17. def openFileInputStreamMaybeZipped[T](file: File)(func: (InputStream) ⇒ T): T

    Permalink
  18. def openFileOutputStream[T](fileName: File, append: Boolean = false)(func: (BufferedOutputStream) ⇒ T): T

    Permalink

    Opens a buffered java.io.BufferedOutputStream on the file.

    Opens a buffered java.io.BufferedOutputStream on the file. Closes it after the block is executed.

  19. def openFileReader[T](fileName: File)(func: (BufferedReader) ⇒ T): T

    Permalink

    Opens a buffered java.io.BufferedReader on the file.

    Opens a buffered java.io.BufferedReader on the file. Closes it after the block is executed.

  20. def openFileWriter[T](fileName: File, append: Boolean = false)(func: (BufferedWriter) ⇒ T): T

    Permalink

    Opens a java.io.BufferedWriter on the file.

    Opens a java.io.BufferedWriter on the file. Closes it after the block is executed.

  21. def openSource[A](s: File)(f: (Source) ⇒ A)(implicit codec: Codec): A

    Permalink

    Opens a scala.io.Source, executes the block, then closes the source.

    Opens a scala.io.Source, executes the block, then closes the source.

    s

    Path of the file

  22. def openSource[A](s: String)(f: (Source) ⇒ A)(implicit codec: Codec): A

    Permalink

    Opens a scala.io.Source, executes the block, then closes the source.

    Opens a scala.io.Source, executes the block, then closes the source.

    s

    Path of the file

  23. def openUnbufferedFileWriter[T](fileName: File, append: Boolean = false)(func: (Writer) ⇒ T): T

    Permalink

    Opens an unbuffered java.io.Writer on the file.

    Opens an unbuffered java.io.Writer on the file. Closes it after the block is executed.

  24. def openZippedFileInputStream[T](fileName: File)(func: (InputStream) ⇒ T): T

    Permalink

    Opens a java.io.OutputStream which writes GZip compressed data to the given path.

    Opens a java.io.OutputStream which writes GZip compressed data to the given path. Closes it after the block is executed.

  25. def openZippedFileOutputStream[T](fileName: File, append: Boolean = false)(func: (OutputStream) ⇒ T): T

    Permalink

    Opens a java.io.OutputStream which writes GZip compressed data to the given path.

    Opens a java.io.OutputStream which writes GZip compressed data to the given path. Closes it after the block is executed.

  26. def openZippedFileReader[T](fileName: File)(func: (BufferedReader) ⇒ T): T

    Permalink

    Opens a java.io.BufferedReader on a GZipped file.

    Opens a java.io.BufferedReader on a GZipped file. Closes it after the block is executed.

  27. def openZippedFileWriter[T](fileName: File, append: Boolean = false)(func: (Writer) ⇒ T): T

    Permalink

    Opens a java.io.BufferedWriter which writes GZip compressed data to the given path.

    Opens a java.io.BufferedWriter which writes GZip compressed data to the given path. Closes it after the block is executed.

  28. def putBesides(filesWithExtensions: (File, String)*): File

    Permalink

    Creates symbolic links with the same basename but different extensions.

    Creates symbolic links with the same basename but different extensions.

    filesWithExtensions

    files with the needed extensions

    returns

    A temporary File which points to the common part of the symbolic links paths.

  29. def readBinaryFile(f: File): Array[Byte]

    Permalink

    Reads file contents into a bytearray.

  30. def readBinaryFile(fileName: String): Array[Byte]

    Permalink

    Reads file contents into a bytearray.

  31. def readBinaryStream(f: InputStream): Array[Byte]

    Permalink

    Reads file contents into a bytearray.

  32. def readLines(s: File): Vector[String]

    Permalink
  33. def readLines(s: String): Vector[String]

    Permalink
  34. def readStreamAndClose(is: InputStream): Iterator[Byte] { ... /* 2 definitions in type refinement */ }

    Permalink

    Returns an iterator on the InputStream's data.

    Returns an iterator on the InputStream's data.

    Closes the stream when read through.

  35. def searchForFileInPath(fileName: String): Boolean

    Permalink

    Searches $PATH for the specified file

  36. implicit def stringSeqToProcess(command: Seq[String]): ProcessBuilder

    Permalink
  37. implicit def stringToProcess(command: String): ProcessBuilder

    Permalink
  38. def useResource[A <: AnyRef { def close(): Unit }, B](param: A)(f: (A) ⇒ B): B

    Permalink

    Returns the result of the block, and closes the resource.

    Returns the result of the block, and closes the resource.

    param

    closeable resource

    f

    block using the resource

  39. def using[A <: AnyRef { def close(): Unit }, B]: (A) ⇒ ((A) ⇒ B) ⇒ B

    Permalink

    Alias for useResource

  40. def writeBinaryToFile(file: File, data: Array[Byte]): Unit

    Permalink

    Writes binary data to file.

  41. def writeBinaryToFile(fileName: String, data: Array[Byte]): Unit

    Permalink

    Writes binary data to file.

  42. def writeBinaryToTempFile(data: Array[Byte]): File

    Permalink
  43. def writeByteBufferToFile(file: File, buff: ByteBuffer): Unit

    Permalink

    Writes the ByteBuffer's contents to a file.

  44. def writeByteBufferToFile(fileName: String, buff: ByteBuffer): Unit

    Permalink

    Writes the ByteBuffer's contents to a file.

  45. def writeToFile(file: File, data: String): Unit

    Permalink

    Writes text data to file.

  46. def writeToFile(fileName: String, data: String): Unit

    Permalink

    Writes text data to file.

  47. def writeToTempFile(data: String): File

    Permalink

Inherited from AnyRef

Inherited from Any

Ungrouped