RNAlib-2.4.14
Files and I/O

Functions to parse, write, and convert various file formats and to deal with file system related issues. More...

Detailed Description

Functions to parse, write, and convert various file formats and to deal with file system related issues.

+ Collaboration diagram for Files and I/O:

Modules

 Nucleic Acid Sequences and Structures
 Functions to read/write different file formats for nucleic acid sequences and secondary structures.
 
 Multiple Sequence Alignments
 Functions to read/write multiple sequence alignments (MSA) in various file formats.
 
 Command Files
 Functions to parse and interpret the content of Command Files.
 

Files

file  commands.h
 Parse and apply different commands that alter the behavior of secondary structure prediction and evaluation.
 
file  ribo.h
 Parse RiboSum Scoring Matrices for Covariance Scoring of Alignments.
 
file  file_formats.h
 Read and write different file formats for RNA sequences, structures.
 
file  file_formats_msa.h
 Functions dealing with file formats for Multiple Sequence Alignments (MSA)
 
file  utils.h
 Several utilities for file handling.
 

Functions

float ** get_ribosum (const char **Alseq, int n_seq, int length)
 Retrieve a RiboSum Scoring Matrix for a given Alignment.
 
float ** readribosum (char *name)
 Read a RiboSum or other user-defined Scoring Matrix and Store into global Memory.
 
void vrna_file_copy (FILE *from, FILE *to)
 Inefficient `cp'.
 
char * vrna_read_line (FILE *fp)
 Read a line of arbitrary length from a stream. More...
 
int vrna_mkdir_p (const char *path)
 Recursivly create a directory tree.
 
char * vrna_basename (const char *path)
 Extract the filename from a file path.
 
char * vrna_dirname (const char *path)
 Extract the directory part of a file path.
 
char * vrna_filename_sanitize (const char *name, const char *replacement)
 Sanitize a file name. More...
 
int vrna_file_exists (const char *filename)
 Check if a file already exists in the file system. More...
 

Function Documentation

char* vrna_read_line ( FILE *  fp)

#include <ViennaRNA/io/utils.h>

Read a line of arbitrary length from a stream.

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
fpA file pointer to the stream where the function should read from
Returns
A pointer to the resulting string
char* vrna_filename_sanitize ( const char *  name,
const char *  replacement 
)

#include <ViennaRNA/io/utils.h>

Sanitize a file name.

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
nameThe input file name
replacementThe replacement character, or NULL
Returns
The sanitized file name, or NULL
int vrna_file_exists ( const char *  filename)

#include <ViennaRNA/io/utils.h>

Check if a file already exists in the file system.

Parameters
filenameThe name of (path to) the file to check for existence
Returns
0 if it doesn't exists, 1 otherwise