コード例 #1
0
def get_quast_process_starter():
    '''
    Get the QUAST process starter path in the local computer.
    '''

    # assign the QUAST process starter path
    quast_process_starter = '{0}/{1}-process-starter.sh'.format(xlib.get_temp_dir(), xlib.get_quast_code())

    # return the QUAST starter path
    return quast_process_starter
コード例 #2
0
ファイル: xgmap.py プロジェクト: GGFHF/NGScloud
def get_gmap_process_starter():
    '''
    Get the GMAP process starter path in the local computer.
    '''

    # assign the GMAP process starter path
    gmap_process_starter = '{0}/{1}-process-starter.sh'.format(xlib.get_temp_dir(), xlib.get_gmap_code())

    # return the GMAP starter path
    return gmap_process_starter
コード例 #3
0
def get_busco_process_starter():
    '''
    Get the BUSCO process starter path in the local computer.
    '''

    # assign the BUSCO process starter path
    busco_process_starter = '{0}/{1}-process-starter.sh'.format(xlib.get_temp_dir(), xlib.get_busco_code())

    # return the BUSCO starter path
    return busco_process_starter
コード例 #4
0
def get_gzip_process_starter(dataset_type):
    '''
    Get the gzip process starter path in the local computer.
    '''

    # assign the gzip process starter path
    name = 'result' if dataset_type == 'whole-result' else dataset_type
    gzip_process_starter = '{0}/{1}-{2}-starter.sh'.format(xlib.get_temp_dir(), xlib.get_gzip_code(), name)

    # return the gzip starter path
    return gzip_process_starter
コード例 #5
0
def get_infrastructure_software_installation_script():
    '''
    Get the infrastructure software installation script path in the local computer.
    '''

    # assign infrastructure software installation script path
    infrastructure_software_installation_script = '{0}/{1}'.format(
        xlib.get_temp_dir(), 'infrastructure_software_installation.sh')

    # return the infrastructure software installation script path
    return infrastructure_software_installation_script
コード例 #6
0
def get_fastqc_process_starter():
    '''
    Get the FastQC process starter path in the local computer.
    '''

    # assign the FastQC process starter path
    fastqc_process_starter = '{0}/{1}-process-starter.sh'.format(
        xlib.get_temp_dir(), xlib.get_fastqc_code())

    # return the FastQC starter path
    return fastqc_process_starter
コード例 #7
0
def get_cd_hit_est_process_starter():
    '''
    Get the CD-HIT-EST process starter path in the local computer.
    '''

    # assign the CD-HIT-EST process starter path
    cd_hit_est_process_starter = '{0}/{1}-process-starter.sh'.format(
        xlib.get_temp_dir(), xlib.get_cd_hit_est_code())

    # return the CD-HIT-EST starter path
    return cd_hit_est_process_starter
コード例 #8
0
ファイル: xcluster.py プロジェクト: GGFHF/NGScloud2
def open_terminal(cluster_name, node_name):
    '''
    Open a terminal window in a node of the cluster.
    '''

    # get the keypair file
    keypair_file = xconfiguration.get_keypair_file()

    # get the public IP address corresponding to the cluster node
    public_ip_address = xec2.get_node_data_dict(cluster_name,
                                                node_name)['public_ip_address']

    # set the command to start the terminal window and run ssh script
    if sys.platform.startswith('linux'):
        command = 'x-terminal-emulator -e ./sshinstance.sh {0} {1} {2}'.format(
            keypair_file, 'root', public_ip_address).split()
    elif sys.platform.startswith('darwin'):
        open_terminal_script = '{0}/open_terminal.sh'.format(
            xlib.get_temp_dir())
        try:
            if not os.path.exists(os.path.dirname(open_terminal_script)):
                os.makedirs(os.path.dirname(open_terminal_script))
            with open(open_terminal_script,
                      mode='w',
                      encoding='iso-8859-1',
                      newline='\n') as file_id:
                file_id.write('#!/bin/bash\n')
                file_id.write(
                    '#-------------------------------------------------------------------------------\n'
                )
                file_id.write('{0}\n'.format('cd {0}'.format(os.getcwd())))
                file_id.write('{0}\n'.format(
                    './sshinstance.sh {0} {1} {2}'.format(
                        keypair_file, 'root', public_ip_address)))
        except Exception as e:
            print('*** ERROR: The file {0} can not be created'.format(
                open_terminal_script))
        os.chmod(open_terminal_script, 0o744)
        command = 'open -a Terminal.app {0}'.format(
            open_terminal_script).split()

    elif sys.platform.startswith('win32') or sys.platform.startswith('cygwin'):
        command = 'cmd.exe /c start .\sshinstance.bat {0} {1} {2}'.format(
            keypair_file, 'root', public_ip_address).split()

    # open the new terminal
    process = subprocess.Popen(command)
コード例 #9
0
def get_starcluster_dir():
    '''
    Get the directory where StarCluster is installed.
    '''

    # initialize the control variable and the error list
    OK = True
    error_list = []

    # initialize the StarCluster directory
    starcluster_dir = ''

    # set the path of the file used to store the StarCluster information
    sci_file_path = '{0}/sci.txt'.format(xlib.get_temp_dir())

    # store the StarCluster information
    if OK:
        command = '{0} {1}'.format(xlib.get_sci(), sci_file_path)
        rc = xlib.run_command(command, sys.stdout)
        if rc != 0:
            error_list.append('*** ERROR: Return code {0} in command -> {1}\n'.format(rc, command))
            OK = False

    # find the StarCluster path
    if OK:
        try:
            file_id = open(sci_file_path, mode='r', encoding='iso-8859-1', newline='\n')
        except Exception as e:
            error_list.append('*** ERROR: The file {0} can not be opened.\n'.format(sci_file_path))
            OK = False
        else:
            OK = False
            record = file_id.readline()
            while record != '':
                if record.startswith('FILE'):
                    record = file_id.readline().strip()
                    starcluster_dir = record[:record.find('__init__.py')]
                    OK = True
                    break
                record = file_id.readline()

    # return the control variable, error list and StarCluster directory
    return (OK, error_list, starcluster_dir)
