File: Mode2Assembly-B-Prepare.py

package info (click to toggle)
shasta 0.14.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 29,636 kB
  • sloc: cpp: 82,262; python: 2,348; makefile: 222; sh: 143
file content (61 lines) | stat: -rwxr-xr-x 1,511 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/python3

import os
import psutil
import sys

"""

This copies to /dev/null all binary data needed by Mode2Assembly-B.py.
Invoke from the assembly directory, which contains the Data directory.

It can be used to get these data in cache, if enough memory is available.

If possible, for best performance, use 

sudo blockdev --setra 65536 /dev/xyz

then when done

sudo blockdev --setra 256 /dev/xyz

where xyz is the block device that contains the assembly directory.


"""

files = [
    'Info', 
    'Markers.toc', 'Markers.data', 
    'MarkerGraphVertexTable', 
    'MarkerGraphVertices.toc', 'MarkerGraphVertices.data',
    'GlobalMarkerGraphEdges',
    'GlobalMarkerGraphEdgeMarkerIntervals.toc', 'GlobalMarkerGraphEdgeMarkerIntervals.data',
    'GlobalMarkerGraphEdgesBySource.toc', 'GlobalMarkerGraphEdgesBySource.data',
    'GlobalMarkerGraphEdgesByTarget.toc', 'GlobalMarkerGraphEdgesByTarget.data',
    'MarkerGraphEdgesConsensus.toc', 'MarkerGraphEdgesConsensus.data',
    'MarkerGraphEdgesConsensusOverlappingBaseCount']
    
gb = 1024 * 1024 * 1024
totalSize = 0
for file in files:
    totalSize = totalSize + os.path.getsize("Data/%s" % file)
print('Total size of the required binary data:', int(round(totalSize / gb)), 'GB')   

memory =  psutil.virtual_memory().total
print('Total physical memory:', int(round(memory / gb)), 'GB')


if totalSize > memory:
    sys.exit('Not enough memory.')
    

for file in files:
    os.system('cp Data/%s /dev/null' % file)
    
print('Done')