File: RestoreRun.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 (32 lines) | stat: -rwxr-xr-x 986 bytes parent folder | download | duplicates (4)
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
#!/usr/bin/python3

import glob
import os
import shutil
import sys
import shasta

# Get from the arguments the list of input fasta files and check that they all exist.
helpMessage = "This script restores a run to memory from directory DataOnDisk."
if not len(sys.argv)==1:
    print(helpMessage)
    exit(1)

if not os.path.lexists('Data'):
    raise Exception('Missing: Data. Use SetupRunDirectory.py to set up the run directory.')

if not os.path.lexists('DataOnDisk'):
    raise Exception('Missing: DataOnDisk.')
    
if glob.glob('Data/*'):
    raise Exception('The Data directory is not empty. Nothing was restored.')

# Copy the Data directory.
# We cannot use regular copy commands because
# this is on the huge page filesystem.
inputFileNames = glob.glob('DataOnDisk/*')
for inputFileName in inputFileNames:
    lastSlashPosition = inputFileName.rfind('/')
    outputFileName = 'Data/' + inputFileName[lastSlashPosition+1:]
    shasta.mappedCopy(inputFileName, outputFileName)