Example #1
0
final_gbk = os.path.join(basedir, organism_name + '.gbk')
final_tbl = os.path.join(basedir, organism_name + '.tbl')
final_proteins = os.path.join(basedir, organism_name + '.proteins.fa')
final_transcripts = os.path.join(basedir, organism_name + '.transcripts.fa')
final_validation = os.path.join(basedir, organism_name + '.validation.txt')
final_error = os.path.join(basedir, organism_name + '.error.summary.txt')
final_fixes = os.path.join(basedir, organism_name + '.models-need-fixing.txt')

#retrieve files/reorganize
shutil.copyfile(os.path.join(basedir, 'tbl2asn', 'genome.gbf'), final_gbk)
shutil.copyfile(os.path.join(basedir, 'tbl2asn', 'genome.tbl'), final_tbl)
shutil.copyfile(os.path.join(basedir, 'tbl2asn', 'genome.val'),
                final_validation)
shutil.copyfile(os.path.join(basedir, 'tbl2asn', 'errorsummary.val'),
                final_error)
lib.gb2allout(final_gbk, final_gff, final_proteins, final_transcripts,
              final_fasta)
errors = lib.ncbiCheckErrors(final_error, final_validation, locustag,
                             final_fixes)
if errors > 0:
    lib.log.info(
        "Manually edit the tbl file %s, then run:\n\nfunannotate fix -i %s -t %s\n"
        % (final_tbl, final_gbk, final_tbl))
else:
    contigs, genes, trnas = lib.countGenBank(final_gbk)
    lib.log.info(
        'Output genome consists of: {:,} contigs containing {:,} protein coding genes and {:,} tRNA genes'
        .format(contigs, genes, trnas))

#clean up
shutil.rmtree(os.path.join(basedir, 'tbl2asn'))
Example #2
0
                os.makedirs(os.path.join(outputdir, 'annotate_results'))
            if not os.path.isdir(os.path.join(outputdir, 'logfiles')):
                os.makedirs(os.path.join(outputdir, 'logfiles'))
        genbank = args.genbank
        Scaffolds = os.path.join(outputdir, 'annotate_misc',
                                 'genome.scaffolds.fasta')
        Proteins = os.path.join(outputdir, 'annotate_misc',
                                'genome.proteins.fasta')
        Transcripts = os.path.join(outputdir, 'annotate_misc',
                                   'genome.transcripts.fasta')
        GFF = os.path.join(outputdir, 'annotate_misc', 'genome.gff3')
        lib.log.info("Checking GenBank file for annotation")
        if not lib.checkGenBank(genbank):
            lib.log.error("Found no annotation in GenBank file, exiting")
            sys.exit(1)
        lib.gb2allout(genbank, GFF, Proteins, Transcripts, Scaffolds)

else:
    #should be a folder, with funannotate files, thus store results there, no need to create output folder
    if not os.path.isdir(args.input):
        lib.log.error("%s directory does not exist" % args.input)
        sys.exit(1)
    if os.path.isdir(os.path.join(
            args.input,
            'update_results')):  #funannotate results should be here
        inputdir = os.path.join(args.input, 'update_results')
        outputdir = args.input
    elif os.path.isdir(os.path.join(args.input, 'predict_results')):
        inputdir = os.path.join(args.input, 'predict_results')
        outputdir = args.input
    else:
        else:
            lib.log.error("Output directory %s already exists, will use any existing data.  If this is not what you want, exit, and provide a unique name for output folder" % (outputdir))
            if not os.path.isdir(os.path.join(outputdir, 'annotate_misc')):
                os.makedirs(os.path.join(outputdir, 'annotate_misc'))
            if not os.path.isdir(os.path.join(outputdir, 'annotate_results')):
                os.makedirs(os.path.join(outputdir, 'annotate_results'))
        genbank = args.genbank
        Scaffolds = os.path.join(outputdir, 'annotate_misc', 'genome.scaffolds.fasta')
        Proteins = os.path.join(outputdir, 'annotate_misc', 'genome.proteins.fasta')
        Transcripts = os.path.join(outputdir, 'annotate_misc', 'genome.transcripts.fasta')
        GFF = os.path.join(outputdir, 'annotate_misc', 'genome.gff3')
        lib.log.info("Checking GenBank file for annotation")
        if not lib.checkGenBank(genbank):
            lib.log.error("Found no annotation in GenBank file, exiting")
            os._exit(1)
        lib.gb2allout(genbank, GFF, Proteins, Transcripts, Scaffolds)
    
else:
    #should be a folder, with funannotate files, thus store results there, no need to create output folder
    if not os.path.isdir(args.input):
        lib.log.error("%i directory does not exist" % args.input)
        os._exit(1)
    if os.path.isdir(os.path.join(args.input, 'predict_results')): #funannotate results should be here
        inputdir = os.path.join(args.input, 'predict_results')
        outputdir = args.input
    else:
        inputdir = os.path.join(args.input) #here user specified the predict_results folder, or it is all together wrong, find out in next few lines
    #get files that you need
    for file in os.listdir(inputdir):
        if file.endswith('.gbk'):
            genbank = os.path.join(inputdir, file)