text: user9975: De novo genome assembly for non-model organisms face the issue of bacterial contamination. For assembled contigs with mostly bacterial-like sequences (based on BLAST search), the entire contig can be dropped off. But for a long contig with small fragments of bacterial-like sequences, one way to solve it is to break the contigs into smaller pieces and drop the bacterial-like pieces. It would work better if the raw reads could be removed BEFORE assembly. This was commonly done for Illumina reads, but for PacBio long reads (non-HiFi reads) with a higher error rate, is it possible to filter contaminated bacterial sequences based on sequence similarity, like BLAST, Kraken? Of course, the potentially contaminated region should be long enough to drop the entire sequence, for PacBio long reads. Maybe 30%? Any suggestion of the processing details?
  
  user2108: I don't think that in principle the issue is any different for PacBio and Illumina; it's just that the process might be noisier with higher error rates. Note that PacBio errors aren't randomly distributed substitutions and probably many (most?) short-ish k-mers (<30nt) will likely be intact. I would suggest doing k-mer filtering of your reads as suggested here or here or here.
  Alternately, use your favorite alignment-based technique, if you have a good idea of what your contaminant is. In principle PB reads will be better filtered by this method than Illumina as local alignment will be able to figure out the errors quite well with longer queries.
  If you go the route of trying to do alignment to some set of contaminant references, the obvious answer would be to use minimap2 as your aligner as this is exactly the task that it is designed for. You can then use samtools to filter out anything that maps well.
  Here is a related question/answer that also addresses the contaminant issue and suggests using Blobology, which I'm not familiar with but may be helpful (granted it also seems to be Illumina-centric). Genome-size estimation using k-mers on PB reads appears to be pretty accurate too, so I think that it's likely ok to work with raw PB k-mers.
  
original_text: 9975: <p>De novo genome assembly for non-model organisms face the issue of bacterial contamination. For assembled contigs with mostly bacterial-like sequences (based on BLAST search), the entire contig can be dropped off. But for a long contig with small fragments of bacterial-like sequences, one way to solve it is to break the contigs into smaller pieces and drop the bacterial-like pieces. It would work better if the raw reads could be removed BEFORE assembly. This was commonly done for Illumina reads, but for PacBio long reads (non-HiFi reads) with a higher error rate, is it possible to filter contaminated bacterial sequences based on sequence similarity, like BLAST, Kraken? Of course, the potentially contaminated region should be long enough to drop the entire sequence, for PacBio long reads. Maybe 30%? Any suggestion of the processing details?</p>
   2108: <p>I don't think that in principle the issue is any different for PacBio and Illumina; it's just that the process might be noisier with higher error rates. Note that <a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5553090/" rel="nofollow noreferrer">PacBio errors aren't randomly distributed substitutions</a> and probably many (most?) short-ish k-mers (&lt;30nt) will likely be intact. I would suggest doing k-mer filtering of your reads as suggested <a href="https://www.biostars.org/p/12988/" rel="nofollow noreferrer">here</a> or <a href="https://www.researchgate.net/post/What_methods_programs_are_recommended_to_clean-up_a_genome_from_contaminating_reads" rel="nofollow noreferrer">here</a> or <a href="https://www.biostars.org/p/130/" rel="nofollow noreferrer">here</a>.</p>
  <p>Alternately, use your favorite alignment-based technique, if you have a good idea of what your contaminant is. In principle PB reads will be <em>better</em> filtered by this method than Illumina as local alignment will be able to figure out the errors quite well with longer queries.</p>
  <p>If you go the route of trying to do alignment to some set of contaminant references, the obvious answer would be to use <a href="https://github.com/lh3/minimap2" rel="nofollow noreferrer">minimap2</a> as your aligner as this is exactly the task that it is designed for. You can then use <a href="http://www.htslib.org/" rel="nofollow noreferrer">samtools</a> to filter out anything that maps well.</p>
  <p>Here is a related question/answer that also addresses the contaminant issue and suggests using <a href="https://github.com/blaxterlab/blobology" rel="nofollow noreferrer">Blobology</a>, which I'm not familiar with but may be helpful (granted it also seems to be Illumina-centric). Genome-size estimation using k-mers on PB reads appears to be pretty accurate too, so I think that it's likely ok to work with raw PB k-mers.</p>
  