def check_db(which_blast=""):
    global options
    in_index = options.reference_fa_base + '.index'
    if options.reference_fa_base:
        time0 = time.time()
        ref_fasta = read_fasta(options.reference_fa_base)
        if len(ref_fasta[0]) > 1:
            options.reference_fa_base += '.1st.fasta'
            write_fasta(out_file=options.reference_fa_base,
                        matrix=[[ref_fasta[0][0]], [ref_fasta[1][0]],
                                ref_fasta[2]],
                        overwrite=True)
            sys.stdout.write(
                '\nWarning: multi-seqs in reference file, only use the 1st sequence.'
            )
        elif len(ref_fasta[0]) == 0:
            sys.stdout.write('\nError: illegal reference file!')
            exit()
        make_blast_db(input_file=options.reference_fa_base,
                      output_base=in_index,
                      which_blast=which_blast)
        sys.stdout.write('\nMaking BLAST db cost ' + str(time.time() - time0))
    else:
        sys.stdout.write('\nError: No reference input!')
        exit()
    return in_index
def check_db(reference_fa_base, which_blast=""):
    in_index = reference_fa_base + '.index'
    if min([os.path.exists(in_index+postfix) for postfix in ('.nhr', '.nin', '.nsq')]):
        pass
    elif reference_fa_base:
        print('Making BLAST db ... ')
        make_blast_db(input_file=reference_fa_base, output_base=in_index, which_blast=which_blast)
        print('Making BLAST db finished.')
    else:
        print('ERROR: No reference input!')
        exit()
    return in_index
Пример #3
0
def initialize_notation_database(which_blast, overwrite=False):
    for fasta_f in os.listdir(NOT_DIR):
        if fasta_f.endswith(".fasta") and fasta_f[:-6] in ("embplant_pt", "other_pt", "embplant_mt", "embplant_nr",
                                                           "animal_mt", "fungus_mt"):
            fasta_f = os.path.join(NOT_DIR, fasta_f)
            output_base = remove_db_postfix(fasta_f)
            sys.stdout.write("makeblastdb " + output_base + " ... ")
            sys.stdout.flush()
            if overwrite or sum([os.path.exists(output_base + postfix) for postfix in (".nhr", ".nin", ".nsq")]) != 3:
                make_blast_db(input_file=fasta_f,
                              output_base=output_base,
                              which_blast=which_blast)
                sys.stdout.write("finished\n")
            else:
                sys.stdout.write("skipped\n")
Пример #4
0
def initialize_notation_database(which_blast, fasta_f, overwrite=False):
    # blast index
    output_base = remove_db_postfix(fasta_f)
    sys.stdout.write("makeblastdb " + os.path.basename(fasta_f) + " ... ")
    sys.stdout.flush()
    if overwrite or sum([
            os.path.exists(output_base + postfix)
            for postfix in (".nhr", ".nin", ".nsq")
    ]) != 3:
        make_blast_db(input_file=fasta_f,
                      output_base=output_base,
                      which_blast=which_blast)
        sys.stdout.write("finished\n")
    else:
        sys.stdout.write("skipped\n")