### Check that there is a database else built it DatabaseName = args.database CheckDatabase_BlastdbcmdProcess = BlastPlus.Blastdbcmd(DatabaseName, "", "") if not CheckDatabase_BlastdbcmdProcess.is_database(): logger.info("Database %s does not exist" % DatabaseName) #Build blast formated database from a fasta file if args.fastq or args.fasta: if args.fastq: if not os.path.isfile(args.fastq): logger.error("The fastq file (-fq) does not exist.") sys.exit(1) else: # Format the fastq file in fasta InputFasta = TmpDirName + "/" + os.path.basename(args.fastq) + ".fasta" logger.info("Convert the fastq file in fasta format") ExitCode = ApytramNeeds.fastq2fasta(args.fastq,InputFasta) elif args.fasta: InputFasta = args.fasta if not os.path.isfile(InputFasta): logger.error("The fasta file (-fa) does not exist.") sys.exit(1) if os.path.isdir(os.path.dirname(DatabaseName)): logger.info("Database directory exists") else: logger.info("Database directory does not exist, we create it") os.makedirs(os.path.dirname(DatabaseName)) # database building logger.info(DatabaseName + " database building") MakeblastdbProcess = BlastPlus.Makeblastdb(InputFasta,DatabaseName) ExitCode = MakeblastdbProcess.launch()
if not os.path.isfile(fastq): logger.error("The fastq file (%s) does not exist." %fastq) end(1) # Format the fastq file in fasta InputFasta = "%s/input_fastq.fasta" %(TmpDirName) logger.info("Convert the fastq file in fasta format") start_convert = time.time() input_size = ApytramNeeds.get_size(args.fastq) logger.debug("size of input files: %s " %input_size) if input_size > FreeSpaceTmpDir: logger.error("Not enough available free space in %s to convert input files" %TmpDirName) end(1) if input_size*2 > FreeSpaceDBDir: logger.error("Not enough available free space in %s to build the database" %DatabaseDirName) end(1) out,err = ApytramNeeds.fastq2fasta(" ".join(args.fastq),InputFasta) if err: logger.error(err) end(1) logger.info("Convertion takes %s seconds" %(time.time() - start_convert)) elif args.fasta: for fasta in args.fasta: if not os.path.isfile(fasta): logger.error("The fasta file (%s) does not exist." %fasta) end(1) # Check enough available free space input_size = ApytramNeeds.get_size(args.fasta) logger.debug("size of input files: %s " %input_size) if input_size*2 > FreeSpaceDBDir: logger.error("Not enough available free space in %s to build the database" %DatabaseDirName) end(1)