BlastnProcess = BlastPlus.Blast("blastn", DatabaseName, BaitSequences) BlastnProcess.Evalue = Evalue BlastnProcess.Task = "blastn" BlastnProcess.Threads = Threads BlastnProcess.OutFormat = "6 sacc" # Write read names in ReadNamesFile ExitCode = BlastnProcess.launch(ReadNamesFile) StatsDict[(i)]["BlastTime"] = time.time() - start_blast_time logger.debug("blast --- %s seconds ---" % (StatsDict[(i)]["BlastTime"])) if PairedData: # Get paired reads names and remove duplicated names ExitCode = ApytramNeeds.add_paired_read_names(ReadNamesFile) else: # Remove duplicated names ExitCode = ApytramNeeds.remove_duplicated_read_names(ReadNamesFile) # Compare the read list names with the list of the previous iteration: Identical = ApytramNeeds.are_identical(ReadNamesFile,"%s/ReadNames.%d.txt" % (TmpDirName,i-1)) if Identical and not FinishAllIter: logger.info("Reads from the current iteration are identical than the previous") Stop = True IterationNotFinished = True i -= 1 else: ### Retrieve sequences logger.info("Retrieve sequences") ReadFasta = TmpDirName + "/Reads.%d.fasta" % (i) BlastdbcmdProcess = BlastPlus.Blastdbcmd(DatabaseName, ReadNamesFile, ReadFasta)
# Write read names in ReadNamesFile if the file does not exist if not os.path.isfile(ReadNamesFile): (out,err) = BlastnProcess.launch(ReadNamesFile) else: logger.warn("%s has already been created, it will be used" %ReadNamesFile ) StatsDict[i]["BlastTime"] = time.time() - start_blast_time logger.debug("blast --- %s seconds ---" % (StatsDict[i]["BlastTime"])) if PairedData: # Get paired reads names and remove duplicated names logger.info("Get paired reads names and remove duplicated names") ExitCode = ApytramNeeds.add_paired_read_names(ReadNamesFile) else: # Remove duplicated names logger.info("Remove duplicated names") out, err = ApytramNeeds.remove_duplicated_read_names(ReadNamesFile) if err != "\n": logger.error(err) # Count the number of reads which will be used in the Trinity assembly logger.info("Count the number of reads") StatsDict[i]["ReadsNumber"] = ApytramNeeds.count_lines(ReadNamesFile) if not StatsDict[i]["ReadsNumber"]: logger.warning("No read recruted by Blast at the iteration %s" %i) Stop = True IterationNotFinished = True i -= 1 else: # Compare the read list names with the list of the previous iteration: Identical = ApytramNeeds.are_identical(ReadNamesFile,"%s/ReadNames.%d.txt" % (TmpDirName,i-1))