File: SetupSmallRunDirectory.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 (70 lines) | stat: -rwxr-xr-x 1,782 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
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
62
63
64
65
66
67
68
69
70
#!/usr/bin/python3

import os
import pwd
import sys


def verifyArguments():
    """
    Parse Fasta path arguments
    """
    helpMessage = """
    This script can be used to set up the run directory for a small
    run for which performance is not important.

    All binary files are created on disk, not on the huge page filesystem.

    This script creates empty directory Data.
    It also creates symbolic link DataOnDisk pointing to Data.

    When using this script, there is not need to use SetuHugePages.py to 
    set up the huge pages.

    After this runs, a shasta run can be started in the current directory.
    """

    if not len(sys.argv) == 1:
        print(helpMessage)
        exit(1)


def verifyDirectoryFiles(parentDirectory=""):
    """
    Make sure the run directory is clean before starting
    """
    # If any of these is present, don't do anything.
    mustNotExist = ['Data']
    
    for name in mustNotExist:
        path = os.path.abspath(os.path.join(parentDirectory, name))
        
        if os.path.lexists(path):
            print('%s must not exist. Remove it before running this script.' % path)
            exit(1)


def setupSmallRunDirectory(parentDirectory=""):
    """
    Generate directories and symlink required for the assembler to run
    """
    # Generate absolute paths to the files that will be created
    dataPath = os.path.abspath(os.path.join(parentDirectory, "Data"))
    dataOnDiskPath = os.path.abspath(os.path.join(parentDirectory, "DataOnDisk"))

    # Create the directories.
    os.mkdir(dataPath)
     
    # Create the symbolic links.
    os.symlink(dataPath, dataOnDiskPath)


def main():
    verifyArguments()
    verifyDirectoryFiles()
    setupSmallRunDirectory()


if __name__ == "__main__":
    main()