コード例 #10
0
def form_view_cluster_experiment_process_log():
    '''
    View the log of an experiment process in the cluster.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Logs - View an experiment process log in the cluster')

    # get the clustner name
    if OK:
        print(xlib.get_separator())
        if xec2.get_running_cluster_list(volume_creator_included=False) != []:
            cluster_name = cinputs.input_cluster_name(volume_creator_included=False, help=True)
        else:
            print('WARNING: There is not any running cluster.')
            OK = False

    # create the SSH client connection
    if OK:
        (OK, error_list, ssh_client) = xssh.create_ssh_client_connection(cluster_name, 'master')
        for error in error_list:
            log.write('{0}\n'.format(error))

    # create the SSH transport connection
    if OK:
        (OK, error_list, ssh_transport) = xssh.create_ssh_transport_connection(cluster_name, 'master')
        for error in error_list:
            log.write('{0}\n'.format(error))

    # create the SFTP client 
    if OK:
        sftp_client = xssh.create_sftp_client(ssh_transport)

    # get the experiment identification
    if OK:
        experiment_id = cinputs.input_experiment_id(ssh_client, help=True)
        if experiment_id == '':
            print('WARNING: The cluster has not experiment data.')
            OK = False

    # get the result_dataset identification
    if OK:
        result_dataset_id = cinputs.input_result_dataset_id('uncompressed', ssh_client, experiment_id, help=True)
        if result_dataset_id == '':
            print('WARNING: The experiment {0} has not result datasets.'.format(experiment_id))
            OK = False

    # create the local path
    if not os.path.exists(xlib.get_temp_dir()):
        os.makedirs(xlib.get_temp_dir())

    # get the log file name and build local and cluster paths
    if OK:
        log_file = xlib.get_cluster_log_file()
        local_path = '{0}/{1}'.format(xlib.get_temp_dir(), log_file)
        cluster_path = '{0}/{1}/{2}'.format(xlib.get_cluster_experiment_result_dir(experiment_id), result_dataset_id, log_file)

    # download the log file from the cluster
    if OK:
        print(xlib.get_separator())
        print('The file {0} is being downloaded from {1} ...'.format(log_file, cluster_path))
        OK = xssh.get_file(sftp_client, cluster_path, local_path)
        if OK:
            print('The file has been uploaded.')

    # close the SSH transport connection
    if OK:
        xssh.close_ssh_transport_connection(ssh_transport)

    # close the SSH client connection
    if OK:
        xssh.close_ssh_client_connection(ssh_client)
    
    # view the log file
    if OK:
        text = 'Logs - View an experiment process log in the cluster'
        OK = clib.view_file(local_path, text)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
コード例 #11
0
ファイル: clog.py プロジェクト: GGFHF/NGScloud2
def form_view_cluster_start_log():
    '''
    View the cluster start log.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Logs - View the cluster start log')

    # get the clustner name
    if OK:
        print(xlib.get_separator())
        if xec2.get_running_cluster_list(only_environment_cluster=True,
                                         volume_creator_included=False) != []:
            cluster_name = cinputs.input_cluster_name(
                volume_creator_included=False, help=True)
        else:
            print('WARNING: There is not any running cluster.')
            OK = False

    # create the SSH client connection
    if OK:
        (OK, error_list,
         ssh_client) = xssh.create_ssh_client_connection(cluster_name)
        for error in error_list:
            print(error)

    # create the SSH transport connection
    if OK:
        (OK, error_list,
         ssh_transport) = xssh.create_ssh_transport_connection(cluster_name)
        for error in error_list:
            print(error)

    # create the SFTP client
    if OK:
        sftp_client = xssh.create_sftp_client(ssh_transport)

    # create the local path
    if not os.path.exists(xlib.get_temp_dir()):
        os.makedirs(xlib.get_temp_dir())

    # get the log file name and build local and cluster paths
    if OK:
        local_path = f'{xlib.get_temp_dir()}/{os.path.basename(xinstance.get_infrastructure_software_installation_log())}'
        cluster_path = f'/home/ubuntu/{os.path.basename(xinstance.get_infrastructure_software_installation_log())}'

    # download the log file from the cluster
    if OK:
        print(xlib.get_separator())
        print(
            f'The file {os.path.basename(xinstance.get_infrastructure_software_installation_log())} is being downloaded from {cluster_path} ...'
        )
        OK = xssh.get_file(sftp_client, cluster_path, local_path)
        if OK:
            print('The file has been uploaded.')

    # close the SSH transport connection
    if OK:
        xssh.close_ssh_transport_connection(ssh_transport)

    # close the SSH client connection
    if OK:
        xssh.close_ssh_client_connection(ssh_client)

    # view the log file
    if OK:
        text = 'Logs - View the cluster start log'
        OK = clib.view_file(local_path, text)

    # show continuation message
    input('Press [Intro] to continue ...')