class TextFileHandler

TextFileHandler(filename, shape[, binsize, …]) To import a genomic data from column text file format
TextFileHandler.readData() Read data from input file
class TextFileHandler(filename, shape, binsize=None, title=None, workDir=None)

To import a genomic data from column text file format

It reads text file, make an full array for given shape and fills the missing place with zeros. These zeros could be later masked to perform any analysis.

Example file format:

15670000    0.2917373776435852
15680000    0.2292359322309494
15690000    0.023434270173311234
15700000    0.06813383102416992
15710000    0.13660947978496552
15720000    0.17478400468826294
15730000    0.20540907979011536
.
.
.

This class is used in browser to visualize the genomic data, which are directly imported from text file.

filename

str – Input text file

shape

int – Size of array required to built

binsize

int – Size of bins expected in input file. If binsize = None, binsize will be determined from the files, however, it is good to give expected binsize to check whether expected binsize match with binsize present in input text file.

title

str – Title of the input data

workDir

str – Directory where temporary files will be generated. If None, defualt temporary directory of the respective OS will be used.

data

numpy.ndarray or numpy.memmap – One-dimensional array containing the data

tmpNumpyFileName

str – Name of temporary numpy memory-mapped file

Parameters:
  • filename (str) – Input text file
  • shape (int) – Size of array required to built
  • binsize (int) – Size of bins expected in input file. If binsize = None, binsize will be determined from the files, however, it is good to give expected binsize to check whether expected binsize match with binsize present in input text file.
  • title (str) – Title of the input data
  • workDir (str) – Directory where temporary files will be generated. If None, default temporary directory of the respective OS will be used.
_generateTempNumpyFile()

Generate temporary numpy memory-mapped file

_getBinSize()

Determine binsize from input file

_removeTempNumpyFile()

Remove temporary numpy memory-mapped file

readData()

Read data from input file

Read data from input file and store in TextFileHandler.data as one-dimensional array