Thank you very much for the help. it worked.
Hello all, I have a multi fasta file in which many sequences contain long runs of Ns. I want to reduce the length of Ns to a maximum of 150 any suggestions? Thank you,
The example sequence below contains a run of 215 Ns.
Seq1 TAGCAGCAGCAATAGCACTAGCAGTACGAGTAGCGGTAGCAGCAggtagtagcagtagcagcagtagtagaagtagtagtagtagtagtagtagtagtactagt agtactagtagtagtagtagcagcagcagcagcagcagcagtagcagcagccgCAGGGGGAGACAAANNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNTAGTAGAATGGGTGGTATaagtagcagcagcagcagcagcagcagtagcagcagcagcagctgTAGCAATAACAGCAGCA GCACCAGCAGTAGctgtagcagcagcagtagcagcagcaagAGTAGCAGGAGGAGTAGGAGGAGTAGGAGNNNNNNNNNNNNNNNNNNNNNNN NNNNNNNNNNNNNNNNNNNNNNGGCAacagtagtagcagcagcagcagtagcagcaggagtagcagtagcagtagtagtagc
2 answers
Seqkit has quite good fasta manupulation functions especially seqkit replace in this case https://bioinf.shenwei.me/seqkit/usage/#replace
it takes search patterns with -p argument which in this case is N repeated 150 or more times N{150,} and -r as replacement which can be N typed 150 times or -
seqkit replace -p '(N{150,})' -r $(printf "%0.sN" {1..150}) -s -i yourFastaFile.fa
validate+close the answer by clicking on the green mark on the left please.
Log in to answer this question.