This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Detect/Filter Sequences That Contain A Large Number Of N Symbols?

I am using wgsim to simulate reads from randomly selected genome regions (hg19):

  1. bedtools shuffleBed to randomly permute location (1Mb);
  2. wgsim (0.3.1-r13) to simulate reads.

Noticed that sometimes wgsim stops (works fine for some fasta files and for specific fasta produces empty <out.read1.fq> <out.read2.fq> files and does nothing else).

Checked those 1Mb fasta files and they are all N's

   >Chr_random
   NNNNNNNNNNNNNNN
   ...
   NNNNNNNNNNNNNNN

Question:

  • How can solve this wgsim problem?
    Or
  • How can I filter out N rich fasta files?

NB: wgsim "chromosome specif bias" was reported before - Short Read Simulator For Cnv Indel? Don't know if I am encountering the same problem here.

Edit

I simply used grep but their might be more elegant way.

deleted-post

1 answer

This is one of the problems that can be somewhat deceiving with respect of the difficulty of solving it. Grepping for a stretch of Ns per file is good answer if that works for this problem.

If one wanted a more generic answer to find all Ns in a file that potentially contains a large number sequences some of which could be potentially huge then I there is no off-the shelf solution that comes to my mind.

It would probably require writing code that reads in fixed amount of data in and keeps a running tally of Ns while resetting for each fasta record. Or some clever regular expression perhaps.

Log in to answer this question.