class TempNumpyArrayFiles
¶
TempNumpyArrayFiles ([workDir]) |
To handle temporary numpy array files |
TempNumpyArrayFiles.updateArraysByBigWig (…) |
Update/resize all array files using given bigWig file |
TempNumpyArrayFiles.updateArraysByChromSize (…) |
Update/resize an array file using given chromosome and its size |
TempNumpyArrayFiles.addChromSizeInfo (…) |
Update chromosome sizes using new bigWig file |
TempNumpyArrayFiles.generateAllTempNumpyFiles () |
Generate all memory mapped numpy array files |
TempNumpyArrayFiles.generateTempNumpyFile (key) |
Generate a memory mapped numpy array file |
TempNumpyArrayFiles.fillAllArraysWithZeros () |
Fill all arrays with zeros. |
-
class
TempNumpyArrayFiles
(workDir=None)¶ To handle temporary numpy array files
To convert a Wig file to hdf5 file, data are parsed, and further stored temporarily in these memory-mapped numpy array files. Use of numpy arrays avoid dependency from storing chromosome location/coordinates because array index is used as the location/coordinates. Additionally, chromosome could be very large and to store these arrays could be memory expensive, these arrays are stored as binary files on the disk.
Note
These generated files are either automatically deleted after execution of script or by deleting [
del
]TempNumpyArrayFiles
instance.-
chromSizeInfo
¶ dict – Dictionary contains chromosome size. Numpy array files will be generated on the basis of these sizes.
-
files
¶ dict – Dictionary for names of temporary numpy array files, where keys are chromosomes and values are respective file names.
-
arrays
¶ dict – Dictionary of memory mapped numpy array (numpy.memmap), where keys are chromosomes and values are respective numpy.memmap arrays.
-
workDir
¶ str – Working directory where temporary numpy array files will be generated.
-
_generateTempNumpyFile
(key, regenerate=False)¶ enerate a memory mapped numpy array file
It is used to generate a memory mapped numpy array file for given chromosome for which size is already in the
TempNumpyArrayFiles.chromSizeInfo
dictionary.Warning
Private method. Use it at your own risk. It is used internally in
TempNumpyArrayFiles.generateTempNumpyFile()
.Parameters: - key (str) – chromosome name. Should be present as key in
TempNumpyArrayFiles.chromSizeInfo
. - regenerate (bool) – Replace or regenerate new memory mapped array for given chromosome
- key (str) – chromosome name. Should be present as key in
-
_getBigWigInfo
(filename)¶ Base method to Retrieve chromosome names and their sizes
- Use
TempNumpyArrayFiles.addChromSizeInfo()
to automatically retrieve chromosome size information from bigWig file and to store inTempNumpyArrayFiles.chromSizeInfo
.
Warning
Private method. Use it at your own risk. It is used internally in
TempNumpyArrayFiles.addChromSizeInfo()
Parameters: filename (str) – Input bigWig file - Use
-
addChromSizeInfo
(bigWigFileName)¶ Update chromosome sizes using new bigWig file
To update
TempNumpyArrayFiles.chromSizeInfo
for new bigWig files, this method can be used.Note
This method only updates the
TempNumpyArrayFiles.chromSizeInfo
dictionary. It does not resize numpy array files.Parameters: bigWigFileName (str) – Name of input bigWig file
-
fillAllArraysWithZeros
()¶ Fill all arrays with zeros.
To fill all memory mapped array with zero. It is used in
WigHandler
so that new data extracted from Wig files can be stored in these array files.
-
generateAllTempNumpyFiles
()¶ Generate all memory mapped numpy array files
It is used to generate all memory mapped numpy array files using the
TempNumpyArrayFiles.chromSizeInfo
dictionary.
-
generateTempNumpyFile
(key, regenerate=False)¶ Generate a memory mapped numpy array file
It is used to generate a memory mapped numpy array for given chromosome for which size is already the
TempNumpyArrayFiles.chromSizeInfo
dictionary.Parameters: - key (str) – chromosome name. Should be present as key in
TempNumpyArrayFiles.chromSizeInfo
. - regenerate (bool) – Replace or regenerate new memory mapped array for given chromosome
- key (str) – chromosome name. Should be present as key in
-