test if file is valid FASTA using grep (i.e. full file matching single regular expression)

What is a simple way to test if given file is valid FASTA:

valid_example.fasta

>genename1 atgcgtcactgNNNNNactgat
>genename 2 ACACTTACAGGGCTAC

>genename3 ATCCaACTACGGCTGGACTTGCGGCAT

I tried the following, but it would give a match if there's at least 1 valid gene, as opposed to all of them

grep -Pli "(>.+\n[atgcn]\n+)*" valid_example.fasta

Answers


Use the -v flag to invert the match. Then check to see if any lines match.

You might want to do like

grep -qv [other options] [pattern] $file || echo $file matches

Need Your Help

how to register apid in urban airship for android?

android urbanairship.com

I have completed client side code by download sample from git for push notification in android.

Retrieving data from core data

iphone objective-c xcode core-data xcdatamodel

I'm using an xcdatamodel to define a number of classes based upon CoreData data entities. This is working great and I can retrieve them in accordance to Apple's examples:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.