mhahsler / rBLAST

Interface for the Basic Local Alignment Search Tool (BLAST) - R-Package
GNU General Public License v3.0
103 stars 22 forks source link

avoid warning if don't give a match against the data base #30

Open cabraham03 opened 1 year ago

cabraham03 commented 1 year ago

I’m trying to find genes obtained from genome and compare with a Virulent Factors database (VFDB), so, not all genes from the genome will give a match against the database; my problem is, if don’t give a match against database how to avoid a Error/Warnings:

VFDB is the database

sq1 is a Biostrings sequence

stats::predict(VFDB, sq1, custom_format = "qseqid sseqid pident length mismatch gapopen qstart qend sstart send qlen slen evalue bitscore qcovs") Error in read.table(outfile, sep = ",", quote = "") : no lines available in input [1] qseqid sseqid pident length mismatch gapopen qstart qend sstart send qlen slen evalue bitscore qcovs

<0 rows> (or 0-length row.names) Warning message: In predict.BLAST(VFDB, sq1, custom_format = "qseqid sseqid pident length mismatch gapopen qstart qend sstart send qlen slen evalue bitscore qcovs") : BLAST did not return a match! I just want to avoid the Error/Warning, if don't return any match just use the next seq in a loop # F multiples seqs in Biostrings format for(i in 1:length(F)){ result <- stats::predict(VFDB, F[i], custom_format = "qseqid sseqid pident length mismatch gapopen qstart qend sstart send qlen slen evalue bitscore qcovs") # some code to avoid the warning with seqs that did not match !!!! }
mhahsler commented 7 months ago

The typical way to do this in R is to use

suppressWarnings()

and

try().