Пример #1
0
def form_run_pipeline_process(pipeline_type):
    '''
    Run a pipeline process with the parameters in the corresponding config file.
    '''

    # initialize the control variable
    OK = True

    # set the pipeline name
    if pipeline_type == xlib.get_toa_process_pipeline_nucleotide_code():
        name = xlib.get_toa_process_pipeline_nucleotide_name()

    elif pipeline_type == xlib.get_toa_process_pipeline_aminoacid_code():
        name = xlib.get_toa_process_pipeline_aminoacid_name()

    elif pipeline_type == xlib.get_toa_process_merge_annotations_code():
        name = xlib.get_toa_process_merge_annotations_name()

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment(f'{name} - Run process')

    # confirm the process run
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action(f'The {name} process is going to be run.')

    # run the process
    if OK:

        if pipeline_type == xlib.get_toa_process_pipeline_nucleotide_code():
            devstdout = xlib.DevStdOut(xtoa.run_pipeline_process.__name__)
            OK = xtoa.run_pipeline_process(pipeline_type,
                                           devstdout,
                                           function=None)

        elif pipeline_type == xlib.get_toa_process_pipeline_aminoacid_code():
            devstdout = xlib.DevStdOut(xtoa.run_pipeline_process.__name__)
            OK = xtoa.run_pipeline_process(pipeline_type,
                                           devstdout,
                                           function=None)

        elif pipeline_type == xlib.get_toa_process_merge_annotations_code():
            devstdout = xlib.DevStdOut(
                xtoa.run_annotation_merger_process.__name__)
            OK = xtoa.run_annotation_merger_process(devstdout, function=None)

    # show continuation message
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #2
0
def form_manage_toa_database(process_type):
    '''
    Manage the TOA database.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    if process_type == xlib.get_toa_type_recreate():
        clib.print_headers_with_environment(
            f'{xlib.get_toa_name()} - Recreate database')
    elif process_type == xlib.get_toa_type_rebuild():
        clib.print_headers_with_environment(
            f'{xlib.get_toa_name()} - Rebuild database')

    # confirm the process run
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action(
            f'The {xlib.get_toa_name()} database is going to be {process_type}.'
        )

    # run the process
    if OK:
        devstdout = xlib.DevStdOut(xtoa.manage_toa_database.__name__)
        OK = xtoa.manage_toa_database(process_type, devstdout, function=None)

    # show continuation message
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #3
0
def form_restart_cluster():
    '''
    Restart a cluster.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Cluster operation - Restart cluster')

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

    # confirm the restarting of the cluster
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action('The cluster is going to be restarted.')

    # stop the cluster
    if OK:
        devstdout = xlib.DevStdOut(xcluster.restart_cluster.__name__)
        OK = xcluster.restart_cluster(cluster_name, devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #4
0
def form_remove_volume():
    '''
    Remove a volume in the current zone.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Volume operation - Remove volume')

    # get current zone name
    zone_name = xconfiguration.get_current_zone_name()

    # get the volume name
    print(xlib.get_separator())
    volume_name = cinputs.input_volume_name(zone_name, template_name='', help=True, help_type='created')

    # confirm the removal of the volume
    print(xlib.get_separator())
    OK = clib.confirm_action('The volume is going to be removed.')

    # remove the volume
    if OK:
        devstdout = xlib.DevStdOut(xvolume.remove_volume.__name__)
        OK = xvolume.remove_volume(volume_name, devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #5
0
def form_show_cluster_composing():
    '''
    Show cluster information of every node: OS, CPU number and memory.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Cluster operation - Show cluster composing')

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

    # show the status of batch jobs
    if OK:
        devstdout = xlib.DevStdOut(xcluster.show_cluster_composing.__name__)
        xcluster.show_cluster_composing(cluster_name, devstdout, function=None)

    # show continuation message
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #6
0
def form_kill_batch_job():
    '''
    Kill a batch job in the cluster.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Cluster operation - Kill batch job')

    # get the cluster name, experiment identification, read dataset identification and the file pattern
    print(xlib.get_separator())
    if xec2.get_running_cluster_list(volume_creator_included=False) == []:
        print('WARNING: There is not any running cluster.')
        OK = False
    else:
        cluster_name = cinputs.input_cluster_name(volume_creator_included=False, help=True)

    # 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:
            print(error)

    # get the batch job identificaction
    if OK:
        batch_job_id = cinputs.input_batch_job_id(ssh_client, help=True)
        if batch_job_id == '':
            print('WARNING: There is not any batch job.')
            OK = False

    # confirm the kill of the batch job
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action('The batch job {0} is going to be killed.'.format(batch_job_id))

    # kill the batch job
    if OK:
        devstdout = xlib.DevStdOut(xcluster.kill_batch_job.__name__)
        xcluster.kill_batch_job(cluster_name, batch_job_id, devstdout, function=None)

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

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #7
0
def form_delink_volume_from_template():
    '''
    Delink a volume from a cluster template
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Configuration - Delink volume in a cluster template')

    # get current zone name
    zone_name = xconfiguration.get_current_zone_name()

    # get the template name and the volume name
    print(xlib.get_separator())
    template_name = cinputs.input_template_name(volume_creator_included=False, help=True, is_all_possible=True)
    volume_name = cinputs.input_volume_name(zone_name, template_name, help=True, help_type='linked')
 
    # verify there is some volume linked to the cluster template
    if volume_name == '':
        print(xlib.get_separator())
        print('*** WARNING: There is not any volume linked to the cluster template.')
        OK = False
 
    # confirm the exclusion of the volume
    if OK:
        print(xlib.get_separator())
        if template_name == 'all':
            OK = clib.confirm_action('The volume {0} is going to be delinked from every template.'.format(volume_name))
        else:
            OK = clib.confirm_action('The volume {0} is going to be delinked from the template {0}.'.format(volume_name, template_name))

    # delink a volume in a cluster template
    if OK:
        print(xlib.get_separator())
        print('The volume {0} is being delinked from the cluster template {1}.'.format(volume_name, template_name))
        devstdout = xlib.DevStdOut(xconfiguration.delink_volume_from_template.__name__)
        (OK, error_list) = xconfiguration.delink_volume_from_template(template_name, volume_name, devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #8
0
def form_restart_pipeline_process(pipeline_type):
    '''
    Restart a pipeline process from the last step ended OK.
    '''

    # initialize the control variable
    OK = True

    # set the pipeline name
    if pipeline_type == xlib.get_toa_process_pipeline_nucleotide_code():
        name = xlib.get_toa_process_pipeline_nucleotide_name()
    elif pipeline_type == xlib.get_toa_process_pipeline_aminoacid_code():
        name = xlib.get_toa_process_pipeline_aminoacid_name()

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment(f'{name} - Run process')

    # get the pipeline dataset identification
    app_list = [pipeline_type]
    pipeline_dataset_id = cinputs.input_result_dataset_id(
        xlib.get_toa_result_pipeline_dir(), app_list)
    if pipeline_dataset_id == '':
        print(f'WARNING: There are not any {pipeline_type} result datasets.')
        OK = False

    # confirm the process run
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action(f'The {name} process is going to be run.')

    # run the process
    if OK:

        devstdout = xlib.DevStdOut(xtoa.restart_pipeline_process.__name__)
        OK = xtoa.restart_pipeline_process(pipeline_type,
                                           pipeline_dataset_id,
                                           devstdout,
                                           function=None)

    # show continuation message
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #9
0
def form_mount_volume():
    '''
    Mount a volume in a node.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Volume operation - Mount volume in a node')

    # get current zone name
    zone_name = xconfiguration.get_current_zone_name()

    # get the cluster name and node name
    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)
        node_name = cinputs.input_node_name(cluster_name, new=False, is_master_valid=True, help=True)
    else:
        print('WARNING: There is not any running cluster.')
        OK = False

    # get the volume name, AWS device file and directory path
    if OK:
        volume_name = cinputs.input_volume_name(zone_name, template_name='', help=True, help_type='created')
        aws_device_file = cinputs.input_device_file(node_name, volume_name)
        mounting_path = cinputs.input_mounting_path(node_name, aws_device_file)

    # confirm the mounting of the volume
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action('The volume is going to be mounted.')

    # mount the volume in the node
    if OK:
        devstdout = xlib.DevStdOut(xvolume.mount_volume.__name__)
        xvolume.mount_volume(cluster_name, node_name, volume_name, aws_device_file, mounting_path, devstdout, function=None, is_menu_call=True)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #10
0
def form_list_clusters():
    '''
    List clusters.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Cluster operation - List clusters')

    # list clusters
    devstdout = xlib.DevStdOut(xcluster.list_clusters.__name__)
    OK = xcluster.list_clusters(devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #11
0
def form_terminate_cluster(force):
    '''
    Terminate a cluster.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    if not force:
        clib.print_headers_with_environment('Cluster operation - Terminate cluster')
    else:
        clib.print_headers_with_environment('Cluster operation - Force termination of a cluster')

    # get the cluster name that must be terminated
    print(xlib.get_separator())
    if not force:
        if xec2.get_running_cluster_list(volume_creator_included=False) == []:
            print('WARNING: There is not any running cluster.')
            OK = False
        else:
            cluster_name = cinputs.input_cluster_name(volume_creator_included=False, help=True)
    else:
        cluster_name = cinputs.input_template_name(volume_creator_included=False, help=False, is_all_possible=False)

    # confirm the termination of the cluster
    if OK:
        print(xlib.get_separator())
        if not force:
            OK = clib.confirm_action('The cluster is going to be terminated.')
        else:
            OK = clib.confirm_action('The cluster is going to be forced to terminate.')

    # terminate the cluster
    if OK:
        devstdout = xlib.DevStdOut(xcluster.terminate_cluster.__name__)
        OK = xcluster.terminate_cluster(cluster_name, force, devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #12
0
def form_review_volume_links():
    '''
    Review linked volumes of cluster templates in order to remove linked volumes
    that do not currently exist.
    '''

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

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Configuration - Review volumes linked to cluster templates')

    # get current zone name
    zone_name = xconfiguration.get_current_zone_name()

    # get the NGScloud confign file
    ngscloud_config_file = xconfiguration.get_ngscloud_config_file()

    # verify if there are any volumes linked
    if xconfiguration.get_volumes_dict() == {}:
        print(xlib.get_separator())
        print('WARNING: There is not any volume linked.')
        OK = False
 
    # confirm the review of volumes links
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action('The file {0} is going to be reviewed in order to remove volumes linked which are not currently created in the zone {1}.'.format(ngscloud_config_file, zone_name))

    # review volumen link
    if OK:
        devstdout = xlib.DevStdOut(xconfiguration.review_volume_links.__name__)
        (OK, error_list) = xconfiguration.review_volume_links(zone_name, devstdout, function=None)

    # show continuation message or exit of application
    print(xlib.get_separator())
    if not OK and error_list != []:
        raise xlib.ProgramException('C001')
    else:
        input('Press [Intro] to continue ...')
Пример #13
0
def form_create_volume():
    '''
    Create a volume in the current zone.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Volume operation - Create volume')

    # get current zone name
    zone_name = xconfiguration.get_current_zone_name()

    # show sites related to EBS volumes
    print(xlib.get_separator())
    print('You can consult the characteristics of the EBS volumes in:')
    print('    https://aws.amazon.com/ebs/details/')
    print('and the EBS pricing is detailed in:')
    print('    https://aws.amazon.com/ebs/pricing/')

    # get the cluster name, node name, volume name, volume type and volume size
    print(xlib.get_separator())
    volume_name = cinputs.input_volume_name(zone_name, template_name='', help=False, help_type='created')
    volume_type = cinputs.input_volume_type()
    volume_size = cinputs.input_volume_size(volume_type)
    terminate_indicator = cinputs.input_terminate_indicator()

    # confirm the creation of the volume
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action('The volume is going to be created.')

    # create the volume
    if OK:
        devstdout = xlib.DevStdOut(xvolume.create_volume.__name__)
        OK = xvolume.create_volume(volume_name, volume_type, volume_size, terminate_indicator, devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #14
0
def form_create_cluster():
    '''
    Create a cluster from a template name.
    '''

    # initialize the control variable
    OK = True

    # initialize the state variables
    master_state_code = ''
    master_state_name = ''

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Cluster operation - Create cluster')

    # show sites related to EBS volumes
    print(xlib.get_separator())
    print('You can consult the characteristics of the EC2 intance types in:')
    print('    https://aws.amazon.com/ec2/instance-types/')
    print('and the EC2 pricing is detailed in:')
    print('    https://aws.amazon.com/ec2/pricing/')
    print()

    # get the template name and set the cluster name
    print(xlib.get_separator())
    template_name = cinputs.input_template_name(volume_creator_included=False, help=True, is_all_possible=False)
    cluster_name = template_name

    # confirm the creation of the cluster
    print(xlib.get_separator())
    OK = clib.confirm_action('The cluster is going to be created.')

    # create the cluster
    if OK:
        devstdout = xlib.DevStdOut(xcluster.create_cluster.__name__)
        (OK, master_state_code, master_state_name) = xcluster.create_cluster(template_name, cluster_name, devstdout, function=None, is_menu_call=True)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #15
0
def form_add_node():
    '''
    Add a node in a cluster.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Node operation - Add node in a cluster')

    # get the cluster name and node name
    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)
        if len(xec2.get_cluster_node_list(cluster_name)) >= xec2.get_max_node_number():
            print('WARNING: The maximum number ({0}) of instances is already running.'.format(xec2.get_max_node_number()))
            OK = False
        else:
            node_name = cinputs.input_node_name(cluster_name, new=True, is_master_valid=False, help=True)
    else:
        print('WARNING: There is not any running cluster.')
        OK = False

    # confirm the addition of the node in the cluster
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action('The node is going to be added.')

    # add node in cluster
    if OK:
        devstdout = xlib.DevStdOut(xnode.add_node.__name__)
        xnode.add_node(cluster_name, node_name, devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #16
0
def form_remove_node():
    '''
    Remove a node in a cluster.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Node operation - Remove node in a cluster')

    # get the cluster name and node name
    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)
        node_name = cinputs.input_node_name(cluster_name, new=False, is_master_valid=False, help=True)
        if node_name == []:
            print('WARNING: There is not any running node besides the master.')
            OK = False
    else:
        print('WARNING: There is not any running cluster.')
        OK = False

    # confirm the removal of the node in the cluster
    if OK:
        print(xlib.get_separator())
        OK = clib.confirm_action('The node is going to be removed.')

    # remove node
    if OK:
        devstdout = xlib.DevStdOut(xnode.remove_node.__name__)
        xnode.remove_node(cluster_name, node_name, devstdout, function=None)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #17
0
def form_terminate_volume_creator():
    '''
    Terminate de volume creator of the current zone.
    '''

    # initialize the control variable
    OK = True

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment('Volume operation - Terminate volume creator')

    # confirm the termination of the volume creator
    print(xlib.get_separator())
    OK = clib.confirm_action('The volume creator is going to be terminated.')

    # terminate the volume creator
    if OK:
        devstdout = xlib.DevStdOut(xcluster.terminate_cluster.__name__)
        xcluster.terminate_cluster(xlib.get_volume_creator_name(), True, devstdout, function=None, is_menu_call=False)

    # show continuation message 
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #18
0
def form_manage_genomic_database(process_type, genomic_database):
    '''
    Manage processes of genomic database.
    '''

    # initialize the control variable
    OK = True

    # set the genomica database name
    if genomic_database == xlib.get_toa_data_basic_data_code():
        name = xlib.get_toa_data_basic_data_name()
    elif genomic_database == xlib.get_toa_data_gymno_01_code():
        name = xlib.get_toa_data_gymno_01_name()
    elif genomic_database == xlib.get_toa_data_dicots_04_code():
        name = xlib.get_toa_data_dicots_04_name()
    elif genomic_database == xlib.get_toa_data_monocots_04_code():
        name = xlib.get_toa_data_monocots_04_name()
    elif genomic_database == xlib.get_toa_data_refseq_plant_code():
        name = xlib.get_toa_data_refseq_plant_name()
    elif genomic_database == xlib.get_toa_data_taxonomy_code():
        name = xlib.get_toa_data_taxonomy_name()
    elif genomic_database == xlib.get_toa_data_nt_code():
        name = xlib.get_toa_data_nt_name()
    elif genomic_database == xlib.get_toa_data_viridiplantae_nucleotide_gi_code(
    ):
        name = xlib.get_toa_data_viridiplantae_nucleotide_gi_name()
    elif genomic_database == xlib.get_toa_data_nr_code():
        name = xlib.get_toa_data_nr_name()
    elif genomic_database == xlib.get_toa_data_viridiplantae_protein_gi_code():
        name = xlib.get_toa_data_viridiplantae_protein_gi_name()
    elif genomic_database == xlib.get_toa_data_gene_code():
        name = xlib.get_toa_data_gene_name()
    elif genomic_database == xlib.get_toa_data_interpro_code():
        name = xlib.get_toa_data_interpro_name()
    elif genomic_database == xlib.get_toa_data_go_code():
        name = xlib.get_toa_data_go_name()

    # print the header
    clib.clear_screen()
    if process_type == xlib.get_toa_type_build_blastplus_db():
        clib.print_headers_with_environment(f'Build {name} for BLAST+')
    elif process_type == xlib.get_toa_type_build_diamond_db():
        clib.print_headers_with_environment(f'Build {name} for DIAMOND')
    elif process_type == xlib.get_toa_type_build_gilist():
        clib.print_headers_with_environment(f'Build {name}')
    elif process_type == xlib.get_toa_type_build_proteome():
        clib.print_headers_with_environment(f'Build {name} proteome')
    elif process_type == xlib.get_toa_type_download_data():
        clib.print_headers_with_environment(
            f'Download {name} functional annotations')
    elif process_type == xlib.get_toa_type_load_data():
        clib.print_headers_with_environment(
            f'Load {name} data in {xlib.get_toa_name()} database')
    print(xlib.get_separator())

    # confirm the process run
    if OK:
        OK = clib.confirm_action(f'The {name} process is going to be run.')

    # run the process
    if OK:
        devstdout = xlib.DevStdOut(xtoa.manage_genomic_database.__name__)
        OK = xtoa.manage_genomic_database(process_type,
                                          genomic_database,
                                          devstdout,
                                          function=None)

    # show continuation message
    print(xlib.get_separator())
    input('Press [Intro] to continue ...')
Пример #19
0
def main(argv):
    '''
    Main line of the program.
    '''

    # verify the operating system.
    if not sys.platform.startswith('linux') and not sys.platform.startswith(
            'darwin') and not sys.platform.startswith(
                'win32') and not sys.platform.startswith('cygwin'):
        print('*** ERROR: The {1} OS is not supported.'.format(sys.platform))
        sys.exit(1)

    # verify the Python version.
    if sys.version_info[0] == 3 and sys.version_info[1] >= 5:
        pass
    else:
        print('A Python version equal or greater than 3.5 is required.')
        sys.exit(1)

    # verify if Boto3 is set up
    try:
        import boto3
    except:
        print('*** ERROR: The library boto3 is not installed.')
        print('Please, review how to set up Boto3 in the manual.')
        sys.exit(1)

    # verify if Paramiko is set up
    try:
        import paramiko
    except:
        print('*** ERROR: The library paramiko is not installed.')
        print('Please, review how to set up Paramiko in the manual.')
        sys.exit(1)

    # verify if Paramiko is set up
    try:
        import paramiko
    except:
        print('*** ERROR: The library paramiko is not installed.')
        print('Please, review how to set up Paramiko in the manual.')
        sys.exit(1)

    # get and verify the options
    parser = build_parser()
    (options, args) = parser.parse_args()
    verify_options(options)

    # verify if the required graphical libraries are setup
    if options.mode == 'gui' or options.mode is None:

        # verify if the library PIL.Image is set up
        try:
            import tkinter
        except:
            print('*** ERROR: The library tkinter is not installed.')
            print('Please, review how to set up Tkinter in the manual.')
            sys.exit(1)

        # verify if the library PIL.Image is set up
        try:
            import PIL.Image
        except:
            print('*** ERROR: The library PIL.Image is not installed.')
            print('Please, review how to set up PIL.Image in the manual.')
            sys.exit(1)

        # verify if the library PIL.ImageTk is set up
        try:
            import PIL.ImageTk
        except:
            print('*** ERROR: The library PIL.ImageTk is not installed.')
            print('Please, review how to set up PIL.ImageTk in the manual.')
            sys.exit(1)

    # import required application libraries
    import ccloud
    import cmenu
    import gmain
    import xlib

    # verify if StarCluster is set up
    command = '{0} --version'.format(xlib.get_starcluster())
    devstdout = xlib.DevStdOut('starcluster_version', print_stdout=False)
    rc = xlib.run_command(command, devstdout)
    if rc != 0:
        print(
            '*** ERROR: The cluster-computing toolkit StarCluster 0.95.6 is not installed or excecution permissions have not set.'
        )
        print('Please, review how to set up in the manual.')
        sys.exit(1)
    else:
        with open(devstdout.get_log_file(), 'r') as log_command:
            version_found = False
            for line in log_command:
                if line.startswith('0.95.6'):
                    version_found = True
            if not version_found:
                print(
                    '*** ERROR: The cluster-computing toolkit StarCluster 0.95.6 is not installed or excecution permissions have not set.'
                )
                print('Please, review how to set up in the manual.')
                sys.exit(1)

    # start the user interface depending on the mode
    if options.mode == 'gui' or options.mode is None:
        main = gmain.Main()
        main.mainloop()
    else:
        ccloud.form_set_environment()
        cmenu.build_menu_main()
Пример #20
0
def form_install_bioinfo_app(app_code):
    '''
    Install the bioinfo application software in the cluster.
    '''

    # initialize the control variable
    OK = True

    # set the bioinfo application name
    if app_code == xlib.get_blastplus_code():
        app_name = xlib.get_blastplus_name()

    elif app_code == xlib.get_diamond_code():
        app_name = xlib.get_diamond_name()

    elif app_code == xlib.get_entrez_direct_code():
        app_name = xlib.get_entrez_direct_name()

    elif app_code == xlib.get_miniconda3_code():
        app_name = xlib.get_miniconda3_name()

    elif app_code == xlib.get_r_code():
        app_name = xlib.get_r_name()

    elif app_code == xlib.get_transdecoder_code():
        app_name = xlib.get_transdecoder_name()

    # print the header
    clib.clear_screen()
    clib.print_headers_with_environment(f'{app_name} - Install software')

    # confirm the software installation
    print(xlib.get_separator())
    if app_code == xlib.get_miniconda3_code():
        OK = clib.confirm_action(
            f'{app_name} (Conda infrastructure) is going to be installed. All Conda packages previously installed will be lost and they have to be reinstalled.'
        )
    elif app_code == xlib.get_r_code():
        OK = clib.confirm_action(
            f'{app_name} and analysis packages are going to be installed. The previous version will be lost, if it exists.'
        )
    else:
        OK = clib.confirm_action(
            f'The {app_name} Conda package is going to be installed. The previous version will be lost, if it exists.'
        )

    # install the software
    if OK:

        # install the BLAST+ software
        if app_code == xlib.get_blastplus_code():
            # -- package_code_list = [(xlib.get_blastplus_conda_code(), 'last')]
            package_code_list = [(xlib.get_blastplus_conda_code(), '2.9.0')]
            devstdout = xlib.DevStdOut(
                xbioinfoapp.install_conda_package_list.__name__)
            OK = xbioinfoapp.install_conda_package_list(app_code,
                                                        app_name,
                                                        package_code_list,
                                                        devstdout,
                                                        function=None)

        # install the DIAMOND software
        elif app_code == xlib.get_diamond_code():
            # -- package_code_list = [(xlib.get_diamond_conda_code(), 'last')]
            package_code_list = [(xlib.get_diamond_conda_code(), '0.9.34')]
            devstdout = xlib.DevStdOut(
                xbioinfoapp.install_conda_package_list.__name__)
            OK = xbioinfoapp.install_conda_package_list(app_code,
                                                        app_name,
                                                        package_code_list,
                                                        devstdout,
                                                        function=None)

        # install the Entrez Direct software
        elif app_code == xlib.get_entrez_direct_code():
            package_code_list = [(xlib.get_entrez_direct_conda_code(), 'last')]
            devstdout = xlib.DevStdOut(
                xbioinfoapp.install_conda_package_list.__name__)
            OK = xbioinfoapp.install_conda_package_list(app_code,
                                                        app_name,
                                                        package_code_list,
                                                        devstdout,
                                                        function=None)

        # install the Miniconda3 software
        elif app_code == xlib.get_miniconda3_code():
            devstdout = xlib.DevStdOut(xbioinfoapp.install_miniconda3.__name__)
            OK = xbioinfoapp.install_miniconda3(devstdout, function=None)

        # install R and analysis packages
        elif app_code == xlib.get_r_code():
            devstdout = xlib.DevStdOut(xbioinfoapp.install_r.__name__)
            OK = xbioinfoapp.install_r(devstdout, function=None)

        # install the TransDecoder software
        elif app_code == xlib.get_transdecoder_code():
            package_code_list = [(xlib.get_transdecoder_conda_code(), 'last')]
            devstdout = xlib.DevStdOut(
                xbioinfoapp.install_conda_package_list.__name__)
            OK = xbioinfoapp.install_conda_package_list(app_code,
                                                        app_name,
                                                        package_code_list,
                                                        devstdout,
                                                        function=None)

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