Files and I/O — ViennaRNA Package

# Files and I/O

Specialized Modules:

- Nucleic Acid Sequences and Structures
- Multiple Sequence Alignments
- Command Files

  Functions

  void vrna_file_copy(FILE *from, FILE *to)

    Inefficient ‘cp’.

        #include <ViennaRNA/io/utils.h>

  char *vrna_read_line(FILE *fp)

    Read a line of arbitrary length from a stream.

        #include <ViennaRNA/io/utils.h>

    Returns a pointer to the resulting string. The necessary memory is allocated and should be released using free() when the string is no longer needed.

    Parameters:

      - fp – A file pointer to the stream where the function should read from

    Returns:

      A pointer to the resulting string

  int vrna_mkdir_p(const char *path)

    Recursivly create a directory tree.

        #include <ViennaRNA/io/utils.h>

  char *vrna_basename(const char *path)

    Extract the filename from a file path.

        #include <ViennaRNA/io/utils.h>

  char *vrna_dirname(const char *path)

    Extract the directory part of a file path.

        #include <ViennaRNA/io/utils.h>

  char *vrna_filename_sanitize(const char *name, const char *replacement)

    Sanitize a file name.

        #include <ViennaRNA/io/utils.h>

    Returns a new file name where all invalid characters are substituted by a replacement character. If no replacement character is supplied, invalid characters are simply removed from the filename. File names may also never exceed a length of 255 characters. Longer file names will undergo a ‘smart’ truncation process, where the filenames’ suffix, i.e. everything after the last dot ‘.’, is attempted to be kept intact. Hence, only the filename part before the suffix is reduced in such a way that the total filename complies to the length restriction of 255 characters. If no suffix is present or the suffix itself already exceeds the maximum length, the filename is simply truncated from the back of the string.

    For now we consider the following characters invalid:

    - backslash ‘’

    - slash ‘/’

    - question mark ‘?’

    - percent sign ‘’

    - asterisk ‘*’

    - colon ‘:’

    - pipe symbol ‘|’

    - double quote ‘”’

    - triangular brackets ‘<’ and ‘>’

    Furthermore, the (resulting) file name must not be a reserved file name, such as:

    - ’.’

    - ’..’

    Note

    This function allocates a new block of memory for the sanitized string. It also may return (a) NULL if the input is pointing to NULL, or (b) an empty string if the input only consists of invalid characters which are simply removed!

    Parameters:

      - name – The input file name

      - replacement – The replacement character, or NULL

    Returns:

      The sanitized file name, or NULL

  int vrna_file_exists(const char *filename)

    Check if a file already exists in the file system.

        #include <ViennaRNA/io/utils.h>

    Parameters:

      - filename – The name of (path to) the file to check for existence

    Returns:

      0 if it doesn’t exists, 1 otherwise

  float **get_ribosum(const char **Alseq, int n_seq, int length)

    Retrieve a RiboSum Scoring Matrix for a given Alignment.

        #include <ViennaRNA/params/ribosum.h>

  float **readribosum(char *name)

    Read a RiboSum or other user-defined Scoring Matrix and Store into global Memory.

        #include <ViennaRNA/params/ribosum.h>