Ejemplo n.º 1
0
    if args.records:
        records = args.records
    if args.output_file:
        output_file = args.output_file
    if args.email:
        email = args.email
    if args.db:
        db = args.db

    if (input_file or records) and output_file and email and db:
        if records:
            records = records.split(",")
        elif input_file:
            records = krio.read_table_file(
                handle=None,
                path=input_file,
                has_headers=False,
                headers=None,
                delimiter=",",
                quotechar='"',
                stripchar="",
                commentchar="#",
                rettype="set",  # dict, list, set
            )

        records = [int(x) for x in records]
        records = sorted(list(records))
        records = [str(x) for x in records]

        krncbi.download_sequence_records(output_file, records, db, email)
    hacks = None
    hacks_data_location = None

    if args.hacks:
        hacks = args.hacks.split(',')
        if args.hacks_data_location:
            hacks_data_location = dict()
            for i, hack in enumerate(hacks):
                hacks_data_location[hack] = args.hacks_data_location.split(',')[i]

    ncbi_names_table = None
    if args.ncbi_names_file:
        ncbi_names_table = krio.read_table_file(
            path=args.ncbi_names_file,
            has_headers=False,
            headers=('tax_id', 'name_txt', 'unique_name', 'name_class'),
            delimiter='\t|',
            quotechar=None,
            stripchar='"',
            rettype='dict')

    synonymy_table = None
    if args.synonymy_file:
        synonymy_table = krio.read_table_file(
            path=args.synonymy_file,
            has_headers=True, headers=None, delimiter=',')

    unresolvable_taxonomy_list = None
    if args.unresolvable_taxonomy_file:
        unresolvable_taxonomy_list = krio.read_table_file(
            path=args.unresolvable_taxonomy_file,
            has_headers=True,
    format = None

    args = parser.parse_args()

    if args.input_file:
        input_file = args.input_file
    if args.output_file:
        output_file = args.output_file
    if args.format:
        format = args.format
    if args.names:

        names = krio.read_table_file(
            path=args.names,
            has_headers=False,
            headers=None,
            delimiter=',',
            quotechar=None,
            stripchar='"',
            rettype='set')

        if not names:
            names = args.names.split(',')

    if args.action:
        action = args.action

    if input_file and output_file and format:

        alignment = AlignIO.read(input_file, format)

        good_sequences = list()