Exemplo n.º 1
0
def build_fastqc_process_starter(current_run_dir):
    '''
    Build the starter of the current FastQC process.
    '''

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

    # write the FastQC process starter
    try:
        if not os.path.exists(os.path.dirname(get_fastqc_process_starter())):
            os.makedirs(os.path.dirname(get_fastqc_process_starter()))
        with open(get_fastqc_process_starter(),
                  mode='w',
                  encoding='utf8',
                  newline='\n') as file_id:
            file_id.write('{0}\n'.format('#!/bin/bash'))
            file_id.write('{0}\n'.format(
                '#-------------------------------------------------------------------------------'
            ))
            file_id.write('{0}\n'.format('{0}/{1} &>{0}/{2}'.format(
                current_run_dir, os.path.basename(get_fastqc_process_script()),
                xlib.get_cluster_log_file())))
    except:
        error_list.append('*** ERROR: The file {0} can not be created'.format(
            get_fastqc_process_starter()))
        OK = False

    # return the control variable and the error list
    return (OK, error_list)
Exemplo n.º 2
0
def build_gzip_process_starter(dataset_type, current_run_dir):
    '''
    Build the starter of the current gzip process.
    '''

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

    # get the log file name
    log_file = xlib.get_cluster_log_file()

    # write the gzip process starter
    try:
        if not os.path.exists(os.path.dirname(get_gzip_process_starter(dataset_type))):
            os.makedirs(os.path.dirname(get_gzip_process_starter(dataset_type)))
        with open(get_gzip_process_starter(dataset_type), 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('{0}/{1} &>>{0}/{2}'.format(current_run_dir, os.path.basename(get_gzip_process_script(dataset_type)), log_file)))
    except Exception as e:
        error_list.append(f'*** EXCEPTION: "{e}".')
        error_list.append('*** ERROR: The file {0} can not be created'.format(get_gzip_process_starter(dataset_type)))
        OK = False

    # return the control variable and the error list
    return (OK, error_list)
Exemplo n.º 3
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 ...')